[BUGFIX] Avoid warning dialog when closing records with dateTime fields 40/52140/3
authorFrank Naegler <frank.naegler@typo3.org>
Fri, 24 Mar 2017 11:12:43 +0000 (12:12 +0100)
committerAndreas Fernandez <typo3@scripting-base.de>
Sat, 25 Mar 2017 15:58:13 +0000 (16:58 +0100)
In case a record contains a DateTimePicker field, the validation is triggered to early
and mark each DateTime field as changed. This patch fix this wrong behavior.

Resolves: #80008
Releases: master
Change-Id: I9a2d81c6cf5b544d5a6f08f43fd2fea86b415d6a
Reviewed-on: https://review.typo3.org/52140
Tested-by: TYPO3com <no-reply@typo3.com>
Tested-by: Joerg Kummer <service@enobe.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/backend/Resources/Public/JavaScript/DateTimePicker.js
typo3/sysext/backend/Resources/Public/JavaScript/FormEngine.js
typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js

index 6fbb0e0..1a053b1 100644 (file)
@@ -173,6 +173,7 @@ define(['jquery'], function($) {
                                                }
                                                $hiddenField.val(value);
                                        }
+                                       $(document).trigger('formengine.dp.change', [$(this)]);
                                });
                        });
                }
index e1e246d..a4c9c35 100644 (file)
@@ -729,6 +729,9 @@ define(['jquery',
                                $input.val($(this).attr('data-original-language-value')).trigger('change');
                                $input.data('last-l10n-state', $(this).val());
                        }
+               }).on('formengine.dp.change', function(event, $field) {
+                       FormEngine.Validation.validate();
+                       FormEngine.Validation.markFieldAsChanged($field);
                });
        };
 
index feba8af..ac9f619 100644 (file)
@@ -21,14 +21,13 @@ define(['jquery', 'TYPO3/CMS/Backend/FormEngine', 'moment'], function ($, FormEn
        /**
         * The main FormEngineValidation object
         *
-        * @type {{rulesSelector: string, inputSelector: string, markerSelector: string, dateTimeSelector: string, groupFieldHiddenElement: string, relatedFieldSelector: string, errorClass: string, lastYear: number, lastDate: number, lastTime: number, refDate: Date, USmode: number, passwordDummy: string}}
+        * @type {{rulesSelector: string, inputSelector: string, markerSelector: string, groupFieldHiddenElement: string, relatedFieldSelector: string, errorClass: string, lastYear: number, lastDate: number, lastTime: number, refDate: Date, USmode: number, passwordDummy: string}}
         * @exports TYPO3/CMS/Backend/FormEngineValidation
         */
        var FormEngineValidation = {
                rulesSelector: '[data-formengine-validation-rules]',
                inputSelector: '[data-formengine-input-params]',
                markerSelector: '.t3js-formengine-validation-marker',
-               dateTimeSelector: '.t3js-datetimepicker',
                groupFieldHiddenElement: '.t3js-formengine-field-group input[type=hidden]',
                relatedFieldSelector: '[data-relatedfieldname]',
                errorClass: 'has-error',
@@ -51,14 +50,7 @@ define(['jquery', 'TYPO3/CMS/Backend/FormEngine', 'moment'], function ($, FormEn
                        // Bind to field changes
                        $(document).on('change', FormEngineValidation.rulesSelector, function() {
                                FormEngineValidation.validate();
-                               var $paletteField = $(this).closest('.t3js-formengine-palette-field');
-                               $paletteField.addClass('has-change');
-                       });
-
-                       $(document).on('dp.change', FormEngineValidation.dateTimeSelector, function(event) {
-                               FormEngineValidation.validate();
-                               var $paletteField = $(this).closest('.t3js-formengine-palette-field');
-                               $paletteField.addClass('has-change');
+                               FormEngineValidation.markFieldAsChanged($(this));
                        });
                });
 
@@ -540,6 +532,16 @@ define(['jquery', 'TYPO3/CMS/Backend/FormEngine', 'moment'], function ($, FormEn
        };
 
        /**
+        * Helper function to mark a field as changed.
+        *
+        * @param {Object} $field
+        */
+       FormEngineValidation.markFieldAsChanged = function($field) {
+               var $paletteField = $field.closest('.t3js-formengine-palette-field');
+               $paletteField.addClass('has-change');
+       };
+
+       /**
         * Helper function to get clean trimmed array from comma list
         *
         * @param {String} delimiter