aw-front-helpers 2.5.30 → 2.5.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/classes/formControl.js +26 -10
- package/package.json +1 -1
package/classes/formControl.js
CHANGED
|
@@ -9,31 +9,31 @@ const defaultOptions = {
|
|
|
9
9
|
classIsError: 'is-error',
|
|
10
10
|
animateToFirstError: false,
|
|
11
11
|
i18n: {
|
|
12
|
-
required: window.Translator
|
|
12
|
+
required: window.Translator
|
|
13
13
|
? window.Translator.trans('form_errors.pattern')
|
|
14
14
|
: 'Ce champs est obligatoire',
|
|
15
|
-
same: window.Translator
|
|
15
|
+
same: window.Translator
|
|
16
16
|
? window.Translator.trans('form_errors.same')
|
|
17
17
|
: 'Les champs ne correspondent pas.',
|
|
18
|
-
email: window.Translator
|
|
18
|
+
email: window.Translator
|
|
19
19
|
? window.Translator.trans('form_errors.email')
|
|
20
20
|
: 'Merci de renseigner un email valide.',
|
|
21
|
-
empty: window.Translator
|
|
21
|
+
empty: window.Translator
|
|
22
22
|
? window.Translator.trans('form_errors.empty')
|
|
23
23
|
: 'Ce champs est obligatoire.',
|
|
24
|
-
checkbox: window.Translator
|
|
24
|
+
checkbox: window.Translator
|
|
25
25
|
? window.Translator.trans('form_errors.checkbox')
|
|
26
26
|
: 'Veuillez accepter les conditions.',
|
|
27
|
-
radio: window.Translator
|
|
27
|
+
radio: window.Translator
|
|
28
28
|
? window.Translator.trans('form_errors.radio')
|
|
29
29
|
: 'Veuillez sélectionner au moins un choix.',
|
|
30
|
-
minLength: window.Translator
|
|
30
|
+
minLength: window.Translator
|
|
31
31
|
? window.Translator.trans('form_errors.min_length')
|
|
32
32
|
: 'Ce champ doit contenir au minimum %length% caractères',
|
|
33
|
-
maxLength: window.Translator
|
|
33
|
+
maxLength: window.Translator
|
|
34
34
|
? window.Translator.trans('form_errors.max_length')
|
|
35
35
|
: 'Ce champ doit contenir au maximum %length% caractères',
|
|
36
|
-
pattern: window.Translator
|
|
36
|
+
pattern: window.Translator
|
|
37
37
|
? window.Translator.trans('form_errors.pattern')
|
|
38
38
|
: 'La donnée saisie ne respecte pas les règles énoncées.',
|
|
39
39
|
},
|
|
@@ -70,6 +70,8 @@ export default class FormControl {
|
|
|
70
70
|
...options,
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
+
this.disabledControls = [];
|
|
74
|
+
|
|
73
75
|
this._form.setAttribute('novalidate', 'novalidate');
|
|
74
76
|
this._formCreateBound();
|
|
75
77
|
this._formGrabDom();
|
|
@@ -104,6 +106,15 @@ export default class FormControl {
|
|
|
104
106
|
|
|
105
107
|
//________________________________________________________ public
|
|
106
108
|
// -
|
|
109
|
+
disableControlsIn(container) {
|
|
110
|
+
this.disabledControls.push( container );
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
enableControlsIn(container) {
|
|
114
|
+
const index = this.disabledControls.indexOf(container);
|
|
115
|
+
this.disabledControls.splice( index, 1 );
|
|
116
|
+
}
|
|
117
|
+
|
|
107
118
|
destroy() {
|
|
108
119
|
this._form.removeEventListener('submit', this._onFormSubmit);
|
|
109
120
|
this._domForm.inputs.forEach((input) => {
|
|
@@ -251,7 +262,12 @@ export default class FormControl {
|
|
|
251
262
|
const group = el.closest(this._options.selectorGroup);
|
|
252
263
|
if (group === null) return false;
|
|
253
264
|
if (el.getAttribute('disabled') !== null) return false;
|
|
254
|
-
|
|
265
|
+
if( this.disabledControls.length > 0 ) {
|
|
266
|
+
for( let i = 0; i < this.disabledControls.length; i++) {
|
|
267
|
+
const container = this.disabledControls[i];
|
|
268
|
+
if (container.contains(el)) return false;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
255
271
|
let invalid = false;
|
|
256
272
|
if (!testRequired(el, this._form)) {
|
|
257
273
|
invalid = true;
|