@osimatic/helpers-js 1.0.72 → 1.0.75

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/date_time.js CHANGED
@@ -26,7 +26,7 @@ class DateTimeFormatter {
26
26
 
27
27
  static getDateSqlFormatter(timeZone) {
28
28
  if (this.dateSqlFormatter == null) {
29
- this.dateSqlFormatter = new Intl.DateTimeFormat('fr-FR', { year: 'numeric', month: '2-digit', day: '2-digit', timeZone: timeZone });
29
+ this.dateSqlFormatter = new Intl.DateTimeFormat('fr-CA', { year: 'numeric', month: '2-digit', day: '2-digit', timeZone: timeZone });
30
30
  }
31
31
 
32
32
  return this.dateSqlFormatter;
@@ -60,8 +60,6 @@ class DateTimeFormatter {
60
60
  class DateTime {
61
61
  static getSqlDate(jsDate, timeZone="Europe/Paris") {
62
62
  return DateTimeFormatter.getDateSqlFormatter(timeZone).format(jsDate).replace(/\//g,'-').replace(',','');
63
-
64
- //24/08/22 bad perfs
65
63
  /*let pad = function(num) { return ('00'+num).slice(-2) };
66
64
  // return jsDate.getUTCFullYear() + '-' + pad(jsDate.getUTCMonth() + 1) + '-' + pad(jsDate.getUTCDate());
67
65
  //return jsDate.getFullYear() + '-' + pad(jsDate.getMonth() + 1) + '-' + pad(jsDate.getDate());
@@ -88,22 +86,22 @@ class DateTime {
88
86
 
89
87
  static getDateDigitalDisplay(jsDate, locale="fr-FR", timeZone="Europe/Paris") {
90
88
  return DateTimeFormatter.getDateDigitalFormatter(locale, timeZone).format(jsDate);
91
- //return jsDate.toLocaleDateString(locale, {year: 'numeric', month: 'numeric', day: 'numeric', timeZone: timeZone}); //24/08/22 bad perfs
89
+ //return jsDate.toLocaleDateString(locale, {year: 'numeric', month: 'numeric', day: 'numeric', timeZone: timeZone});
92
90
  }
93
91
 
94
92
  static getDateTextDisplay(jsDate, locale="fr-FR", timeZone="Europe/Paris") {
95
93
  return DateTimeFormatter.getDateTextFormatter(locale, timeZone).format(jsDate);
96
- //return jsDate.toLocaleDateString(locale, {weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', timeZone: timeZone}); //24/08/22 bad perfs
94
+ //return jsDate.toLocaleDateString(locale, {weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', timeZone: timeZone});
97
95
  }
98
96
 
99
97
  static getTimeDisplay(jsDate, locale="fr-FR", timeZone="Europe/Paris") {
100
98
  return DateTimeFormatter.getTimeFormatter(locale, timeZone).format(jsDate);
101
- //return jsDate.toLocaleTimeString(locale, {hour: 'numeric', minute: 'numeric', timeZone: timeZone}); //24/08/22 bad perfs
99
+ //return jsDate.toLocaleTimeString(locale, {hour: 'numeric', minute: 'numeric', timeZone: timeZone});
102
100
  }
103
101
 
104
102
  static getTimeDigitalDisplay(jsDate, locale="fr-FR", timeZone="Europe/Paris") {
105
103
  return DateTimeFormatter.getTimeDigitalFormatter(locale, timeZone).format(jsDate);
106
- //return jsDate.toLocaleTimeString(locale, {hour: '2-digit', minute: '2-digit', second: '2-digit', timeZone: timeZone}); //24/08/22 bad perfs
104
+ //return jsDate.toLocaleTimeString(locale, {hour: '2-digit', minute: '2-digit', second: '2-digit', timeZone: timeZone});
107
105
  }
108
106
 
109
107
  static getTimeDisplayWithNbDays(jsDate, jsPreviousDate, locale="fr-FR", timeZone="Europe/Paris") {
@@ -119,7 +117,7 @@ class DateTime {
119
117
 
120
118
  static getDateTimeDigitalDisplay(jsDate, locale="fr-FR", timeZone="Europe/Paris") {
121
119
  return DateTimeFormatter.getDateTimeFormatter(locale, timeZone).format(jsDate);
122
- //return jsDate.toLocaleDateString(locale, {year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', timeZone: timeZone}); //24/08/22 bad perfs
120
+ //return jsDate.toLocaleDateString(locale, {year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', timeZone: timeZone});
123
121
  }
124
122
 
125
123
  static getYear(jsDate) {
package/form_helper.js CHANGED
@@ -22,6 +22,11 @@ class FormHelper {
22
22
  return form.find('select[name="'+selectName+'"] option:not([disabled])').length;
23
23
  }
24
24
 
25
+ static reset(form) {
26
+ form.find('[name]').each((idx, el) => $(el).val(''));
27
+ return form;
28
+ }
29
+
25
30
  static getFormData(form) {
26
31
  // var formElement = document.getElementById("myFormElement");
27
32
  return new FormData(form[0]);
@@ -200,11 +205,12 @@ class FormHelper {
200
205
  static displayFormErrors(form, btnSubmit, errors, errorWrapperDiv) {
201
206
  this.displayFormErrorsFromText(form, this.getFormErrorText(errors), errorWrapperDiv);
202
207
  if (btnSubmit != null) {
203
- if (btnSubmit.buttonLoader != null) {
204
- btnSubmit.buttonLoader('reset');
205
- } else {
206
- btnSubmit.attr('disabled', false).button('reset');
207
- }
208
+ FormHelper.buttonLoader(btnSubmit, 'reset');
209
+ //if (btnSubmit.buttonLoader != null) {
210
+ // btnSubmit.buttonLoader('reset');
211
+ //} else {
212
+ // btnSubmit.attr('disabled', false).button('reset');
213
+ //}
208
214
  }
209
215
  }
210
216
 
@@ -311,7 +317,7 @@ class EditValue {
311
317
 
312
318
  let button = $('<button type="submit" class="btn btn-success ms-2" data-loading-text="<i class=\'fa fa-circle-notch fa-spin\'></i>" style="vertical-align: baseline;"><i class="fas fa-check"></i></button>');
313
319
  button.click(function (e) {
314
- parent.find('button').buttonLoader('loading');
320
+ FormHelper.buttonLoader(parent.find('button'), 'loading');
315
321
  let newValue = parent.find('input').val();
316
322
  onSubmitCallback(newValue, parent,
317
323
  (isSuccess, valueFormatCallback) => {
@@ -24,7 +24,7 @@ class ImportFromCsv {
24
24
 
25
25
  formUpload.find('button[type="submit"]').click(function(event) {
26
26
  event.preventDefault();
27
- $(this).buttonLoader('loading');
27
+ FormHelper.buttonLoader($(this), 'loading');
28
28
  formUpload.find('div.errors').addClass('hide');
29
29
 
30
30
  let isFileParsed = false;
@@ -69,7 +69,7 @@ class ImportFromCsv {
69
69
  if (!isFileParsed) {
70
70
  formUpload.find('div.errors').html(errorMessageFileEmpty).removeClass('hide');
71
71
  }
72
- formUpload.find('button[type="submit"]').buttonLoader('reset');
72
+ FormHelper.buttonLoader(formUpload.find('button[type="submit"]'), 'reset');
73
73
  }
74
74
  });
75
75
  event.preventDefault();
@@ -77,7 +77,7 @@ class ImportFromCsv {
77
77
 
78
78
  formMatching.find('button[type="submit"]').click(function (event) {
79
79
  event.preventDefault();
80
- $(this).buttonLoader('loading');
80
+ FormHelper.buttonLoader($(this), 'loading');
81
81
  formMatching.find('div.errors').addClass('hide').empty();
82
82
  divResult.find('table tr').removeClass('danger');
83
83
 
@@ -86,7 +86,7 @@ class ImportFromCsv {
86
86
 
87
87
  if ($.isEmptyObject(tabLink)) {
88
88
  formMatching.find('div.errors').html(errorMessageImportSelectColumns).removeClass('hide');
89
- $(this).buttonLoader('reset');
89
+ FormHelper.buttonLoader($(this), 'reset');
90
90
  return false;
91
91
  }
92
92
 
@@ -103,7 +103,7 @@ class ImportFromCsv {
103
103
  else {
104
104
  formMatching.find('div.errors').html(ImportFromCsv.getErrorsHtmlOfImportData(json, divResult)).removeClass('hide');
105
105
  }
106
- formMatching.find('button[type="submit"]').buttonLoader('reset');
106
+ FormHelper.buttonLoader(formMatching.find('button[type="submit"]'), 'reset');
107
107
  }
108
108
  );
109
109
  });
package/media.js CHANGED
@@ -15,14 +15,13 @@ class AudioMedia {
15
15
  });
16
16
 
17
17
  div.find('.play_asynchronously_link').off('click').click(function () {
18
- if ($(this).buttonLoader('loading') != null) {
19
- let button = $(this).buttonLoader('loading');
20
- AudioMedia.playAudioUrl($(this).data('url'), () => button.buttonLoader('reset'));
21
- } else {
22
- let button = $(this).attr('disabled', true).button('loading');
23
- AudioMedia.playAudioUrl($(this).data('url'), () => button.attr('disabled', false).button('reset'));
24
- }
25
-
18
+ //if (FormHelper.buttonLoader($(this), 'loading') != null) {
19
+ let button = FormHelper.buttonLoader($(this), 'loading');
20
+ AudioMedia.playAudioUrl($(this).data('url'), () => FormHelper.buttonLoader(button, 'reset'));
21
+ //} else {
22
+ // let button = $(this).attr('disabled', true).button('loading');
23
+ // AudioMedia.playAudioUrl($(this).data('url'), () => button.attr('disabled', false).button('reset'));
24
+ //}
26
25
  return false;
27
26
  });
28
27
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.0.72",
3
+ "version": "1.0.75",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"