[TASK] FormEngineValidation on speed 43/51643/2
authorFrank Naegler <frank.naegler@typo3.org>
Sun, 12 Feb 2017 16:10:50 +0000 (17:10 +0100)
committerSusanne Moog <susanne.moog@typo3.org>
Mon, 13 Feb 2017 15:29:20 +0000 (16:29 +0100)
This patch removes the setTimeout hacks from FormEngineValidation.js.
Since the removal of ExtJS from FormEngine this hacky solution could be
removed and speed up the FormEngine validation process.

Resolves: #79765
Releases: master
Change-Id: I18f38a1641ea7916844cd464da3f31ad0fc22517
Reviewed-on: https://review.typo3.org/51643
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
typo3/sysext/backend/Resources/Private/TypeScript/FormEngineReview.ts
typo3/sysext/backend/Resources/Public/JavaScript/FormEngineReview.js
typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js

index 2dfbe36..284b4a6 100644 (file)
@@ -133,9 +133,11 @@ class FormEngineReview {
 
             // Bootstrap has no official API to update the content of a popover w/o destroying it
             let $popover: any = $toggleButton.data('bs.popover');
-            $popover.options.content = $list.wrapAll('<div>').parent().html();
-            $popover.setContent();
-            $popover.$tip.addClass($popover.options.placement);
+            if ($popover) {
+              $popover.options.content = $list.wrapAll('<div>').parent().html();
+              $popover.setContent();
+              $popover.$tip.addClass($popover.options.placement);
+            }
         } else {
             $toggleButton.addClass('hidden').popover('hide');
         }
index bc76129..8d7f6d3 100644 (file)
@@ -48,9 +48,11 @@ define(["require", "exports", "TYPO3/CMS/Backend/FormEngineValidation", "jquery"
                     $toggleButton.removeClass('hidden');
                     // Bootstrap has no official API to update the content of a popover w/o destroying it
                     var $popover = $toggleButton.data('bs.popover');
-                    $popover.options.content = $list_1.wrapAll('<div>').parent().html();
-                    $popover.setContent();
-                    $popover.$tip.addClass($popover.options.placement);
+                    if ($popover) {
+                        $popover.options.content = $list_1.wrapAll('<div>').parent().html();
+                        $popover.setContent();
+                        $popover.$tip.addClass($popover.options.placement);
+                    }
                 }
                 else {
                     $toggleButton.addClass('hidden').popover('hide');
index ff6497f..feba8af 100644 (file)
@@ -50,23 +50,16 @@ define(['jquery', 'TYPO3/CMS/Backend/FormEngine', 'moment'], function ($, FormEn
                FormEngineValidation.initializeInputFields().promise().done(function () {
                        // Bind to field changes
                        $(document).on('change', FormEngineValidation.rulesSelector, function() {
-                               // we need to wait, because the update of the select fields needs some time
-                               window.setTimeout(function() {
-                                       FormEngineValidation.validate();
-                               }, 500);
+                               FormEngineValidation.validate();
                                var $paletteField = $(this).closest('.t3js-formengine-palette-field');
                                $paletteField.addClass('has-change');
                        });
 
-                       // Bind to datepicker change event, but wait some milliseconds, because the init is not so fast
-                       window.setTimeout(function() {
-                               //noinspection JSUnusedLocalSymbols
-                               $(document).on('dp.change', FormEngineValidation.dateTimeSelector, function(event) {
-                                       FormEngineValidation.validate();
-                                       var $paletteField = $(this).closest('.t3js-formengine-palette-field');
-                                       $paletteField.addClass('has-change');
-                               });
-                       }, 500);
+                       $(document).on('dp.change', FormEngineValidation.dateTimeSelector, function(event) {
+                               FormEngineValidation.validate();
+                               var $paletteField = $(this).closest('.t3js-formengine-palette-field');
+                               $paletteField.addClass('has-change');
+                       });
                });
 
                var today = new Date();
@@ -75,6 +68,7 @@ define(['jquery', 'TYPO3/CMS/Backend/FormEngine', 'moment'], function ($, FormEn
                FormEngineValidation.lastTime = 0;
                FormEngineValidation.refDate = today;
                FormEngineValidation.USmode = 0;
+               FormEngineValidation.validate();
        };
 
        /**
@@ -1041,13 +1035,7 @@ define(['jquery', 'TYPO3/CMS/Backend/FormEngine', 'moment'], function ($, FormEn
        };
 
        FormEngineValidation.registerReady = function() {
-               $(function() {
-                       FormEngineValidation.initialize();
-                       // Start first validation after one second, because all fields are initial empty (typo3form.fieldSet)
-                       window.setTimeout(function() {
-                               FormEngineValidation.validate();
-                       }, 1000);
-               });
+               FormEngineValidation.initialize();
        };
 
        FormEngine.Validation = FormEngineValidation;