[BUGFIX] Scheduler now offers an enable/disable toggle in list view 09/36209/5
authorMathias Schreiber <mathias.schreiber@wmdb.de>
Sat, 24 Jan 2015 10:46:31 +0000 (11:46 +0100)
committerBenjamin Mack <benni@typo3.org>
Sat, 24 Jan 2015 23:53:29 +0000 (00:53 +0100)
In order to quickly enable or disable tasks we introduced a new toggle
control in the list view.

Resolves: #25631
Releases: master
Change-Id: I42b3c0be7996bd4a53a8e58393420694b1cb057b
Reviewed-on: http://review.typo3.org/36209
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Tested-by: Michael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>
typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php

index 68ecacc..318e272 100644 (file)
@@ -234,6 +234,10 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                                                $this->stopTask();
                                                $content .= $this->listTasksAction();
                                                break;
+                                       case 'toggleHidden':
+                                               $this->toggleDisableAction();
+                                               $content .= $this->listTasksAction();
+                                               break;
                                        case 'list':
 
                                        default:
@@ -506,6 +510,17 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
        }
 
        /**
+        * Toggles the disabled state of the submitted task
+        *
+        * @return void
+        */
+       protected function toggleDisableAction() {
+               $task = $this->scheduler->fetchTask($this->submittedData['uid']);
+               $task->setDisabled(!$task->isDisabled());
+               $task->save();
+       }
+
+       /**
         * Return a form to add a new task or edit an existing one
         *
         * @return string HTML form to add or edit a task
@@ -909,6 +924,15 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                                foreach ($taskGroup['tasks'] as $schedulerRecord) {// Define action icons
                                        $editAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=edit&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:edit', TRUE) . '" class="icon">' .
                                                IconUtility::getSpriteIcon('actions-document-open') . '</a>';
+                                       if ((int)$schedulerRecord['disable'] === 1) {
+                                               $translationKey = 'enable';
+                                               $spriteIcon = 'actions-edit-unhide';
+                                       } else {
+                                               $translationKey = 'disable';
+                                               $spriteIcon = 'actions-edit-hide';
+                                       }
+                                       $toggleHiddenAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=toggleHidden&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:' . $translationKey, TRUE) . '" class="icon">' .
+                                               IconUtility::getSpriteIcon($spriteIcon) . '</a>';
                                        $deleteAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=delete&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" onclick="return confirm(\'' . $this->getLanguageService()->getLL('msg.delete') . '\');" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:delete', TRUE) . '" class="icon">' .
                                                IconUtility::getSpriteIcon('actions-edit-delete') . '</a>';
                                        $stopAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=stop&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" onclick="return confirm(\'' . $this->getLanguageService()->getLL('msg.stop') . '\');" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:stop', TRUE) . '" class="icon">' .
@@ -993,7 +1017,7 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                                                // Define checkbox
                                                $startExecutionElement = '<input type="checkbox" name="tx_scheduler[execute][]" value="' . $schedulerRecord['uid'] . '" id="task_' . $schedulerRecord['uid'] . '" class="checkboxes" />';
 
-                                               $actions = $editAction . $deleteAction;
+                                               $actions = $editAction . $toggleHiddenAction . $deleteAction;
 
                                                // Check the disable status
                                                // Row is shown dimmed if task is disabled, unless it is still running