From 5f0224c84e9da0a4660a3b7ebbcc0b450cee8501 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner <sebastian.wagner@tritum.de> Date: Sat, 5 Mar 2016 18:19:02 +0100 Subject: [PATCH] [TASK] EXT:form - prevent initial ajax call Initially, provide the whole configuration for the wizard through a requireJs config. Therefore, an early AJAX call to the WizardController can be omitted. With this patchset, no AJAX route for loading has to be registered. The loadAction is removed as well. Furthermore, a left over intialize script is dropped. The Wizard.Settings to configure the ExtJs viewport are used directly. Resolves: #74316 Releases: master Change-Id: I5278784cadc603238707b6e7b26426155e3c080c Reviewed-on: https://review.typo3.org/47110 Reviewed-by: Daniel Goerz <ervaude@gmail.com> Tested-by: Bjoern Jacob <bjoern.jacob@tritum.de> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../Classes/Controller/WizardController.php | 26 ------------------- .../form/Configuration/Backend/AjaxRoutes.php | 6 ----- .../Private/Language/locallang_wizard.xlf | 3 --- .../Public/JavaScript/Wizard/Initialize.js | 21 --------------- .../JavaScript/Wizard/Viewport/Right.js | 23 +++------------- 5 files changed, 3 insertions(+), 76 deletions(-) delete mode 100644 typo3/sysext/form/Resources/Public/JavaScript/Wizard/Initialize.js diff --git a/typo3/sysext/form/Classes/Controller/WizardController.php b/typo3/sysext/form/Classes/Controller/WizardController.php index 14df9b34fcf2..e7185dc80f9a 100644 --- a/typo3/sysext/form/Classes/Controller/WizardController.php +++ b/typo3/sysext/form/Classes/Controller/WizardController.php @@ -70,32 +70,6 @@ class WizardController ->withHeader('Pragma', 'no-cache'); } - /** - * The load action called via AJAX - * - * The action which should be taken when the form in the wizard is loaded - * - * @param ServerRequestInterface $request - * @param ResponseInterface $response the response object - * @return ResponseInterface returns a 500 error or a valid JSON response - */ - public function loadAction(ServerRequestInterface $request, ResponseInterface $response) - { - $result = $this->getRepository()->getRecordAsJson(); - if (!$result) { - $response = $response->withStatus(500); - $result = ['message' => $this->getLanguageService()->getLL('action_load_message_failed', false)]; - } else { - $result = ['configuration' => $result]; - } - $response->getBody()->write(json_encode($result)); - return $response - ->withHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT') - ->withHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT') - ->withHeader('Cache-Control', 'no-cache, must-revalidate') - ->withHeader('Pragma', 'no-cache'); - } - /** * Gets the repository object. * diff --git a/typo3/sysext/form/Configuration/Backend/AjaxRoutes.php b/typo3/sysext/form/Configuration/Backend/AjaxRoutes.php index 6942f36f7c9c..660792b6c3ab 100644 --- a/typo3/sysext/form/Configuration/Backend/AjaxRoutes.php +++ b/typo3/sysext/form/Configuration/Backend/AjaxRoutes.php @@ -5,12 +5,6 @@ use TYPO3\CMS\Form\Controller\WizardController; * Definitions for AJAX routes provided by EXT:form */ return [ - // Loads the current form wizard data - 'formwizard_load' => [ - 'path' => '/wizard/form/load', - 'target' => WizardController::class . '::loadAction' - ], - // Save the current form wizard 'formwizard_save' => [ 'path' => '/wizard/form/save', diff --git a/typo3/sysext/form/Resources/Private/Language/locallang_wizard.xlf b/typo3/sysext/form/Resources/Private/Language/locallang_wizard.xlf index 2066e59ba8aa..488988b1e490 100644 --- a/typo3/sysext/form/Resources/Private/Language/locallang_wizard.xlf +++ b/typo3/sysext/form/Resources/Private/Language/locallang_wizard.xlf @@ -45,9 +45,6 @@ <trans-unit id="action_save_message_saved"> <source>Changes saved successfully</source> </trans-unit> - <trans-unit id="action_load_message_failed"> - <source>Failed to save the form</source> - </trans-unit> <trans-unit id="button_remove"> <source>Remove</source> </trans-unit> diff --git a/typo3/sysext/form/Resources/Public/JavaScript/Wizard/Initialize.js b/typo3/sysext/form/Resources/Public/JavaScript/Wizard/Initialize.js deleted file mode 100644 index 593fddc1f9db..000000000000 --- a/typo3/sysext/form/Resources/Public/JavaScript/Wizard/Initialize.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Initialize - * - * Adds a listener to be notified when the document is ready - * (before onload and before images are loaded). - * Shorthand of Ext.EventManager.onDocumentReady. - * - * @param {Function} fn The method the event invokes. - * @param {Object} scope (optional) The scope (this reference) in which the handler function executes. Defaults to the browser window. - * @param {Boolean} options (optional) Options object as passed to {@link Ext.Element#addListener}. It is recommended that the options - * {single: true} be used so that the handler is removed on first invocation. - * - * @return void - */ -Ext.onReady(function() { - // Instantiate new viewport - TYPO3.Form.Wizard.Settings.ajaxUrl = document.location.href; - var viewport = new TYPO3.Form.Wizard.Viewport({}); - // When the window is resized, the viewport has to be resized as well - Ext.EventManager.onWindowResize(viewport.doLayout, viewport); -}); diff --git a/typo3/sysext/form/Resources/Public/JavaScript/Wizard/Viewport/Right.js b/typo3/sysext/form/Resources/Public/JavaScript/Wizard/Viewport/Right.js index c19d844ef640..994fee3aec4c 100644 --- a/typo3/sysext/form/Resources/Public/JavaScript/Wizard/Viewport/Right.js +++ b/typo3/sysext/form/Resources/Public/JavaScript/Wizard/Viewport/Right.js @@ -76,30 +76,13 @@ TYPO3.Form.Wizard.Viewport.Right = Ext.extend(Ext.Container, { }, /** - * Load the form with an AJAX call + * Load the form from config * * Loads the configuration and initializes the history */ loadForm: function() { - var wizardUrl = TYPO3.Form.Wizard.Settings.ajaxUrl; - var url = wizardUrl.substring(wizardUrl.indexOf('&P')); - url = TYPO3.settings.ajaxUrls['formwizard_load'] + url; - Ext.Ajax.request({ - url: url, - method: 'POST', - success: function(response, opts) { - var responseObject = Ext.decode(response.responseText); - this.loadConfiguration(responseObject.configuration); - this.initializeHistory(); - }, - failure: function(response, opts) { - Ext.MessageBox.alert( - 'Loading form', - 'Server-side failure with status code ' + response.status - ); - }, - scope: this - }); + this.loadConfiguration(TYPO3.Form.Wizard.Settings.Configuration); + this.initializeHistory(); }, /** -- GitLab