@osimatic/helpers-js 1.1.56 → 1.1.58
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/flash_message.js +10 -7
- package/form_helper.js +16 -11
- package/location.js +3 -7
- package/package.json +1 -1
package/flash_message.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
class FlashMessage {
|
|
2
|
-
static displaySuccess(message, reload, modal=null) {
|
|
3
|
-
this.display('success', message, reload, modal);
|
|
2
|
+
static displaySuccess(message, reload=false, modal=null, onMessageHidden=null) {
|
|
3
|
+
this.display('success', message, reload, modal, onMessageHidden);
|
|
4
4
|
}
|
|
5
|
-
static displayWarning(message, modal=null) {
|
|
6
|
-
this.display('warning', message, false, modal);
|
|
5
|
+
static displayWarning(message, modal=null, onMessageHidden=null) {
|
|
6
|
+
this.display('warning', message, false, modal, onMessageHidden);
|
|
7
7
|
}
|
|
8
|
-
static displayError(message, modal=null) {
|
|
9
|
-
this.display('danger', message, false, modal);
|
|
8
|
+
static displayError(message, modal=null, onMessageHidden=null) {
|
|
9
|
+
this.display('danger', message, false, modal, onMessageHidden);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
static display(type, message, reload, modal=null) {
|
|
12
|
+
static display(type, message, reload=false, modal=null, onMessageHidden=null) {
|
|
13
13
|
if (null !== modal) {
|
|
14
14
|
modal.modal('hide');
|
|
15
15
|
}
|
|
@@ -22,6 +22,9 @@ class FlashMessage {
|
|
|
22
22
|
|
|
23
23
|
setTimeout(function () {
|
|
24
24
|
$('div.snackbar').remove();
|
|
25
|
+
if (typeof onMessageHidden == 'function') {
|
|
26
|
+
onMessageHidden();
|
|
27
|
+
}
|
|
25
28
|
}, 6000);
|
|
26
29
|
|
|
27
30
|
if (true === reload) {
|
package/form_helper.js
CHANGED
|
@@ -234,7 +234,7 @@ class FormHelper {
|
|
|
234
234
|
// Messages erreur
|
|
235
235
|
// ------------------------------------------------------------
|
|
236
236
|
|
|
237
|
-
static extractErrorKeyOfJson(json, onlyIfUniqueError) {
|
|
237
|
+
static extractErrorKeyOfJson(json, onlyIfUniqueError=false) {
|
|
238
238
|
if (typeof json == 'undefined' || json == null) {
|
|
239
239
|
return null;
|
|
240
240
|
}
|
|
@@ -243,7 +243,7 @@ class FormHelper {
|
|
|
243
243
|
return json.error;
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
-
if (
|
|
246
|
+
if (onlyIfUniqueError && !json.length || json.length > 1) {
|
|
247
247
|
return null;
|
|
248
248
|
}
|
|
249
249
|
|
|
@@ -267,18 +267,23 @@ class FormHelper {
|
|
|
267
267
|
let errorLabels = [];
|
|
268
268
|
for (let property in errors) {
|
|
269
269
|
// console.log(property);
|
|
270
|
-
if (typeof errors[property]
|
|
271
|
-
|
|
272
|
-
errorLabels.push(errors[property]);
|
|
273
|
-
} else {
|
|
274
|
-
errorLabels.push(errors[property]['error_description']);
|
|
275
|
-
}
|
|
270
|
+
if (typeof errors[property] == 'function') {
|
|
271
|
+
continue;
|
|
276
272
|
}
|
|
273
|
+
if (typeof errors[property]['error_description'] !== 'undefined') {
|
|
274
|
+
errorLabels.push(errors[property]['error_description']);
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
if (Array.isArray(errors[property]) && errors[property].length === 2) {
|
|
278
|
+
errorLabels.push(errors[property][1]);
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
errorLabels.push(errors[property]);
|
|
277
282
|
}
|
|
278
283
|
return errorLabels.removeEmptyValues().map(errorLabel => '<span>' + errorLabel + '</span>').join('<br/>');
|
|
279
284
|
}
|
|
280
285
|
|
|
281
|
-
static displayFormErrors(form, btnSubmit, errors, errorWrapperDiv) {
|
|
286
|
+
static displayFormErrors(form, btnSubmit, errors, errorWrapperDiv=null) {
|
|
282
287
|
this.displayFormErrorsFromText(form, this.getFormErrorText(errors), errorWrapperDiv);
|
|
283
288
|
if (btnSubmit != null) {
|
|
284
289
|
FormHelper.buttonLoader(btnSubmit, 'reset');
|
|
@@ -290,10 +295,10 @@ class FormHelper {
|
|
|
290
295
|
}
|
|
291
296
|
}
|
|
292
297
|
|
|
293
|
-
static displayFormErrorsFromText(form, errorLabels, errorWrapperDiv) {
|
|
298
|
+
static displayFormErrorsFromText(form, errorLabels, errorWrapperDiv=null) {
|
|
294
299
|
let errorDiv = '<div class="alert alert-danger form_errors">'+errorLabels+'</div>';
|
|
295
300
|
|
|
296
|
-
if (
|
|
301
|
+
if (null != errorWrapperDiv) {
|
|
297
302
|
errorWrapperDiv.append(errorDiv);
|
|
298
303
|
return;
|
|
299
304
|
}
|
package/location.js
CHANGED
|
@@ -7,11 +7,11 @@ class Country {
|
|
|
7
7
|
return '<span><img src="'+Country.getFlagPath(countryCode)+'" alt="" title="'+Country.getCountryName(countryCode)+'" class="flag" /></span>'
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
static fillCountrySelect(select, defaultValue) {
|
|
10
|
+
static fillCountrySelect(select, defaultValue=null) {
|
|
11
11
|
if (select.children().length === 0) {
|
|
12
12
|
Object.entries(Country.getCountries()).forEach(([countryCode, countryName]) => select.append('<option value="' + countryCode + '">' + countryName + '</option>'));
|
|
13
13
|
}
|
|
14
|
-
if (
|
|
14
|
+
if (null != defaultValue) {
|
|
15
15
|
select.val(defaultValue);
|
|
16
16
|
}
|
|
17
17
|
if (typeof select.selectpicker != 'undefined') {
|
|
@@ -309,11 +309,7 @@ class PostalAddress {
|
|
|
309
309
|
});
|
|
310
310
|
}
|
|
311
311
|
|
|
312
|
-
static format(addressData, separator) {
|
|
313
|
-
if (typeof separator == 'undefined') {
|
|
314
|
-
separator = '<br/>';
|
|
315
|
-
}
|
|
316
|
-
|
|
312
|
+
static format(addressData, separator='<br/>') {
|
|
317
313
|
function empty(value) {
|
|
318
314
|
return typeof value == 'undefined' || value == null || value === '';
|
|
319
315
|
}
|