@osimatic/helpers-js 1.0.24 → 1.0.25

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
@@ -419,128 +419,4 @@ class SqlDateTime {
419
419
  }
420
420
 
421
421
 
422
- class InputPeriod {
423
-
424
- static addLinks(form) {
425
- let divParent = form.find('input[type="date"][data-add_period_select_links]').parent();
426
- if (divParent.hasClass('input-group')) {
427
- divParent = divParent.parent();
428
- }
429
- divParent.append(''
430
- +'<div class="select_period_links">'
431
- +'<a href="#" class="period_select_yesterday">Hier</a> - '
432
- +'<a href="#" class="period_select_current_week">Cette semaine</a> - '
433
- +'<a href="#" class="period_select_last_week">La semaine dernière</a> - '
434
- +'<a href="#" class="period_select_current_month">Ce mois-ci</a> - '
435
- +'<a href="#" class="period_select_last_month">Le mois dernier</a> - '
436
- +'<a href="#" class="period_select_current_year">Cette année</a>'
437
- +'</div>'
438
- );
439
- this.init(form);
440
- }
441
-
442
- static init(form) {
443
- let link;
444
- //console.log(form.find('a.period_select_current_week'));
445
-
446
- if ((link = form.find('a.period_select_today')).length) {
447
- link.click(function() { InputPeriod.selectToday($(this)); return false; });
448
- }
449
- if ((link = form.find('a.period_select_yesterday')).length) {
450
- link.click(function() { InputPeriod.selectPreviousDay($(this), 1); return false; });
451
- }
452
- if ((link = form.find('a.period_select_tomorrow')).length) {
453
- link.click(function() { InputPeriod.selectFollowingDay($(this), 1); return false; });
454
- }
455
- if ((link = form.find('a.period_select_current_week')).length) {
456
- link.click(function() { InputPeriod.selectCurrentWeek($(this)); return false; });
457
- }
458
- if ((link = form.find('a.period_select_last_week')).length) {
459
- link.click(function() { InputPeriod.selectPreviousWeek($(this), 1); return false; });
460
- }
461
- if ((link = form.find('a.period_select_current_month')).length) {
462
- link.click(function() { InputPeriod.selectCurrentMonth($(this)); return false; });
463
- }
464
- if ((link = form.find('a.period_select_last_month')).length) {
465
- link.click(function() { InputPeriod.selectPreviousMonth($(this), 1); return false; });
466
- }
467
- if ((link = form.find('a.period_select_current_year')).length) {
468
- link.click(function() { InputPeriod.selectCurrentYear($(this)); return false; });
469
- }
470
- if ((link = form.find('a.period_select_last_year')).length) {
471
- link.click(function() { InputPeriod.selectCurrentYear($(this), 1); return false; });
472
- }
473
- }
474
-
475
-
476
- static selectToday(link) {
477
- let date = new Date();
478
- this.selectPeriod(link, date, date);
479
- }
480
-
481
- static selectPreviousDay(lien, nbDays) {
482
- this.selectFollowingDay(lien, -nbDays);
483
- }
484
- static selectFollowingDay(lien, nbDays) {
485
- let date = new Date();
486
- date.setDate(date.getDate() + nbDays);
487
- this.selectPeriod(lien, date, date);
488
- }
489
-
490
- static selectCurrentWeek(lien) {
491
- let date = new Date();
492
- this.selectPeriod(lien, DateTime.getFirstDayOfWeek(date), DateTime.getLastDayOfWeek(date));
493
- }
494
- static selectPreviousWeek(lien, nbWeeks) {
495
- this.selectFollowingWeek(lien, -nbWeeks);
496
- }
497
- static selectFollowingWeek(lien, nbWeeks) {
498
- let date = new Date();
499
- date.setDate(date.getDate() + (7*nbWeeks));
500
- this.selectPeriod(lien, DateTime.getFirstDayOfWeek(date), DateTime.getLastDayOfWeek(date));
501
- }
502
-
503
- static selectCurrentMonth(lien) {
504
- let date = new Date();
505
- this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date));
506
- }
507
- static selectPreviousMonth(lien, nbMonths) {
508
- this.selectFollowingMonth(lien, -nbMonths);
509
- }
510
- static selectFollowingMonth(lien, nbMonths) {
511
- let date = new Date();
512
- date.setDate(1);
513
- date.setMonth(date.getMonth() + nbMonths);
514
- this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date));
515
- }
516
-
517
- static selectCurrentYear(lien) {
518
- this.selectFollowingYear(lien, 0);
519
- }
520
- static selectPreviousYear(lien, nbAnneesMoins) {
521
- this.selectFollowingYear(lien, -nbAnneesMoins);
522
- }
523
- static selectFollowingYear(lien, nbAnneesMoins) {
524
- let date = new Date();
525
- date.setFullYear(date.getFullYear() + nbAnneesMoins);
526
- this.selectPeriod(lien, DateTime.getFirstDayOfYear(date), DateTime.getLastDayOfYear(date));
527
- }
528
-
529
-
530
- static selectPeriod(link, startDate, endDate) {
531
- let inputPeriodStart = link.parent().parent().find('input[type="date"]').filter('[name="date_start"], [name="start_date"], [name="start_period"], [name="period_start_date"]');
532
- let inputPeriodEnd = link.parent().parent().find('input[type="date"]').filter('[name="date_end"], [name="end_date"], [name="end_period"], [name="period_end_date"]');
533
- if (inputPeriodStart.length == 0 || inputPeriodEnd.length == 0) {
534
- console.log('no period input found');
535
- return;
536
- }
537
-
538
- //console.log(startDate);
539
- //console.log(endDate);
540
- inputPeriodStart.val(DateTime.getSqlDate(startDate));
541
- inputPeriodEnd.val(DateTime.getSqlDate(endDate));
542
- }
543
-
544
- }
545
-
546
- module.exports = { DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, InputPeriod };
422
+ module.exports = { DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime };
package/file.js CHANGED
@@ -12,9 +12,9 @@ class File {
12
12
  }
13
13
  var type = contentType;
14
14
 
15
- var blob = new Blob([data], {
16
- type: type
17
- });
15
+ var blob = new Blob([data], {
16
+ type: type
17
+ });
18
18
 
19
19
  //console.log('disposition: '+disposition+' ; filename: '+filename+' ; type: '+type);
20
20
  //console.log('blob: %o', blob);
@@ -37,30 +37,30 @@ class File {
37
37
  a.click();
38
38
  }
39
39
 
40
- setTimeout(function () {
41
- URL.revokeObjectURL(downloadUrl);
42
- }, 100); // cleanup
40
+ setTimeout(function () {
41
+ URL.revokeObjectURL(downloadUrl);
42
+ }, 100); // cleanup
43
43
  }
44
44
  }
45
45
 
46
- static formatFileSize(fileSizeInBytes, fractionDigits, locale) {
47
- fractionDigits = (typeof fractionDigits != 'undefined' ? fractionDigits : 2);
48
- var i = -1;
49
- var byteUnits = ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
50
- if (fileSizeInBytes === 0) {
51
- return '0 ' + byteUnits[0];
52
- }
53
- do {
54
- fileSizeInBytes = fileSizeInBytes / 1024;
55
- i++;
56
- }
57
- while (fileSizeInBytes > 1024);
58
- //var size = Math.max(fileSizeInBytes, 0.1).toFixed(fractionDigits);
59
- var size = Math.max(fileSizeInBytes, 0.1);
60
- return (new Intl.NumberFormat(locale, {
61
- maximumFractionDigits: fractionDigits
62
- }).format(size)) + ' ' + byteUnits[i];
63
- }
46
+ static formatFileSize(fileSizeInBytes, fractionDigits, locale) {
47
+ fractionDigits = (typeof fractionDigits != 'undefined' ? fractionDigits : 2);
48
+ var i = -1;
49
+ var byteUnits = ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
50
+ if (fileSizeInBytes === 0) {
51
+ return '0 ' + byteUnits[0];
52
+ }
53
+ do {
54
+ fileSizeInBytes = fileSizeInBytes / 1024;
55
+ i++;
56
+ }
57
+ while (fileSizeInBytes > 1024);
58
+ //var size = Math.max(fileSizeInBytes, 0.1).toFixed(fractionDigits);
59
+ var size = Math.max(fileSizeInBytes, 0.1);
60
+ return (new Intl.NumberFormat(locale, {
61
+ maximumFractionDigits: fractionDigits
62
+ }).format(size)) + ' ' + byteUnits[i];
63
+ }
64
64
  }
65
65
 
66
66
  const CSV_FILE_EXTENSION = "csv";
package/form_date.js CHANGED
@@ -1,17 +1,214 @@
1
- const {Object} = require('./index');
1
+ // input period de type : Du <input type="date" name="start_date" /> au <input type="date" name="end_date" />
2
+ class InputPeriod {
2
3
 
4
+ static addLinks(form) {
5
+ let divParent = form.find('input[type="date"][data-add_period_select_links]').parent();
6
+ if (divParent.hasClass('input-group')) {
7
+ divParent = divParent.parent();
8
+ }
9
+ divParent.append(''
10
+ +'<div class="select_period_links">'
11
+ +'<a href="#" class="period_select_yesterday">Hier</a> - '
12
+ +'<a href="#" class="period_select_current_week">Cette semaine</a> - '
13
+ +'<a href="#" class="period_select_last_week">La semaine dernière</a> - '
14
+ +'<a href="#" class="period_select_current_month">Ce mois-ci</a> - '
15
+ +'<a href="#" class="period_select_last_month">Le mois dernier</a> - '
16
+ +'<a href="#" class="period_select_current_year">Cette année</a>'
17
+ +'</div>'
18
+ );
19
+ this.init(form);
20
+ }
21
+
22
+ static init(form) {
23
+ let link;
24
+ //console.log(form.find('a.period_select_current_week'));
25
+
26
+ if ((link = form.find('a.period_select_today')).length) {
27
+ link.click(function() { InputPeriod.selectToday($(this)); return false; });
28
+ }
29
+ if ((link = form.find('a.period_select_yesterday')).length) {
30
+ link.click(function() { InputPeriod.selectPreviousDay($(this), 1); return false; });
31
+ }
32
+ if ((link = form.find('a.period_select_tomorrow')).length) {
33
+ link.click(function() { InputPeriod.selectFollowingDay($(this), 1); return false; });
34
+ }
35
+ if ((link = form.find('a.period_select_current_week')).length) {
36
+ link.click(function() { InputPeriod.selectCurrentWeek($(this)); return false; });
37
+ }
38
+ if ((link = form.find('a.period_select_last_week')).length) {
39
+ link.click(function() { InputPeriod.selectPreviousWeek($(this), 1); return false; });
40
+ }
41
+ if ((link = form.find('a.period_select_current_month')).length) {
42
+ link.click(function() { InputPeriod.selectCurrentMonth($(this)); return false; });
43
+ }
44
+ if ((link = form.find('a.period_select_last_month')).length) {
45
+ link.click(function() { InputPeriod.selectPreviousMonth($(this), 1); return false; });
46
+ }
47
+ if ((link = form.find('a.period_select_current_year')).length) {
48
+ link.click(function() { InputPeriod.selectCurrentYear($(this)); return false; });
49
+ }
50
+ if ((link = form.find('a.period_select_last_year')).length) {
51
+ link.click(function() { InputPeriod.selectCurrentYear($(this), 1); return false; });
52
+ }
53
+ }
54
+
55
+
56
+ static selectToday(link) {
57
+ let date = new Date();
58
+ this.selectPeriod(link, date, date);
59
+ }
60
+
61
+ static selectPreviousDay(lien, nbDays) {
62
+ this.selectFollowingDay(lien, -nbDays);
63
+ }
64
+ static selectFollowingDay(lien, nbDays) {
65
+ let date = new Date();
66
+ date.setDate(date.getDate() + nbDays);
67
+ this.selectPeriod(lien, date, date);
68
+ }
69
+
70
+ static selectCurrentWeek(lien) {
71
+ let date = new Date();
72
+ this.selectPeriod(lien, DateTime.getFirstDayOfWeek(date), DateTime.getLastDayOfWeek(date));
73
+ }
74
+ static selectPreviousWeek(lien, nbWeeks) {
75
+ this.selectFollowingWeek(lien, -nbWeeks);
76
+ }
77
+ static selectFollowingWeek(lien, nbWeeks) {
78
+ let date = new Date();
79
+ date.setDate(date.getDate() + (7*nbWeeks));
80
+ this.selectPeriod(lien, DateTime.getFirstDayOfWeek(date), DateTime.getLastDayOfWeek(date));
81
+ }
82
+
83
+ static selectCurrentMonth(lien) {
84
+ let date = new Date();
85
+ this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date));
86
+ }
87
+ static selectPreviousMonth(lien, nbMonths) {
88
+ this.selectFollowingMonth(lien, -nbMonths);
89
+ }
90
+ static selectFollowingMonth(lien, nbMonths) {
91
+ let date = new Date();
92
+ date.setDate(1);
93
+ date.setMonth(date.getMonth() + nbMonths);
94
+ this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date));
95
+ }
96
+
97
+ static selectCurrentYear(lien) {
98
+ this.selectFollowingYear(lien, 0);
99
+ }
100
+ static selectPreviousYear(lien, nbAnneesMoins) {
101
+ this.selectFollowingYear(lien, -nbAnneesMoins);
102
+ }
103
+ static selectFollowingYear(lien, nbAnneesMoins) {
104
+ let date = new Date();
105
+ date.setFullYear(date.getFullYear() + nbAnneesMoins);
106
+ this.selectPeriod(lien, DateTime.getFirstDayOfYear(date), DateTime.getLastDayOfYear(date));
107
+ }
108
+
109
+
110
+ static selectPeriod(link, startDate, endDate) {
111
+ let inputPeriodStart = link.parent().parent().find('input[type="date"]').filter('[name="date_start"], [name="start_date"], [name="start_period"], [name="period_start_date"]');
112
+ let inputPeriodEnd = link.parent().parent().find('input[type="date"]').filter('[name="date_end"], [name="end_date"], [name="end_period"], [name="period_end_date"]');
113
+ if (inputPeriodStart.length == 0 || inputPeriodEnd.length == 0) {
114
+ console.log('no period input found');
115
+ return;
116
+ }
117
+
118
+ //console.log(startDate);
119
+ //console.log(endDate);
120
+ inputPeriodStart.val(DateTime.getSqlDate(startDate));
121
+ inputPeriodEnd.val(DateTime.getSqlDate(endDate));
122
+ }
123
+
124
+ }
125
+
126
+ // input period de type : <select class="period">Aujourd'hui / Ce mois-ci / etc. / Personnalisé</select>
3
127
  class FormDate {
4
128
  static initForm(form) {
129
+
130
+ function fillPeriodSelect(select) {
131
+ Object.entries(FormDate.getPeriodList()).forEach(([idx, tabListPeriode]) => {
132
+ let html = '<optgroup label="'+tabListPeriode['label']+'">';
133
+ Object.entries(tabListPeriode['list']).forEach(([key, label]) => {
134
+ html += '<option value="'+key+'">'+label+'</option>';
135
+ });
136
+ html += '</optgroup>';
137
+ select.append(html);
138
+ });
139
+ if (select.data('default_value')) {
140
+ select.val(select.data('default_value'));
141
+ }
142
+ }
143
+
144
+ function updatePeriodSelect(select) {
145
+ if (select.val() === 'perso') {
146
+ select.closest('.form-group').next().removeClass('hide');
147
+ }
148
+ else {
149
+ select.closest('.form-group').next().addClass('hide');
150
+ }
151
+ }
152
+
153
+ function updateForm(form) {
154
+ let periodSelect = form.find('select.periode');
155
+ if (periodSelect.length === 0) {
156
+ return;
157
+ }
158
+
159
+ updatePeriodSelect(periodSelect);
160
+
161
+ let comparedPeriodSelect = form.find('select.periodeCompare');
162
+ if (comparedPeriodSelect.length === 0) {
163
+ return;
164
+ }
165
+
166
+ let listValues = [];
167
+ let valueDefault = null;
168
+
169
+ comparedPeriodSelect.find('option').attr('disabled', false);
170
+
171
+ Object.entries(FormDate.getPeriodList()).forEach(([idx, tabListPeriode]) => {
172
+ if (idx != 0) {
173
+ let listKeyPeriode = Object.entries(tabListPeriode['list']).map(([key, value]) => key);
174
+ if (listKeyPeriode.indexOf(periodSelect.val()) !== -1) {
175
+ listValues = listKeyPeriode;
176
+ valueDefault = listKeyPeriode[1];
177
+ }
178
+ else {
179
+ comparedPeriodSelect.find('option[value="' + listKeyPeriode[0] + '"]').parent().children().attr('disabled', true);
180
+ }
181
+ }
182
+ });
183
+
184
+ if (periodSelect.val() === 'perso') {
185
+ valueDefault = 'perso';
186
+ }
187
+ else if (comparedPeriodSelect.val() !== 'perso' && listValues.indexOf(comparedPeriodSelect.val()) !== -1) {
188
+ valueDefault = comparedPeriodSelect.val();
189
+ }
190
+ comparedPeriodSelect.val(valueDefault);
191
+
192
+ updatePeriodSelect(comparedPeriodSelect);
193
+ }
194
+
5
195
  // ---------- Choix période (new) ----------
6
196
 
7
- // Formulaire de sélection de période
8
197
  if (form.find('select.periode').length > 0) {
198
+ fillPeriodSelect(form.find('select.periode'));
9
199
  form.find('select.periode').change(function() {
10
- FormDate.updatePeriodSelect($(this).closest('form'));
200
+ updateForm($(this).closest('form'));
11
201
  });
12
- FormDate.updatePeriodSelect($(this).closest('form'));
13
202
  }
14
203
 
204
+ if (form.find('select.periodeCompare').length > 0) {
205
+ fillPeriodSelect(form.find('select.periodeCompare'));
206
+ form.find('select.periodeCompare').change(function() {
207
+ updateForm($(this).closest('form'));
208
+ });
209
+ }
210
+
211
+ updateForm(form);
15
212
 
16
213
  // ---------- Choix période (old) ----------
17
214
 
@@ -51,7 +248,7 @@ class FormDate {
51
248
  ' <a href="#" class="lien_form_day_moins_8">J-8</a> - '+
52
249
  ' <a href="#" class="lien_form_last_month">Le mois dernier</a> - '+
53
250
  ' <a href="#" class="lien_form_month_moins_2">Mois M-2</a> - '+
54
- ' <a href="#" class="lien_form_last_year">L\'année dernière</a>'+
251
+ ' <a href="#" class="lien_form_last_year">Lannée dernière</a>'+
55
252
  '</p>'
56
253
  );
57
254
  }
@@ -141,58 +338,99 @@ class FormDate {
141
338
  //}
142
339
  }
143
340
 
144
- static updatePeriodSelect(form) {
145
- function updateSelect(select) {
146
- if (select.val() === 'perso') {
147
- select.parent().parent().next().removeClass('hide');
148
- }
149
- else {
150
- select.parent().parent().next().addClass('hide');
151
- }
152
- }
153
-
154
- let periodSelect = form.find('select.period');
155
- if (periodSelect.length === 0) {
156
- return;
157
- }
158
-
159
- updateSelect(periodSelect);
160
-
161
- let comparedPeriodSelect = form.find('select.compared_period');
162
- if (comparedPeriodSelect.length === 0) {
163
- return;
164
- }
165
-
166
- let listValues = [];
167
- let valueDefault = null;
168
-
169
- comparedPeriodSelect.find('option').attr('disabled', false);
170
-
171
- let listePeriodeCompare = typeof listePeriodeCompare != 'undefined' ? listePeriodeCompare : {};
172
- listePeriodeCompare.forEach(([idx, tabListPeriode]) => {
173
- if (idx != 0) {
174
- let listKeyPeriode = Object.entries(tabListPeriode['list']).map(([key, value]) => key);
175
- if (listKeyPeriode.indexOf(periodSelect.val()) !== -1) {
176
- listValues = listKeyPeriode;
177
- valueDefault = listKeyPeriode[1];
178
- }
179
- else {
180
- comparedPeriodSelect.find('option[value="' + listKeyPeriode[0] + '"]').parent().children().attr('disabled', true);
181
- }
182
- }
183
- });
184
-
185
- if (periodSelect.val() === 'perso') {
186
- valueDefault = 'perso';
187
- }
188
- else if (comparedPeriodSelect.val() !== 'perso' && listValues.indexOf(comparedPeriodSelect.val()) !== -1) {
189
- valueDefault = comparedPeriodSelect.val();
190
- }
191
- comparedPeriodSelect.val(valueDefault);
192
-
193
- updateSelect(comparedPeriodSelect);
341
+ static getPeriodList() {
342
+ return {
343
+ other: {label: 'Autre', list: {
344
+ perso: 'Personnalisé',
345
+ }},
346
+ '1d': {label: 'Un jour', list: { // 1 jour
347
+ 'ajd': 'Aujourd’hui',
348
+ 'hier': 'Hier',
349
+ 'jourMoins2': 'Avant-hier',
350
+ 'jourMoins3': 'J-3',
351
+ 'jourMoins7': 'J-7',
352
+ 'jourMoins8': 'J-8',
353
+ 'same_day_last_year': 'Même jour l’année dernière',
354
+ 'same_day_least_2_years': 'Même jour l’année A-2',
355
+ 'same_day_as_yesterday_last_year': 'Même jour qu’hier l’année dernière',
356
+ 'same_day_as_yesterday_least_2_years': 'Même jour qu’hier l’année A-2'
357
+ }},
358
+ '1w': {label: 'Une semaine', list: { // 1 semaine
359
+ 'curr_week': 'Cette semaine',
360
+ 'last_week': 'La semaine dernière',
361
+ 'weekMoins2': 'Semaine S-2',
362
+ 'weekMoins3': 'Semaine S-3',
363
+ 'weekMoins4': 'Semaine S-4',
364
+ }},
365
+ '7d': {label: '7 jours', list: { // 7 jours
366
+ 'last_7_days': 'Les 7 derniers jours',
367
+ 'last_7_days_before': 'Les 7 jours avant',
368
+ 'last_7_days_least_1_year': 'Les mêmes 7 jours l’année dernière',
369
+ 'last_7_days_least_2_years': 'Les mêmes 7 jours l’année A-2',
370
+ }},
371
+ '14d': {label: '14 jours', list: { // 14 jours
372
+ 'last_14_days': 'Les 14 derniers jours',
373
+ 'last_14_days_before': 'Les 14 jours avant',
374
+ 'last_14_days_least_1_year': 'Les mêmes 14 jours l’année dernière',
375
+ 'last_14_days_least_2_years': 'Les mêmes 14 jours l’année A-2',
376
+ }},
377
+ // 30 jours
378
+ '30d': {label: '30 jours', list: {
379
+ 'last_30_days': 'Les 30 derniers jours',
380
+ 'last_30_days_before': 'Les 30 jours avant',
381
+ 'last_30_days_least_1_year': 'Les mêmes 30 jours l’année dernière',
382
+ 'last_30_days_least_2_years': 'Les mêmes 30 jours l’année A-2',
383
+ }},
384
+ '60d': {label: '60 jours', list: { // 60 jours
385
+ 'last_60_days': 'Les 60 derniers jours',
386
+ 'last_60_days_before': 'Les 60 jours avant',
387
+ 'last_60_days_least_1_year': 'Les mêmes 60 jours l’année dernière',
388
+ 'last_60_days_least_2_years': 'Les mêmes 60 jours l’année A-2',
389
+ }},
390
+ '1m': {label: 'Un mois', list: { // 1 mois
391
+ 'curr_month': 'Ce mois-ci',
392
+ 'last_month': 'Le mois dernier',
393
+ 'monthMoins2': 'Mois M-2',
394
+ 'monthMoins3': 'Mois M-3',
395
+ 'monthMoins4': 'Mois M-4',
396
+ 'monthMoins5': 'Mois M-5',
397
+ 'monthMoins6': 'Mois M-6',
398
+ 'same_month_last_year': 'Même mois l’année dernière',
399
+ 'same_month_least_2_years': 'Même mois l’année A-2',
400
+ }},
401
+ '3m': {label: '3 mois', list: { // 3 mois
402
+ 'last_3_month': 'Les 3 derniers mois',
403
+ 'last_3_month_before': 'Les 3 mois avant',
404
+ 'last_3_month_least_1_year': 'Les mêmes 3 mois l’année dernière',
405
+ 'last_3_month_least_2_years': 'Les mêmes 3 mois l’année A-2',
406
+ }},
407
+ '6m': {label: '6 mois', list: { // 6 mois
408
+ 'last_6_month': 'Les 6 derniers mois',
409
+ 'last_6_month_before': 'Les 6 mois avant',
410
+ 'last_6_month_least_1_year': 'Les mêmes 6 mois l’année dernière',
411
+ 'last_6_month_least_2_years': 'Les mêmes 6 mois l’année A-2',
412
+ }},
413
+ '12m': {label: '12 mois', list: { // 12 mois
414
+ 'last_12_month': 'Les 12 derniers mois',
415
+ 'last_12_month_before': 'Les 12 mois avant',
416
+ 'last_12_month_least_1_year': 'Les mêmes 12 mois l’année dernière',
417
+ 'last_12_month_least_2_years': 'Les mêmes 12 mois l’année A-2',
418
+ }},
419
+ '24m': {label: '24 mois', list: { // 24 mois
420
+ 'last_24_month': 'Les 24 derniers mois',
421
+ 'last_24_month_before': 'Les 24 mois avant',
422
+ 'last_24_month_least_1_year': 'Les mêmes 24 mois l’année dernière',
423
+ 'last_24_month_least_2_years': 'Les mêmes 24 mois l’année A-2',
424
+ }},
425
+ '1y': {label: 'Une année', list: { // 1 année
426
+ 'curr_year': 'Cette année',
427
+ 'last_year': 'L’année dernière',
428
+ 'yearMoins2': 'Année A-2',
429
+ 'yearMoins3': 'Année A-3',
430
+ 'yearMoins4': 'Année A-4',
431
+ }},
432
+ };
194
433
  }
195
-
196
434
  static setTodaySelected(periodFormGroup) {
197
435
  let date = new Date();
198
436
  FormDate.setSelectedDate(periodFormGroup, date.getDate(), (date.getMonth() + 1), date.getFullYear());
@@ -241,7 +479,7 @@ class FormDate {
241
479
  }
242
480
  return new Date();
243
481
  }
244
-
482
+
245
483
  static setSelectedDate(periodFormGroup, day, month, year) {
246
484
  periodFormGroup.find('select.day').val(day);
247
485
  periodFormGroup.find('select.month').val(month);
@@ -250,24 +488,9 @@ class FormDate {
250
488
 
251
489
 
252
490
 
253
-
254
-
255
-
256
-
257
-
258
-
259
-
260
-
261
-
262
-
263
-
264
-
265
-
266
-
267
-
491
+ /*
268
492
  // deprecated
269
493
 
270
- /** @deprecated */
271
494
  static majSelectPeriode(select) {
272
495
  if (select.find(':selected').attr('value') === 'perso') {
273
496
  select.parent().parent().next().removeClass('hide');
@@ -277,7 +500,6 @@ class FormDate {
277
500
  }
278
501
  }
279
502
 
280
- /** @deprecated */
281
503
  static majSelectCompare() {
282
504
  if ($('form select#periodeCompare').length === 0) {
283
505
  return;
@@ -315,53 +537,38 @@ class FormDate {
315
537
  FormDate.majSelectPeriode(selectCompare);
316
538
  }
317
539
 
318
- /** @deprecated */
319
540
  static selectFormDateToday(lien) {
320
541
  let date = new Date();
321
542
  FormDate.selectFormDate(lien, date.getDate(), (date.getMonth() + 1), date.getFullYear());
322
543
  }
323
-
324
- /** @deprecated */
325
544
  static selectFormDateDayMoinsNb(lien, nbJoursMoins) {
326
545
  let date = new Date();
327
546
  date.setDate(date.getDate() - nbJoursMoins);
328
547
  FormDate.selectFormDate(lien, date.getDate(), (date.getMonth() + 1), date.getFullYear());
329
548
  }
330
-
331
- /** @deprecated */
332
549
  static selectFormDateCurrentMonth(lien) {
333
550
  let date = new Date();
334
551
  FormDate.selectFormDate(lien, -1, (date.getMonth() + 1), date.getFullYear());
335
552
  }
336
-
337
- /** @deprecated */
338
553
  static selectFormDateMonthMoinsNb(lien, nbMoisMoins) {
339
554
  let date = new Date();
340
555
  date.setDate(1);
341
556
  date.setMonth(date.getMonth() - nbMoisMoins);
342
557
  FormDate.selectFormDate(lien, -1, (date.getMonth() + 1), date.getFullYear());
343
558
  }
344
-
345
- /** @deprecated */
346
559
  static selectFormDateCurrentYear(lien) {
347
560
  let today = new Date();
348
561
  FormDate.selectFormDate(lien, -1, -1, today.getFullYear());
349
562
  }
350
-
351
- /** @deprecated */
352
563
  static selectFormDateYearMoinsNb(lien, nbAnneesMoins) {
353
564
  let today = new Date();
354
565
  FormDate.selectFormDate(lien, -1, -1, today.getFullYear() - nbAnneesMoins);
355
566
  }
356
-
357
- /** @deprecated */
358
567
  static selectFormDateAddDayFromSelectedDay(lien, nbDaysAdded) {
359
568
  let date = FormDate.getDateObjectSelected(lien);
360
569
  date.setDate(date.getDate() + nbDaysAdded);
361
570
  FormDate.selectFormDate(lien, date.getDate(), (date.getMonth() + 1), date.getFullYear());
362
571
  }
363
-
364
- /** @deprecated */
365
572
  static getDateObjectSelected(lien) {
366
573
  let selectorDay = '#' + (lien.parent().prev().prev().prev().prev().attr('id')) + ' option:selected';
367
574
  let selectorMonth = '#' + (lien.parent().prev().prev().prev().attr('id')) + ' option:selected';
@@ -371,8 +578,6 @@ class FormDate {
371
578
  }
372
579
  return new Date();
373
580
  }
374
-
375
- /** @deprecated */
376
581
  static selectFormDate(lien, day, month, year) {
377
582
  let selectorDay = '#' + (lien.parent().prev().prev().prev().prev().attr('id')) + ' option[value=' + day + ']';
378
583
  let selectorMonth = '#' + (lien.parent().prev().prev().prev().attr('id')) + ' option[value=' + month + ']';
@@ -381,7 +586,7 @@ class FormDate {
381
586
  if ($(selectorMonth).length > 0) $(selectorMonth).prop('selected', 'selected');
382
587
  if ($(selectorYear).length > 0) $(selectorYear).prop('selected', 'selected');
383
588
  }
384
-
589
+ */
385
590
  }
386
591
 
387
- module.exports = { FormDate };
592
+ module.exports = { FormDate, InputPeriod };
package/index.js CHANGED
@@ -11,7 +11,7 @@ const { HTTPRequest, Cookie, UrlAndQueryString } = require('./network');
11
11
  const { IBAN, BankCard } = require('./bank');
12
12
  const { AudioMedia, UserMedia } = require('./media');
13
13
  const { PersonName, Email, TelephoneNumber } = require('./contact_details');
14
- const { DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, InputPeriod } = require('./date_time');
14
+ const { DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime } = require('./date_time');
15
15
  const { Duration } = require('./duration');
16
16
  const { File, CSV, Img } = require('./file');
17
17
  const { FormHelper } = require('./form_helper');
@@ -19,7 +19,6 @@ const { Country, PostalAddress, Location } = require('./location');
19
19
  const { SocialNetwork } = require('./social_network');
20
20
  const { sleep, refresh } = require('./util');
21
21
  const { chr, ord, trim, empty } = require('./php.min');
22
- const { FormDate } = require('./form_date');
23
22
 
24
23
  // exports plugins "maison"
25
24
  const { DataTable } = require('./data_table');
@@ -27,6 +26,7 @@ const { Pagination, Navigation } = require('./paging');
27
26
  const { DetailsSubArray } = require('./details_sub_array');
28
27
  const { SelectAll } = require('./select_all');
29
28
  const { MultipleActionInTable } = require('./multiple_action_in_table');
29
+ const { FormDate, InputPeriod } = require('./form_date');
30
30
  const { ShoppingCart } = require('./shopping_cart');
31
31
  const { FlashMessage } = require('./flash_message');
32
32
  const { CountDown } = require('./count_down');
@@ -43,9 +43,9 @@ const { OpenStreetMap } = require('./open_street_map');
43
43
  // deprecated
44
44
 
45
45
  module.exports = {
46
- Array, Object, Number, String,
47
- HTTPRequest, Cookie, UrlAndQueryString, IBAN, BankCard, AudioMedia, UserMedia, PersonName, Email, TelephoneNumber, DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, InputPeriod, Duration, File, CSV, Img, FormHelper, Country, PostalAddress, Location, SocialNetwork, FormDate,
48
- DataTable, Pagination, Navigation, DetailsSubArray, SelectAll, MultipleActionInTable, ShoppingCart, FlashMessage, CountDown, ImportFromCsv, JwtToken, JwtSession, ListBox,
49
- sleep, refresh, chr, ord, trim, empty,
50
- GoogleCharts, GoogleRecaptcha, GoogleMap, OpenStreetMap
46
+ Array, Object, Number, String,
47
+ HTTPRequest, Cookie, UrlAndQueryString, IBAN, BankCard, AudioMedia, UserMedia, PersonName, Email, TelephoneNumber, DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, Duration, File, CSV, Img, FormHelper, Country, PostalAddress, Location, SocialNetwork,
48
+ DataTable, Pagination, Navigation, DetailsSubArray, SelectAll, MultipleActionInTable, FormDate, InputPeriod, ShoppingCart, FlashMessage, CountDown, ImportFromCsv, JwtToken, JwtSession, ListBox,
49
+ sleep, refresh, chr, ord, trim, empty,
50
+ GoogleCharts, GoogleRecaptcha, GoogleMap, OpenStreetMap
51
51
  };
package/media.js CHANGED
@@ -81,9 +81,9 @@ class UserMedia {
81
81
  }
82
82
 
83
83
  /** SystemPermissionDenied => (macOS) browser does not have permission to access cam/mic */
84
- /** UserPermissionDenied => user denied permission for site to access cam/mic */
85
- /** CouldNotStartVideoSource = > (Windows) browser does not have permission to access cam/mic OR camera is in use by another application or browser tab */
86
- /** Generic => all other errors */
84
+ /** UserPermissionDenied => user denied permission for site to access cam/mic */
85
+ /** CouldNotStartVideoSource = > (Windows) browser does not have permission to access cam/mic OR camera is in use by another application or browser tab */
86
+ /** Generic => all other errors */
87
87
 
88
88
  static requestMediaPermissions(constraints) {
89
89
  /*try {
@@ -95,7 +95,7 @@ class UserMedia {
95
95
  return new Promise((resolve, reject) => {
96
96
  const bowser = require('bowser');
97
97
  const browser = bowser.getParser(window.navigator.userAgent);
98
- const browserName = browser.getBrowserName();
98
+ const browserName = browser.getBrowserName();
99
99
 
100
100
  navigator.mediaDevices.getUserMedia(constraints !== 'undefined' ? constraints : { audio: true, video: true })
101
101
  .then((stream) => resolve(stream))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"