[BUGFIX] Apply potential changes after form editor save operation 62/56162/2
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Wed, 28 Feb 2018 23:21:36 +0000 (00:21 +0100)
committerSusanne Moog <susanne.moog@typo3.org>
Thu, 15 Mar 2018 14:21:56 +0000 (15:21 +0100)
Apply potential form definition changes within the form editor,
if the form definition changes while saving it.
This is possible through the hook ['ext/form']['beforeFormSave']

Releases: master, 8.7
Resolves: #84081
Change-Id: I0c20e0d20f9ec9ec8ccc0f279f68f9b4ebdfc306
Reviewed-on: https://review.typo3.org/56162
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
typo3/sysext/form/Classes/Controller/FormEditorController.php
typo3/sysext/form/Resources/Public/JavaScript/Backend/FormEditor.js
typo3/sysext/form/Resources/Public/JavaScript/Backend/FormEditor/Mediator.js

index be7baed..ec4b1ec 100644 (file)
@@ -181,6 +181,8 @@ class FormEditorController extends AbstractBackendController
             ];
         }
 
+        $response['formDefinition'] = $formDefinition;
+
         $this->view->assign('response', $response);
         // saveFormAction uses the extbase JsonView::class.
         // That's why we have to set the view variables in this way.
index be98568..ea37378 100644 (file)
@@ -132,6 +132,17 @@ define(['jquery',
       };
 
       /**
+       * @internal
+       *
+       * @return void
+       * @throws 1519855175
+       */
+      function setFormDefinition(formDefinition) {
+        assert('object' === $.type(formDefinition), 'Invalid parameter "formDefinition"', 1519855175);
+        _getApplicationStateStack().setCurrentState('formDefinition', _getFactory().createFormElement(formDefinition, undefined, undefined, true));
+      };
+
+      /**
        * @public
        *
        * @param string type
@@ -1119,6 +1130,7 @@ define(['jquery',
         getMaximalApplicationStates: getMaximalApplicationStates,
         getCurrentApplicationStates: getCurrentApplicationStates,
         getCurrentApplicationStatePosition: getCurrentApplicationStatePosition,
+        setFormDefinition: setFormDefinition,
 
         run: run
       };
index f698da1..8d8b6fe 100644 (file)
@@ -200,13 +200,24 @@ define(['jquery',
        *
        * @param string
        * @param array
-       *              args[0] = html
+       *              args[0] = response
        * @return void
        * @subscribe core/ajax/saveFormDefinition/success
        */
       getPublisherSubscriber().subscribe('core/ajax/saveFormDefinition/success', function(topic, args) {
         getFormEditorApp().setUnsavedContent(false);
         getViewModel().showSaveSuccessMessage();
+
+        getFormEditorApp().setFormDefinition(args[0]['formDefinition']);
+
+        getViewModel().addStructureRootElementSelection();
+        getFormEditorApp().setCurrentlySelectedFormElement(getRootFormElement());
+        getViewModel().setStructureRootElementTitle();
+        getViewModel().setStageHeadline();
+        getViewModel().renderAbstractStageArea();
+        getViewModel().renewStructure();
+        getViewModel().renderPagination();
+        getViewModel().renderInspectorEditors();
       });
 
       /**
@@ -811,9 +822,6 @@ define(['jquery',
        * @subscribe core/formElement/somePropertyChanged
        */
       getPublisherSubscriber().subscribe('core/formElement/somePropertyChanged', function(topic, args) {
-        var hasError, validationElement, validationResults;
-
-        validationResults = [];
         if ('renderables' !== args[0]) {
           if (!getFormEditorApp().isRootFormElementSelected() && 'label' === args[0]) {
             getViewModel().getStructure().setTreeNodeTitle();