[FEATURE] Add a "Run task" button to task overview 81/18081/3
authorThomas Löffler <loeffler@spooner-web.de>
Wed, 6 Feb 2013 20:48:30 +0000 (21:48 +0100)
committerIngo Renner <ingo@typo3.org>
Sat, 16 Feb 2013 23:07:46 +0000 (00:07 +0100)
Run a task directly with one click in task list

Releases: 6.1
Resolves: #45154
Change-Id: I42035d0ca0a5c51d092bec27ded1bddd16d1e9bb
Reviewed-on: https://review.typo3.org/18081
Reviewed-by: Ingo Renner
Tested-by: Ingo Renner
typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php
typo3/sysext/scheduler/Resources/Public/Images/Icons/RunTask.png [new file with mode: 0644]
typo3/sysext/scheduler/ext_tables.php
typo3/sysext/scheduler/mod1/locallang.xlf
typo3/sysext/scheduler/res/tx_scheduler_be.js

index 53e38c8..a094c06 100644 (file)
@@ -945,7 +945,7 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                                '0' => array(
                                        'tr' => array('<tr class="t3-row-header">', '</tr>'),
                                        'defCol' => array('<td>', '</td>'),
-                                       '1' => array('<td style="width: 56px;">', '</td>'),
+                                       '1' => array('<td style="width: 76px;">', '</td>'),
                                        '3' => array('<td colspan="2">', '</td>')
                                ),
                                'defRow' => array(
@@ -987,8 +987,9 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                                $editAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=edit&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:edit', TRUE) . '" class="icon">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-open') . '</a>';
                                $deleteAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=delete&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" onclick="return confirm(\'' . $GLOBALS['LANG']->getLL('msg.delete') . '\');" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:delete', TRUE) . '" class="icon">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-edit-delete') . '</a>';
                                $stopAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=stop&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" onclick="return confirm(\'' . $GLOBALS['LANG']->getLL('msg.stop') . '\');" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:stop', TRUE) . '" class="icon"><img ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->backPath, (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('scheduler') . '/res/gfx/stop.png')) . ' alt="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:stop') . '" /></a>';
-                               $enableAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=enable&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:enable', TRUE) . '" class="icon">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-edit-unhide') . '</a>';
-                               $disableAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=disable&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:disable', TRUE) . '" class="icon">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-edit-hide') . '</a>';
+                               $enableAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=enable&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:activate', TRUE) . '" class="icon">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-edit-unhide') . '</a>';
+                               $disableAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=disable&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:deactivate', TRUE) . '" class="icon">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-edit-hide') . '</a>';
+                               $runAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&tx_scheduler[execute][]=' . $schedulerRecord['uid'] . '" title="' . $GLOBALS['LANG']->getLL('action.run_task') . '" class="icon">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('extensions-scheduler-run-task') . '</a>';
                                // Define some default values
                                $lastExecution = '-';
                                $isRunning = FALSE;
@@ -1070,11 +1071,9 @@ 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" />';
-                                       // Show no action links (edit, delete) if task is running
+
                                        $actions = $editAction . $deleteAction;
-                                       if ($isRunning) {
-                                               $actions = $stopAction;
-                                       }
+
                                        // Check the disable status
                                        // Row is shown dimmed if task is disabled, unless it is still running
                                        if ($schedulerRecord['disable'] == 1 && !$isRunning) {
@@ -1084,6 +1083,14 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                                        } elseif (!$isRunning) {
                                                $actions .= $disableAction;
                                        }
+
+                                       // Show no action links (edit, delete) if task is running
+                                       if ($isRunning) {
+                                               $actions = $stopAction;
+                                       } else {
+                                               $actions .= $runAction;
+                                       }
+
                                        // Check if the last run failed
                                        $failureOutput = '';
                                        if (!empty($schedulerRecord['lastexecution_failure'])) {
diff --git a/typo3/sysext/scheduler/Resources/Public/Images/Icons/RunTask.png b/typo3/sysext/scheduler/Resources/Public/Images/Icons/RunTask.png
new file mode 100644 (file)
index 0000000..2f6ea1f
Binary files /dev/null and b/typo3/sysext/scheduler/Resources/Public/Images/Icons/RunTask.png differ
index b070b9f..91f2b07 100755 (executable)
@@ -7,5 +7,14 @@ if (TYPO3_MODE == 'BE') {
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule('tools', 'txschedulerM1', '', \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'mod1/');
        // Add context sensitive help (csh) to the backend module
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('_MOD_tools_txschedulerM1', 'EXT:' . $_EXTKEY . '/mod1/locallang_csh_scheduler.xml');
+
+       // Register specific icon for run task button
+       \TYPO3\CMS\Backend\Sprite\SpriteManager::addSingleIcons(
+               array(
+                       'run-task' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . 'Resources/Public/Images/Icons/RunTask.png'
+               ),
+               $_EXTKEY
+       );
+
 }
 ?>
\ No newline at end of file
index 116ce0c..6f477e7 100644 (file)
                        <trans-unit id="title" xml:space="preserve">
                                <source>TYPO3 Scheduler administration module</source>
                        </trans-unit>
+                       <trans-unit id="action.run_task" xml:space="preserve">
+                               <source>Run task</source>
+                       </trans-unit>
                </body>
        </file>
 </xliff>
index cdc4eeb..705afe2 100644 (file)
@@ -165,4 +165,13 @@ Ext.onReady(function(){
                        }
                }
        });
+
+       Ext.addBehaviors({
+                       // Add a listener for click on run single task
+               '.t3-icon-scheduler-run-task@click' : function(event, element) {
+                       var checkbox = Ext.get(element).parent('tr').child('input[type="checkbox"]');
+                       var idParts = checkbox.id.split('_');
+                       Ext.select('#executionstatus_' + idParts[1]).item(0).set({src: TYPO3.settings.scheduler.runningIcon});
+               }
+       })
 });
\ No newline at end of file