Fixed bug 12089: Make messages in reports module collapsible
authorSteffen Kamper <info@sk-typo3.de>
Wed, 30 Sep 2009 19:10:22 +0000 (19:10 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Wed, 30 Sep 2009 19:10:22 +0000 (19:10 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@6078 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/reports/ext_tables.php
typo3/sysext/reports/mod/index.php
typo3/sysext/reports/mod/mod_styles.css
typo3/sysext/reports/reports/class.tx_reports_reports_status.php

index 9e2be93..f9227ec 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-09-24  Steffen Kamper  <info@sk-typo3.de>
+
+       * Fixed bug 12089: Make messages in reports module collapsible
+
 2009-09-30  Oliver Hader  <oliver@typo3.org>
 
        * Fixed bug #12035: BE style must match t3skin in reports module and flash messages (thanks to Tom Ruether)
index 53a58a9..9b8a66c 100644 (file)
@@ -22,6 +22,7 @@ if (TYPO3_MODE == 'BE') {
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports']['tx_reports']['status']['security'] = 'tx_reports_reports_status_SecurityStatus';
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports']['tx_reports']['status']['configuration'] = 'tx_reports_reports_status_ConfigurationStatus';
 
+       $GLOBALS['TYPO3_CONF_VARS']['BE']['AJAX']['Reports::saveCollapseState'] = 'EXT:reports/reports/class.tx_reports_reports_status.php:tx_reports_reports_Status->saveCollapseState';
 }
 
 ?>
\ No newline at end of file
index 54dbd8f..b7ba410 100644 (file)
@@ -58,6 +58,7 @@ class tx_reports_Module extends t3lib_SCbase {
                        t3lib_extMgm::extPath('reports') . 'mod/mod_template.html'
                );
                $this->doc->backPath = $GLOBALS['BACK_PATH'];
+               $this->doc->getPageRenderer()->loadScriptaculous('effects');
                $this->doc->addStyleSheet(
                        'tx_reports',
                        '../' . t3lib_extMgm::siteRelPath('reports') . 'mod/mod_styles.css'
@@ -107,7 +108,6 @@ class tx_reports_Module extends t3lib_SCbase {
 
                                // Draw the form
                        $this->doc->form = '<form action="" method="post" enctype="multipart/form-data">';
-
                                // JavaScript
                        $this->doc->JScode = '
                                <script language="javascript" type="text/javascript">
@@ -115,6 +115,24 @@ class tx_reports_Module extends t3lib_SCbase {
                                        function jumpToUrl(URL) {
                                                document.location = URL;
                                        }
+                                       var state;
+                                       Event.observe(document, "dom:loaded", function(){
+                                               $$(".section-header").invoke("observe", "click", function(event){
+                                                       var item = Event.element(event);        
+                                                       if (item.hasClassName("expanded")) {
+                                                               item.removeClassName("expanded").addClassName("collapsed");
+                                                               Effect.BlindUp(item.next("div"), {duration : 0.5});
+                                                               state = 1;
+                                                       } else {
+                                                               item.removeClassName("collapsed").addClassName("expanded");
+                                                               Effect.BlindDown(item.next("div"), {duration : 0.5});
+                                                               state = 0;
+                                                       }
+                                                       new Ajax.Request("ajax.php", {
+                                                               parameters : "ajaxID=Reports::saveCollapseState&item=" + item.id + "&state=" + state
+                                                       });
+                                               }); 
+                                       });
                                </script>
                        ';
                        $this->doc->postCode='
@@ -246,6 +264,7 @@ class tx_reports_Module extends t3lib_SCbase {
                return $buttons;
        }
 
+
 }
 
 
index 5580d6f..51065c8 100644 (file)
@@ -27,64 +27,30 @@ body#ext-reports-mod-index-php {
 /* ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- */
 /* status report */
 
-table.system-status-report {
-       width: 100%;
-       margin: 10px 0px;
-       border-collapse: collapse;
-       border-top: 1px solid #595d66;
+#ext-reports-mod-index-php h2.section-header {
+       margin: 15px 0;
+       padding: 2px 0 0 20px;
+       cursor: pointer;
 }
-
-
-table.system-status-report th,
-table.system-status-report td {
-       border-width: 1px 0px;
-}
-
-table.system-status-report th,
-table.system-status-report td {
-       text-align: left;
-       padding: 6px;
-       font-size: 12px;
-}
-table.system-status-report th {
-       width: 300px;
-}
-table.system-status-report th a,
-table.system-status-report td a {
-       color: #000;
-       font-weight: bold;
-       text-decoration: none;
+#ext-reports-mod-index-php h2.collapsed {
+       background-image:url(../../../gfx/arrowright.png);
+       background-repeat:no-repeat;
 }
-
-table.system-status-report th a:hover,
-table.system-status-report td a:hover {
-       text-decoration: underline;
-}
-
-table.system-status-report th {
-       padding-left: 30px;
-       font-weight: bold;
+#ext-reports-mod-index-php h2.expanded {
+       background-image:url(../../../gfx/arrowdown.png);
+       background-repeat:no-repeat;
 }
 
-table.system-status-report td.merge-down,
-table.system-status-report th.merge-down {
-       border-bottom-width: 0px !important;
+#ext-reports-mod-index-php .message-body {
+       clear: left;
 }
 
-table.system-status-report td.merge-up {
-       border-top-width: 0px !important;
-       background-image: none;
-       padding-left: 30px;
+#ext-reports-mod-index-php .message-left {
+       float: left;
+       width: 400px;
 }
 
-table.system-status-report tr td.typo3-message {
-       background-image: none;
+#ext-reports-mod-index-php .message-right {
+       float: left;
 }
 
-table.system-status-report tr td.typo3-message ul,
-table.system-status-report tr td.typo3-message ol {
-       margin-top: 0px;
-}
-
-
-
index dd283c0..988670a 100644 (file)
@@ -96,14 +96,31 @@ class tx_reports_reports_Status implements tx_reports_Report {
         */
        protected function renderStatus(array $statusCollection) {
                $content = '';
+               $template = '
+               <div class="typo3-message message-###CLASS###">
+                       <div class="header-container">
+                               <div class="message-header message-left">###HEADER###</div>
+                               <div class="message-header message-right">###STATUS###</div>
+                       </div>
+                       <div class="message-body">###CONTENT###</div>
+               </div>';
 
                $statuses = $this->sortStatusProviders($statusCollection);
 
                foreach($statuses as $provider => $providerStatus) {
                        $providerState = $this->sortStatuses($providerStatus);
 
-                       $content .= '<h2>' . $provider . '</h2>';
-                       $content .= '<table class="system-status-report">';
+                       $id = str_replace(' ', '-', $provider);
+                       if (isset($GLOBALS['BE_USER']->uc['reports']['states'][$id]) && $GLOBALS['BE_USER']->uc['reports']['states'][$id]) {
+                               $collapsedStyle = 'style="display:none"';
+                               $collapsedClass = 'collapsed';
+                       } else {
+                               $collapsedStyle = '';
+                               $collapsedClass = 'expanded';
+                       }
+
+                       $content .= '<h2 id="' . $id . '" class="section-header ' . $collapsedClass . '">' . $provider . '</h2>
+                               <div ' . $collapsedStyle . '>';
                        $classes = array(
                                tx_reports_reports_status_Status::NOTICE  => 'notice',
                                tx_reports_reports_status_Status::INFO    => 'information',
@@ -113,18 +130,14 @@ class tx_reports_reports_Status implements tx_reports_Report {
                        );
 
                        foreach ($providerState as $status) {
-                               $class = 'typo3-message message-' . $classes[$status->getSeverity()];
-                               $description = $status->getMessage();
-       
-                               if (empty($description)) {
-                                       $content .= '<tr><th class="'. $class .' statusTitle">'. $status->getTitle() .'</th><td class="'. $class .'">'. $status->getValue() .'</td></tr>';
-                               } else {
-                                       $content .= '<tr><th class="'. $class .' merge-down">'. $status->getTitle() .'</th><td class="'. $class .' merge-down">'. $status->getValue() .'</td></tr>';
-                                       $content .= '<tr><td class="'. $class .' merge-up" colspan="2">'. $description .'</td></tr>';
-                               }
+                               $content .= strtr($template, array(
+                                       '###CLASS###'   => $classes[$status->getSeverity()],
+                                       '###HEADER###'  => $status->getTitle(),
+                                       '###STATUS###'  => $status->getValue(),
+                                       '###CONTENT###' => $status->getMessage(),
+                               ));
                        }
-       
-                       $content .= '</table>';
+                       $content .= '</div>';
                }
                return $content;
        }
@@ -181,6 +194,22 @@ class tx_reports_reports_Status implements tx_reports_Report {
                }
                return $statuses;
        }
+
+       /**
+        * saves the section toggle state in the backend user's uc
+        *
+        * @param       array           array of parameters from the AJAX interface, currently unused
+        * @param       TYPO3AJAX       object of type TYPO3AJAX
+        * @return      void
+        */
+       
+       public function saveCollapseState(array $params, TYPO3AJAX $ajaxObj) {
+               $item = t3lib_div::_POST('item');
+               $state = (bool)t3lib_div::_POST('state');
+
+               $GLOBALS['BE_USER']->uc['reports']['states'][$item] = $state;
+               $GLOBALS['BE_USER']->writeUC();
+       }
 }