@osimatic/helpers-js 1.0.59 → 1.0.62
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/CHANGELOG +4 -1
- package/data_table.js +0 -4
- package/file.js +1 -1
- package/import_from_csv.js +5 -5
- package/network.js +6 -1
- package/number.js +19 -32
- package/package.json +1 -1
package/CHANGELOG
CHANGED
|
@@ -45,4 +45,7 @@ FormHelper.getFormErrorTextBis(...) -> FormHelper.getFormErrorText(...)
|
|
|
45
45
|
FormHelper.displayFormErrorsFromXhr(form, btnSubmit, xhr) -> FormHelper.displayFormErrors(form, btnSubmit, xhr.responseJSON)
|
|
46
46
|
|
|
47
47
|
1.0.35 :
|
|
48
|
-
ajout méthode HTTPRequest.init() (charge le polyfill de fetch)
|
|
48
|
+
ajout méthode HTTPRequest.init() (charge le polyfill de fetch)
|
|
49
|
+
|
|
50
|
+
1.0.61
|
|
51
|
+
DataTable.displayErrorFromXhr -> DataTable.displayError
|
package/data_table.js
CHANGED
|
@@ -268,10 +268,6 @@ class DataTable {
|
|
|
268
268
|
// }
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
static displayErrorFromXhr(div, jqxhr, defaultMessage) {
|
|
272
|
-
this.displayError(div, JSON.parse(jqxhr.responseJSON), defaultMessage);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
271
|
static displayError(div, data, defaultMessage) {
|
|
276
272
|
var error = null;
|
|
277
273
|
if (data != null) {
|
package/file.js
CHANGED
|
@@ -111,7 +111,7 @@ class Img {
|
|
|
111
111
|
// $(img).attr('src', urlCreator.createObjectURL(data));
|
|
112
112
|
Img.setBlobToImg($(img), data);
|
|
113
113
|
},
|
|
114
|
-
error: (jqxhr, status,
|
|
114
|
+
error: (jqxhr, status, errorThrown) => HTTPRequest.logJqueryRequestFailure(jqxhr, status, errorThrown),
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
|
package/import_from_csv.js
CHANGED
|
@@ -95,13 +95,13 @@ class ImportFromCsv {
|
|
|
95
95
|
|
|
96
96
|
requestImportData(dataToImport,
|
|
97
97
|
// fonction callback en cas d'erreur de formulaire
|
|
98
|
-
|
|
99
|
-
console.log(
|
|
100
|
-
if (typeof
|
|
101
|
-
formMatching.find('div.errors').html(
|
|
98
|
+
(json) => {
|
|
99
|
+
console.log(json);
|
|
100
|
+
if (typeof json['import_list'] !== 'undefined') {
|
|
101
|
+
formMatching.find('div.errors').html(json['import_list']).removeClass('hide');
|
|
102
102
|
}
|
|
103
103
|
else {
|
|
104
|
-
formMatching.find('div.errors').html(ImportFromCsv.getErrorsHtmlOfImportData(
|
|
104
|
+
formMatching.find('div.errors').html(ImportFromCsv.getErrorsHtmlOfImportData(json, divResult)).removeClass('hide');
|
|
105
105
|
}
|
|
106
106
|
formMatching.find('button[type="submit"]').buttonLoader('reset');
|
|
107
107
|
}
|
package/network.js
CHANGED
|
@@ -620,13 +620,18 @@ class UrlAndQueryString {
|
|
|
620
620
|
if (typeof (object) == 'object') {
|
|
621
621
|
for (var name in object) {
|
|
622
622
|
value = object[name];
|
|
623
|
+
// 06/06/2022 : ajout de ce if pour éviter bug sur fonction HTTPRequest.formatQueryString
|
|
624
|
+
if (typeof (value) == 'undefined') {
|
|
625
|
+
continue;
|
|
626
|
+
}
|
|
623
627
|
// 14/01/2020 : les tableaux avec param[0], param[1] en query string fonctionne pas, il faut mettre param[]=x¶m[]=y
|
|
624
628
|
//name = p == '' ? name : '['+name+']';
|
|
625
629
|
name = p == '' ? name : '[]';
|
|
626
630
|
if (typeof (value) == 'object') {
|
|
627
631
|
buildStringFromParam(value, p + name);
|
|
628
632
|
}
|
|
629
|
-
|
|
633
|
+
// 06/06/2022 : ajout null !== value pour éviter bug sur fonction HTTPRequest.formatQueryString
|
|
634
|
+
else if (null !== value && typeof (value) != 'function' && name != '') {
|
|
630
635
|
// 27/01/2020 : correction bug boolean affiché en string true/false
|
|
631
636
|
if (typeof (value) == 'boolean') {
|
|
632
637
|
value = (value ? 1 : 0);
|
package/number.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
Number.prototype.format = Number.prototype.format || function(nbDecimal, locale) {
|
|
3
|
-
|
|
4
|
-
return new Intl.NumberFormat(locale, {
|
|
5
|
-
minimumFractionDigits: nbDecimal,
|
|
6
|
-
maximumFractionDigits: nbDecimal
|
|
7
|
-
}).format(this);
|
|
3
|
+
return Number.format(this, nbDecimal, locale);
|
|
8
4
|
}
|
|
9
5
|
|
|
10
6
|
if (!Number.format) {
|
|
@@ -32,32 +28,44 @@ Number.prototype.formatForDisplay = Number.prototype.formatForDisplay || functio
|
|
|
32
28
|
};
|
|
33
29
|
|
|
34
30
|
Number.prototype.formatCurrency = Number.prototype.formatCurrency || function(currency, nbDecimal, locale) {
|
|
31
|
+
return Number.formatCurrency(this, currency, nbDecimal, locale);
|
|
32
|
+
}
|
|
33
|
+
Number.formatCurrency = Number.formatCurrency || function(number, currency, nbDecimal, locale) {
|
|
35
34
|
nbDecimal = (typeof nbDecimal != 'undefined'?nbDecimal:2);
|
|
36
35
|
return new Intl.NumberFormat(locale, {
|
|
37
36
|
style: 'currency',
|
|
38
37
|
currency: currency,
|
|
39
38
|
minimumFractionDigits: nbDecimal,
|
|
40
39
|
maximumFractionDigits: nbDecimal
|
|
41
|
-
}).format(
|
|
40
|
+
}).format(number);
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
Number.prototype.formatPercent = Number.prototype.formatPercent || function(nbDecimal, locale) {
|
|
44
|
+
return Number.formatPercent(this, nbDecimal, locale);
|
|
45
|
+
}
|
|
46
|
+
Number.formatPercent = Number.formatPercent || function(number, nbDecimal, locale) {
|
|
45
47
|
nbDecimal = (typeof nbDecimal != 'undefined'?nbDecimal:2);
|
|
46
48
|
return new Intl.NumberFormat(locale, {
|
|
47
49
|
style: 'percent',
|
|
48
50
|
minimumFractionDigits: nbDecimal,
|
|
49
51
|
maximumFractionDigits: nbDecimal
|
|
50
|
-
}).format(
|
|
52
|
+
}).format(number);
|
|
51
53
|
}
|
|
52
54
|
|
|
53
|
-
Number.prototype.padLeft2 = Number.prototype.padLeft2 || function(
|
|
54
|
-
return this
|
|
55
|
+
Number.prototype.padLeft2 = Number.prototype.padLeft2 || function() {
|
|
56
|
+
return Number.padLeft2(this);
|
|
57
|
+
}
|
|
58
|
+
Number.padLeft2 = Number.padLeft2 || function(n) {
|
|
59
|
+
return n > 9 ? "" + n : "0" + n;
|
|
55
60
|
}
|
|
56
61
|
|
|
57
62
|
Number.prototype.roundDecimal = Number.prototype.roundDecimal || function(precision) {
|
|
63
|
+
return Number.roundDecimal(this, precision);
|
|
64
|
+
}
|
|
65
|
+
Number.roundDecimal = Number.roundDecimal || function(number, precision) {
|
|
58
66
|
precision = precision || 2;
|
|
59
|
-
|
|
60
|
-
return Math.round(
|
|
67
|
+
let tmp = Math.pow(10, precision);
|
|
68
|
+
return Math.round(number*tmp) / tmp;
|
|
61
69
|
}
|
|
62
70
|
|
|
63
71
|
if (!Number.random) {
|
|
@@ -65,24 +73,3 @@ if (!Number.random) {
|
|
|
65
73
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
66
74
|
};
|
|
67
75
|
}
|
|
68
|
-
|
|
69
|
-
/** @deprecated */
|
|
70
|
-
Number.prototype.formatAsString = function(locale, minimumFractionDigits) {
|
|
71
|
-
minimumFractionDigits = (typeof minimumFractionDigits != 'undefined'?minimumFractionDigits:0);
|
|
72
|
-
return new Intl.NumberFormat(locale, {minimumFractionDigits: minimumFractionDigits}).format(this);
|
|
73
|
-
};
|
|
74
|
-
/** @deprecated */
|
|
75
|
-
Number.prototype.formatAsCurrency = function(locale, currency, nbFractionDigits) {
|
|
76
|
-
nbFractionDigits = (typeof nbFractionDigits != 'undefined'?nbFractionDigits:2);
|
|
77
|
-
return new Intl.NumberFormat(locale, {
|
|
78
|
-
style: 'currency',
|
|
79
|
-
currency: 'EUR',
|
|
80
|
-
minimumFractionDigits: nbFractionDigits,
|
|
81
|
-
maximumFractionDigits: nbFractionDigits
|
|
82
|
-
}).format(this);
|
|
83
|
-
};
|
|
84
|
-
/** @deprecated */
|
|
85
|
-
Number.prototype.formatAsPercent = function(locale, minimumFractionDigits) {
|
|
86
|
-
minimumFractionDigits = (typeof minimumFractionDigits != 'undefined'?minimumFractionDigits:0);
|
|
87
|
-
return new Intl.NumberFormat(locale, {style: 'percent', minimumFractionDigits:minimumFractionDigits}).format(this);
|
|
88
|
-
};
|