[TASK] EXT:form - prevent initial ajax call 10/47110/3
authorSebastian Wagner <sebastian.wagner@tritum.de>
Sat, 5 Mar 2016 17:19:02 +0000 (18:19 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 5 Mar 2016 19:33:54 +0000 (20:33 +0100)
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>
typo3/sysext/form/Classes/Controller/WizardController.php
typo3/sysext/form/Configuration/Backend/AjaxRoutes.php
typo3/sysext/form/Resources/Private/Language/locallang_wizard.xlf
typo3/sysext/form/Resources/Public/JavaScript/Wizard/Initialize.js [deleted file]
typo3/sysext/form/Resources/Public/JavaScript/Wizard/Viewport/Right.js

index 14df9b3..e7185dc 100644 (file)
@@ -71,32 +71,6 @@ class WizardController
     }
 
     /**
-     * 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.
      *
      * @return ContentRepository
index 6942f36..660792b 100644 (file)
@@ -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',
index 2066e59..488988b 100644 (file)
@@ -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 (file)
index 593fddc..0000000
+++ /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);
-});
index c19d844..994fee3 100644 (file)
@@ -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();
        },
 
        /**