@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 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, exception) => console.log('request failure. Status: '+status+'Exception: '+exception),
114
+ error: (jqxhr, status, errorThrown) => HTTPRequest.logJqueryRequestFailure(jqxhr, status, errorThrown),
115
115
  });
116
116
  }
117
117
 
@@ -95,13 +95,13 @@ class ImportFromCsv {
95
95
 
96
96
  requestImportData(dataToImport,
97
97
  // fonction callback en cas d'erreur de formulaire
98
- function (jqxhr) {
99
- console.log(jqxhr.responseJSON);
100
- if (typeof jqxhr.responseJSON['import_list'] !== 'undefined') {
101
- formMatching.find('div.errors').html(jqxhr.responseJSON['import_list']).removeClass('hide');
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(jqxhr.responseJSON, divResult)).removeClass('hide');
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&param[]=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
- else if (typeof (value) != 'function' && name != '') {
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
- nbDecimal = (typeof nbDecimal != 'undefined'?nbDecimal:2);
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(this);
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(this);
52
+ }).format(number);
51
53
  }
52
54
 
53
- Number.prototype.padLeft2 = Number.prototype.padLeft2 || function(n) {
54
- return this > 9 ? "" + this : "0" + 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
- var tmp = Math.pow(10, precision);
60
- return Math.round(this*tmp) / tmp;
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
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.0.59",
3
+ "version": "1.0.62",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"