From 69de2efd1343f684db37fa413d63763cc33ff366 Mon Sep 17 00:00:00 2001 From: Michael Oehlhof <typo3@oehlhof.de> Date: Thu, 22 Dec 2016 17:08:45 +0100 Subject: [PATCH] [BUGFIX] EXT:Scheduler: Post only fields of selected class on save MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When saving a new task, now only the extra fields of the selected class where submitted via post and no longer all extra fields of all possible classes. This prevents saving the wrong value if extra fields of different classes have the same id. Resolves: #25805 Releases: master Change-Id: I4f0ae67694fbc3b284e763e3edd123804d078350 Reviewed-on: https://review.typo3.org/51027 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Thomas Hohn <thomas@hohn.dk> Reviewed-by: Frank Nägler <frank.naegler@typo3.org> Tested-by: Frank Nägler <frank.naegler@typo3.org> Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl> Tested-by: Wouter Wolters <typo3@wouterwolters.nl> --- .../Classes/Controller/SchedulerModuleController.php | 4 +++- .../Resources/Public/JavaScript/Scheduler.js | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php b/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php index 25024277ff6f..f1b88eb6c474 100644 --- a/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php +++ b/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php @@ -162,7 +162,7 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas // Prepare main content $this->content .= '<h1>' . $this->getLanguageService()->getLL('function.' . $this->MOD_SETTINGS['function']) . '</h1>'; $this->content .= $this->getModuleContent(); - $this->content .= '</form>'; + $this->content .= '</form><div id="extraFieldsHidden"></div>'; } else { // If no access, only display the module's title $this->content = '<h1>' . $this->getLanguageService()->getLL('title.') . '</h1>'; @@ -800,6 +800,7 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas . '</div></div>'; // Display additional fields + $table[] = '<div id="extraFieldsSection">'; foreach ($allAdditionalFields as $class => $fields) { if ($class == $taskInfo['class']) { $additionalFieldsStyle = ''; @@ -820,6 +821,7 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas } } } + $table[] = '</div>'; $this->view->assign('table', implode(LF, $table)); $this->view->assign('now', $this->getServerTime()); diff --git a/typo3/sysext/scheduler/Resources/Public/JavaScript/Scheduler.js b/typo3/sysext/scheduler/Resources/Public/JavaScript/Scheduler.js index 92017b522d71..3e364a02f102 100644 --- a/typo3/sysext/scheduler/Resources/Public/JavaScript/Scheduler.js +++ b/typo3/sysext/scheduler/Resources/Public/JavaScript/Scheduler.js @@ -14,7 +14,9 @@ /** * Module: TYPO3/CMS/Scheduler/Scheduler */ -define(['jquery'], function($) { +define(['jquery', + 'TYPO3/CMS/Backend/SplitButtons' + ], function($, SplitButtons) { /** * @@ -168,5 +170,13 @@ define(['jquery'], function($) { $(Scheduler.initializeEvents); $(Scheduler.initializeDefaultStates); + SplitButtons.addPreSubmitCallback(function() { + var taskClass = $('#task_class').val(); + taskClass = taskClass.toLowerCase().replace(/\\/g, '-'); + + $('.extraFields').appendTo($('#extraFieldsHidden')); + $('.extra_fields_' + taskClass).appendTo($('#extraFieldsSection')); + }); + return Scheduler; }); -- GitLab