@osimatic/helpers-js 1.5.2 → 1.5.3
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/count_down.js +46 -48
- package/date_time.js +0 -1
- package/details_sub_array.js +22 -11
- package/flash_message.js +10 -6
- package/form_date.js +144 -153
- package/import_from_csv.js +34 -5
- package/multi_files_input.js +2 -1
- package/multiple_action_in_table.js +11 -7
- package/package.json +1 -1
- package/tests/count_down.test.js +131 -352
- package/tests/details_sub_array.test.js +11 -28
- package/tests/flash_message.test.js +21 -153
- package/tests/form_date.test.js +287 -961
- package/tests/import_from_csv.test.js +53 -11
- package/tests/multi_files_input.test.js +14 -16
- package/tests/multiple_action_in_table.test.js +0 -9
- package/tests/open_street_map.test.js +15 -23
package/form_date.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
const { DateTime } = require('./date_time');
|
|
2
|
+
|
|
3
|
+
// input period de type : Du <input type="date" name="start_date" /> au <input type="date" name="end_date" />
|
|
2
4
|
class InputPeriod {
|
|
3
5
|
|
|
4
6
|
static addLinks(form) {
|
|
5
|
-
let divParent = form.
|
|
6
|
-
if (divParent.
|
|
7
|
-
divParent = divParent.
|
|
7
|
+
let divParent = form.querySelector('input[type="date"][data-add_period_select_links]').parentElement;
|
|
8
|
+
if (divParent.classList.contains('input-group')) {
|
|
9
|
+
divParent = divParent.parentElement;
|
|
8
10
|
}
|
|
9
|
-
divParent.
|
|
11
|
+
divParent.insertAdjacentHTML('beforeend', ''
|
|
10
12
|
+'<div class="select_period_links">'
|
|
11
13
|
+'<a href="#" class="period_select_yesterday">Hier</a> - '
|
|
12
14
|
+'<a href="#" class="period_select_current_week">Cette semaine</a> - '
|
|
@@ -20,35 +22,43 @@ class InputPeriod {
|
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
static init(form) {
|
|
23
|
-
|
|
24
|
-
//console.log(form.find('a.period_select_current_week'));
|
|
25
|
+
//console.log(form.querySelector('a.period_select_current_week'));
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
const linkToday = form.querySelector('a.period_select_today');
|
|
28
|
+
if (linkToday) {
|
|
29
|
+
linkToday.addEventListener('click', (e) => { e.preventDefault(); InputPeriod.selectToday(linkToday); });
|
|
28
30
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
const linkYesterday = form.querySelector('a.period_select_yesterday');
|
|
32
|
+
if (linkYesterday) {
|
|
33
|
+
linkYesterday.addEventListener('click', (e) => { e.preventDefault(); InputPeriod.selectPreviousDay(linkYesterday, 1); });
|
|
31
34
|
}
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
const linkTomorrow = form.querySelector('a.period_select_tomorrow');
|
|
36
|
+
if (linkTomorrow) {
|
|
37
|
+
linkTomorrow.addEventListener('click', (e) => { e.preventDefault(); InputPeriod.selectFollowingDay(linkTomorrow, 1); });
|
|
34
38
|
}
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
const linkCurrentWeek = form.querySelector('a.period_select_current_week');
|
|
40
|
+
if (linkCurrentWeek) {
|
|
41
|
+
linkCurrentWeek.addEventListener('click', (e) => { e.preventDefault(); InputPeriod.selectCurrentWeek(linkCurrentWeek); });
|
|
37
42
|
}
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
const linkLastWeek = form.querySelector('a.period_select_last_week');
|
|
44
|
+
if (linkLastWeek) {
|
|
45
|
+
linkLastWeek.addEventListener('click', (e) => { e.preventDefault(); InputPeriod.selectPreviousWeek(linkLastWeek, 1); });
|
|
40
46
|
}
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
const linkCurrentMonth = form.querySelector('a.period_select_current_month');
|
|
48
|
+
if (linkCurrentMonth) {
|
|
49
|
+
linkCurrentMonth.addEventListener('click', (e) => { e.preventDefault(); InputPeriod.selectCurrentMonth(linkCurrentMonth); });
|
|
43
50
|
}
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
const linkLastMonth = form.querySelector('a.period_select_last_month');
|
|
52
|
+
if (linkLastMonth) {
|
|
53
|
+
linkLastMonth.addEventListener('click', (e) => { e.preventDefault(); InputPeriod.selectPreviousMonth(linkLastMonth, 1); });
|
|
46
54
|
}
|
|
47
|
-
|
|
48
|
-
|
|
55
|
+
const linkCurrentYear = form.querySelector('a.period_select_current_year');
|
|
56
|
+
if (linkCurrentYear) {
|
|
57
|
+
linkCurrentYear.addEventListener('click', (e) => { e.preventDefault(); InputPeriod.selectCurrentYear(linkCurrentYear); });
|
|
49
58
|
}
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
const linkLastYear = form.querySelector('a.period_select_last_year');
|
|
60
|
+
if (linkLastYear) {
|
|
61
|
+
linkLastYear.addEventListener('click', (e) => { e.preventDefault(); InputPeriod.selectPreviousYear(linkLastYear, 1); });
|
|
52
62
|
}
|
|
53
63
|
}
|
|
54
64
|
|
|
@@ -108,15 +118,16 @@ class InputPeriod {
|
|
|
108
118
|
|
|
109
119
|
|
|
110
120
|
static selectPeriod(link, startDate, endDate) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
121
|
+
const container = link.parentElement.parentElement;
|
|
122
|
+
const inputPeriodStart = container.querySelector('input[type="date"][name="date_start"], input[type="date"][name="start_date"], input[type="date"][name="start_period"], input[type="date"][name="period_start_date"]');
|
|
123
|
+
const inputPeriodEnd = container.querySelector('input[type="date"][name="date_end"], input[type="date"][name="end_date"], input[type="date"][name="end_period"], input[type="date"][name="period_end_date"]');
|
|
124
|
+
if (!inputPeriodStart || !inputPeriodEnd) {
|
|
114
125
|
console.log('no period input found');
|
|
115
126
|
return;
|
|
116
127
|
}
|
|
117
128
|
|
|
118
|
-
inputPeriodStart.
|
|
119
|
-
inputPeriodEnd.
|
|
129
|
+
inputPeriodStart.value = DateTime.getDateForInputDate(startDate);
|
|
130
|
+
inputPeriodEnd.value = DateTime.getDateForInputDate(endDate);
|
|
120
131
|
}
|
|
121
132
|
|
|
122
133
|
}
|
|
@@ -127,19 +138,19 @@ class FormDate {
|
|
|
127
138
|
static fillYearSelect(select, nbYearsBefore=5, nbYearsAfter=0) {
|
|
128
139
|
const currentDate = new Date();
|
|
129
140
|
for (let year=currentDate.getUTCFullYear()-nbYearsBefore; year<=(currentDate.getUTCFullYear()+nbYearsAfter); year++) {
|
|
130
|
-
select.
|
|
141
|
+
select.insertAdjacentHTML('beforeend', '<option value="'+year+'">'+year+'</option>');
|
|
131
142
|
}
|
|
132
143
|
}
|
|
133
144
|
|
|
134
145
|
static fillMonthSelect(select, locale) {
|
|
135
146
|
for (let month=1; month<=12; month++) {
|
|
136
|
-
select.
|
|
147
|
+
select.insertAdjacentHTML('beforeend', '<option value="'+month+'">'+DateTime.getMonthNameByMonth(month, locale).capitalize()+'</option>');
|
|
137
148
|
}
|
|
138
149
|
}
|
|
139
150
|
|
|
140
151
|
static fillDayOfWeekSelect(select, locale) {
|
|
141
152
|
for (let dayOfWeek=1; dayOfWeek<=7; dayOfWeek++) {
|
|
142
|
-
select.
|
|
153
|
+
select.insertAdjacentHTML('beforeend', '<option value="'+dayOfWeek+'">'+DateTime.getDayNameByDayOfWeek(dayOfWeek, locale).capitalize()+'</option>');
|
|
143
154
|
}
|
|
144
155
|
}
|
|
145
156
|
|
|
@@ -152,86 +163,85 @@ class FormDate {
|
|
|
152
163
|
html += '<option value="'+key+'">'+label+'</option>';
|
|
153
164
|
});
|
|
154
165
|
html += '</optgroup>';
|
|
155
|
-
select.
|
|
166
|
+
select.insertAdjacentHTML('beforeend', html);
|
|
156
167
|
});
|
|
157
|
-
if (select.
|
|
158
|
-
select.
|
|
168
|
+
if (select.dataset.default_value) {
|
|
169
|
+
select.value = select.dataset.default_value;
|
|
159
170
|
}
|
|
160
171
|
}
|
|
161
172
|
|
|
162
173
|
function updatePeriodSelect(select) {
|
|
163
|
-
if (select.
|
|
164
|
-
select.closest('.form-group').
|
|
174
|
+
if (select.value === 'perso') {
|
|
175
|
+
select.closest('.form-group').nextElementSibling.classList.remove('hide');
|
|
165
176
|
}
|
|
166
177
|
else {
|
|
167
|
-
select.closest('.form-group').
|
|
178
|
+
select.closest('.form-group').nextElementSibling.classList.add('hide');
|
|
168
179
|
}
|
|
169
180
|
}
|
|
170
181
|
|
|
171
182
|
function updateForm(form) {
|
|
172
|
-
let periodSelect = form.
|
|
173
|
-
if (periodSelect
|
|
183
|
+
let periodSelect = form.querySelector('select.periode');
|
|
184
|
+
if (!periodSelect) {
|
|
174
185
|
return;
|
|
175
186
|
}
|
|
176
187
|
|
|
177
188
|
updatePeriodSelect(periodSelect);
|
|
178
189
|
|
|
179
|
-
let comparedPeriodSelect = form.
|
|
180
|
-
if (comparedPeriodSelect
|
|
190
|
+
let comparedPeriodSelect = form.querySelector('select.periodeCompare');
|
|
191
|
+
if (!comparedPeriodSelect) {
|
|
181
192
|
return;
|
|
182
193
|
}
|
|
183
194
|
|
|
184
195
|
let listValues = [];
|
|
185
196
|
let valueDefault = null;
|
|
186
197
|
|
|
187
|
-
comparedPeriodSelect.
|
|
198
|
+
comparedPeriodSelect.querySelectorAll('option').forEach(o => o.disabled = false);
|
|
188
199
|
|
|
189
200
|
Object.entries(FormDate.getPeriodList()).forEach(([idx, tabListPeriode]) => {
|
|
190
201
|
if (idx != 0) {
|
|
191
202
|
let listKeyPeriode = Object.entries(tabListPeriode['list']).map(([key, value]) => key);
|
|
192
|
-
if (listKeyPeriode.indexOf(periodSelect.
|
|
203
|
+
if (listKeyPeriode.indexOf(periodSelect.value) !== -1) {
|
|
193
204
|
listValues = listKeyPeriode;
|
|
194
205
|
valueDefault = listKeyPeriode[1];
|
|
195
206
|
}
|
|
196
207
|
else {
|
|
197
|
-
comparedPeriodSelect.
|
|
208
|
+
const optgroup = comparedPeriodSelect.querySelector('option[value="' + listKeyPeriode[0] + '"]')?.parentElement;
|
|
209
|
+
if (optgroup) { Array.from(optgroup.children).forEach(o => o.disabled = true); }
|
|
198
210
|
}
|
|
199
211
|
}
|
|
200
212
|
});
|
|
201
213
|
|
|
202
|
-
if (periodSelect.
|
|
214
|
+
if (periodSelect.value === 'perso') {
|
|
203
215
|
valueDefault = 'perso';
|
|
204
216
|
}
|
|
205
|
-
else if (comparedPeriodSelect.
|
|
206
|
-
valueDefault = comparedPeriodSelect.
|
|
217
|
+
else if (comparedPeriodSelect.value !== 'perso' && listValues.indexOf(comparedPeriodSelect.value) !== -1) {
|
|
218
|
+
valueDefault = comparedPeriodSelect.value;
|
|
207
219
|
}
|
|
208
|
-
comparedPeriodSelect.
|
|
220
|
+
comparedPeriodSelect.value = valueDefault;
|
|
209
221
|
|
|
210
222
|
updatePeriodSelect(comparedPeriodSelect);
|
|
211
223
|
}
|
|
212
224
|
|
|
213
225
|
// ---------- Choix période (new) ----------
|
|
214
226
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
});
|
|
227
|
+
const periodeSelect = form.querySelector('select.periode');
|
|
228
|
+
if (periodeSelect) {
|
|
229
|
+
fillPeriodSelect(periodeSelect);
|
|
230
|
+
periodeSelect.addEventListener('change', () => { updateForm(form); });
|
|
220
231
|
}
|
|
221
232
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
});
|
|
233
|
+
const periodeCompareSelect = form.querySelector('select.periodeCompare');
|
|
234
|
+
if (periodeCompareSelect) {
|
|
235
|
+
fillPeriodSelect(periodeCompareSelect);
|
|
236
|
+
periodeCompareSelect.addEventListener('change', () => { updateForm(form); });
|
|
227
237
|
}
|
|
228
238
|
|
|
229
239
|
updateForm(form);
|
|
230
240
|
|
|
231
241
|
// ---------- Choix période (old) ----------
|
|
232
242
|
|
|
233
|
-
if (form.
|
|
234
|
-
form.
|
|
243
|
+
if (form.querySelector('select.day') && form.querySelector('select.month') && form.querySelector('select.year')) {
|
|
244
|
+
form.querySelector('select.year').insertAdjacentHTML('afterend',
|
|
235
245
|
'<br/>'+
|
|
236
246
|
'<p class="select_date_fastly">'+
|
|
237
247
|
' <a href="#" class="lien_form_today">Auj.</a> - '+
|
|
@@ -246,8 +256,8 @@ class FormDate {
|
|
|
246
256
|
'</p>'
|
|
247
257
|
);
|
|
248
258
|
}
|
|
249
|
-
else if (form.
|
|
250
|
-
form.
|
|
259
|
+
else if (form.querySelector('select.month') && form.querySelector('select.year')) {
|
|
260
|
+
form.querySelector('select.year').insertAdjacentHTML('afterend',
|
|
251
261
|
'<br/>'+
|
|
252
262
|
'<p class="select_date_fastly">'+
|
|
253
263
|
' <a href="#" class="lien_form_current_month">Ce mois-ci</a> - '+
|
|
@@ -257,8 +267,8 @@ class FormDate {
|
|
|
257
267
|
);
|
|
258
268
|
}
|
|
259
269
|
|
|
260
|
-
if (form.
|
|
261
|
-
form.
|
|
270
|
+
if (form.querySelector('select.dayCompare') && form.querySelector('select.monthCompare') && form.querySelector('select.yearCompare')) {
|
|
271
|
+
form.querySelector('select.yearCompare').insertAdjacentHTML('afterend',
|
|
262
272
|
'<br/>'+
|
|
263
273
|
'<p class="select_date_fastly">'+
|
|
264
274
|
' <a href="#" class="lien_form_yesterday">Hier</a> - '+
|
|
@@ -266,81 +276,59 @@ class FormDate {
|
|
|
266
276
|
' <a href="#" class="lien_form_day_moins_8">J-8</a> - '+
|
|
267
277
|
' <a href="#" class="lien_form_last_month">Le mois dernier</a> - '+
|
|
268
278
|
' <a href="#" class="lien_form_month_moins_2">Mois M-2</a> - '+
|
|
269
|
-
' <a href="#" class="lien_form_last_year">L
|
|
279
|
+
' <a href="#" class="lien_form_last_year">L\'année dernière</a>'+
|
|
270
280
|
'</p>'
|
|
271
281
|
);
|
|
272
282
|
}
|
|
273
283
|
|
|
274
284
|
// Lien de sélection de date
|
|
275
285
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
return false;
|
|
280
|
-
});
|
|
286
|
+
const lienToday = form.querySelector('a.lien_form_today');
|
|
287
|
+
if (lienToday) {
|
|
288
|
+
lienToday.addEventListener('click', (e) => { e.preventDefault(); FormDate.setTodaySelected(lienToday.closest('.form-group')); });
|
|
281
289
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
return false;
|
|
286
|
-
});
|
|
290
|
+
const lienYesterday = form.querySelector('a.lien_form_yesterday');
|
|
291
|
+
if (lienYesterday) {
|
|
292
|
+
lienYesterday.addEventListener('click', (e) => { e.preventDefault(); FormDate.addNbDaysToToday(lienYesterday.closest('.form-group'), -1); });
|
|
287
293
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
return false;
|
|
292
|
-
});
|
|
294
|
+
const lienDayMoins7 = form.querySelector('a.lien_form_day_moins_7');
|
|
295
|
+
if (lienDayMoins7) {
|
|
296
|
+
lienDayMoins7.addEventListener('click', (e) => { e.preventDefault(); FormDate.addNbDaysToToday(lienDayMoins7.closest('.form-group'), -7); });
|
|
293
297
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
return false;
|
|
298
|
-
});
|
|
298
|
+
const lienDayMoins8 = form.querySelector('a.lien_form_day_moins_8');
|
|
299
|
+
if (lienDayMoins8) {
|
|
300
|
+
lienDayMoins8.addEventListener('click', (e) => { e.preventDefault(); FormDate.addNbDaysToToday(lienDayMoins8.closest('.form-group'), -8); });
|
|
299
301
|
}
|
|
300
302
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
return false;
|
|
305
|
-
});
|
|
303
|
+
const lienCurrentMonth = form.querySelector('a.lien_form_current_month');
|
|
304
|
+
if (lienCurrentMonth) {
|
|
305
|
+
lienCurrentMonth.addEventListener('click', (e) => { e.preventDefault(); FormDate.setCurrentMonthSelected(lienCurrentMonth.closest('.form-group')); });
|
|
306
306
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
return false;
|
|
311
|
-
});
|
|
307
|
+
const lienLastMonth = form.querySelector('a.lien_form_last_month');
|
|
308
|
+
if (lienLastMonth) {
|
|
309
|
+
lienLastMonth.addEventListener('click', (e) => { e.preventDefault(); FormDate.addNbMonthsToToday(lienLastMonth.closest('.form-group'), -1); });
|
|
312
310
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
return false;
|
|
317
|
-
});
|
|
311
|
+
const lienMonthMoins2 = form.querySelector('a.lien_form_month_moins_2');
|
|
312
|
+
if (lienMonthMoins2) {
|
|
313
|
+
lienMonthMoins2.addEventListener('click', (e) => { e.preventDefault(); FormDate.addNbMonthsToToday(lienMonthMoins2.closest('.form-group'), -2); });
|
|
318
314
|
}
|
|
319
315
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
return false;
|
|
324
|
-
});
|
|
316
|
+
const lienCurrentYear = form.querySelector('a.lien_form_current_year');
|
|
317
|
+
if (lienCurrentYear) {
|
|
318
|
+
lienCurrentYear.addEventListener('click', (e) => { e.preventDefault(); FormDate.setCurrentYearSelected(lienCurrentYear.closest('.form-group')); });
|
|
325
319
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
return false;
|
|
330
|
-
});
|
|
320
|
+
const lienLastYear = form.querySelector('a.lien_form_last_year');
|
|
321
|
+
if (lienLastYear) {
|
|
322
|
+
lienLastYear.addEventListener('click', (e) => { e.preventDefault(); FormDate.addNbYearsToToday(lienLastYear.closest('.form-group'), -1); });
|
|
331
323
|
}
|
|
332
324
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
return false;
|
|
337
|
-
});
|
|
325
|
+
const lienPrevDay = form.querySelector('a.lien_form_date_prev_day');
|
|
326
|
+
if (lienPrevDay) {
|
|
327
|
+
lienPrevDay.addEventListener('click', (e) => { e.preventDefault(); FormDate.addNbDaysToSelectedDate(lienPrevDay.closest('.form-group'), -1); });
|
|
338
328
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
return false;
|
|
343
|
-
});
|
|
329
|
+
const lienNextDay = form.querySelector('a.lien_form_date_next_day');
|
|
330
|
+
if (lienNextDay) {
|
|
331
|
+
lienNextDay.addEventListener('click', (e) => { e.preventDefault(); FormDate.addNbDaysToSelectedDate(lienNextDay.closest('.form-group'), 1); });
|
|
344
332
|
}
|
|
345
333
|
|
|
346
334
|
//if ($('form select[name=select_date_fastly]').length > 0) {
|
|
@@ -362,16 +350,16 @@ class FormDate {
|
|
|
362
350
|
perso: 'Personnalisé',
|
|
363
351
|
}},
|
|
364
352
|
'1d': {label: 'Un jour', list: { // 1 jour
|
|
365
|
-
'ajd': 'Aujourd
|
|
353
|
+
'ajd': 'Aujourd\u2019hui',
|
|
366
354
|
'hier': 'Hier',
|
|
367
355
|
'jourMoins2': 'Avant-hier',
|
|
368
356
|
'jourMoins3': 'J-3',
|
|
369
357
|
'jourMoins7': 'J-7',
|
|
370
358
|
'jourMoins8': 'J-8',
|
|
371
|
-
'same_day_last_year': 'Même jour l
|
|
372
|
-
'same_day_least_2_years': 'Même jour l
|
|
373
|
-
'same_day_as_yesterday_last_year': 'Même jour qu
|
|
374
|
-
'same_day_as_yesterday_least_2_years': 'Même jour qu
|
|
359
|
+
'same_day_last_year': 'Même jour l\u2019année dernière',
|
|
360
|
+
'same_day_least_2_years': 'Même jour l\u2019année A-2',
|
|
361
|
+
'same_day_as_yesterday_last_year': 'Même jour qu\u2019hier l\u2019année dernière',
|
|
362
|
+
'same_day_as_yesterday_least_2_years': 'Même jour qu\u2019hier l\u2019année A-2'
|
|
375
363
|
}},
|
|
376
364
|
'1w': {label: 'Une semaine', list: { // 1 semaine
|
|
377
365
|
'curr_week': 'Cette semaine',
|
|
@@ -383,27 +371,27 @@ class FormDate {
|
|
|
383
371
|
'7d': {label: '7 jours', list: { // 7 jours
|
|
384
372
|
'last_7_days': 'Les 7 derniers jours',
|
|
385
373
|
'last_7_days_before': 'Les 7 jours avant',
|
|
386
|
-
'last_7_days_least_1_year': 'Les mêmes 7 jours l
|
|
387
|
-
'last_7_days_least_2_years': 'Les mêmes 7 jours l
|
|
374
|
+
'last_7_days_least_1_year': 'Les mêmes 7 jours l\u2019année dernière',
|
|
375
|
+
'last_7_days_least_2_years': 'Les mêmes 7 jours l\u2019année A-2',
|
|
388
376
|
}},
|
|
389
377
|
'14d': {label: '14 jours', list: { // 14 jours
|
|
390
378
|
'last_14_days': 'Les 14 derniers jours',
|
|
391
379
|
'last_14_days_before': 'Les 14 jours avant',
|
|
392
|
-
'last_14_days_least_1_year': 'Les mêmes 14 jours l
|
|
393
|
-
'last_14_days_least_2_years': 'Les mêmes 14 jours l
|
|
380
|
+
'last_14_days_least_1_year': 'Les mêmes 14 jours l\u2019année dernière',
|
|
381
|
+
'last_14_days_least_2_years': 'Les mêmes 14 jours l\u2019année A-2',
|
|
394
382
|
}},
|
|
395
383
|
// 30 jours
|
|
396
384
|
'30d': {label: '30 jours', list: {
|
|
397
385
|
'last_30_days': 'Les 30 derniers jours',
|
|
398
386
|
'last_30_days_before': 'Les 30 jours avant',
|
|
399
|
-
'last_30_days_least_1_year': 'Les mêmes 30 jours l
|
|
400
|
-
'last_30_days_least_2_years': 'Les mêmes 30 jours l
|
|
387
|
+
'last_30_days_least_1_year': 'Les mêmes 30 jours l\u2019année dernière',
|
|
388
|
+
'last_30_days_least_2_years': 'Les mêmes 30 jours l\u2019année A-2',
|
|
401
389
|
}},
|
|
402
390
|
'60d': {label: '60 jours', list: { // 60 jours
|
|
403
391
|
'last_60_days': 'Les 60 derniers jours',
|
|
404
392
|
'last_60_days_before': 'Les 60 jours avant',
|
|
405
|
-
'last_60_days_least_1_year': 'Les mêmes 60 jours l
|
|
406
|
-
'last_60_days_least_2_years': 'Les mêmes 60 jours l
|
|
393
|
+
'last_60_days_least_1_year': 'Les mêmes 60 jours l\u2019année dernière',
|
|
394
|
+
'last_60_days_least_2_years': 'Les mêmes 60 jours l\u2019année A-2',
|
|
407
395
|
}},
|
|
408
396
|
'1m': {label: 'Un mois', list: { // 1 mois
|
|
409
397
|
'curr_month': 'Ce mois-ci',
|
|
@@ -413,36 +401,36 @@ class FormDate {
|
|
|
413
401
|
'monthMoins4': 'Mois M-4',
|
|
414
402
|
'monthMoins5': 'Mois M-5',
|
|
415
403
|
'monthMoins6': 'Mois M-6',
|
|
416
|
-
'same_month_last_year': 'Même mois l
|
|
417
|
-
'same_month_least_2_years': 'Même mois l
|
|
404
|
+
'same_month_last_year': 'Même mois l\u2019année dernière',
|
|
405
|
+
'same_month_least_2_years': 'Même mois l\u2019année A-2',
|
|
418
406
|
}},
|
|
419
407
|
'3m': {label: '3 mois', list: { // 3 mois
|
|
420
408
|
'last_3_month': 'Les 3 derniers mois',
|
|
421
409
|
'last_3_month_before': 'Les 3 mois avant',
|
|
422
|
-
'last_3_month_least_1_year': 'Les mêmes 3 mois l
|
|
423
|
-
'last_3_month_least_2_years': 'Les mêmes 3 mois l
|
|
410
|
+
'last_3_month_least_1_year': 'Les mêmes 3 mois l\u2019année dernière',
|
|
411
|
+
'last_3_month_least_2_years': 'Les mêmes 3 mois l\u2019année A-2',
|
|
424
412
|
}},
|
|
425
413
|
'6m': {label: '6 mois', list: { // 6 mois
|
|
426
414
|
'last_6_month': 'Les 6 derniers mois',
|
|
427
415
|
'last_6_month_before': 'Les 6 mois avant',
|
|
428
|
-
'last_6_month_least_1_year': 'Les mêmes 6 mois l
|
|
429
|
-
'last_6_month_least_2_years': 'Les mêmes 6 mois l
|
|
416
|
+
'last_6_month_least_1_year': 'Les mêmes 6 mois l\u2019année dernière',
|
|
417
|
+
'last_6_month_least_2_years': 'Les mêmes 6 mois l\u2019année A-2',
|
|
430
418
|
}},
|
|
431
419
|
'12m': {label: '12 mois', list: { // 12 mois
|
|
432
420
|
'last_12_month': 'Les 12 derniers mois',
|
|
433
421
|
'last_12_month_before': 'Les 12 mois avant',
|
|
434
|
-
'last_12_month_least_1_year': 'Les mêmes 12 mois l
|
|
435
|
-
'last_12_month_least_2_years': 'Les mêmes 12 mois l
|
|
422
|
+
'last_12_month_least_1_year': 'Les mêmes 12 mois l\u2019année dernière',
|
|
423
|
+
'last_12_month_least_2_years': 'Les mêmes 12 mois l\u2019année A-2',
|
|
436
424
|
}},
|
|
437
425
|
'24m': {label: '24 mois', list: { // 24 mois
|
|
438
426
|
'last_24_month': 'Les 24 derniers mois',
|
|
439
427
|
'last_24_month_before': 'Les 24 mois avant',
|
|
440
|
-
'last_24_month_least_1_year': 'Les mêmes 24 mois l
|
|
441
|
-
'last_24_month_least_2_years': 'Les mêmes 24 mois l
|
|
428
|
+
'last_24_month_least_1_year': 'Les mêmes 24 mois l\u2019année dernière',
|
|
429
|
+
'last_24_month_least_2_years': 'Les mêmes 24 mois l\u2019année A-2',
|
|
442
430
|
}},
|
|
443
431
|
'1y': {label: 'Une année', list: { // 1 année
|
|
444
432
|
'curr_year': 'Cette année',
|
|
445
|
-
'last_year': 'L
|
|
433
|
+
'last_year': 'L\u2019année dernière',
|
|
446
434
|
'yearMoins2': 'Année A-2',
|
|
447
435
|
'yearMoins3': 'Année A-3',
|
|
448
436
|
'yearMoins4': 'Année A-4',
|
|
@@ -489,9 +477,9 @@ class FormDate {
|
|
|
489
477
|
}
|
|
490
478
|
|
|
491
479
|
static getSelectedDate(periodFormGroup) {
|
|
492
|
-
let day = periodFormGroup.
|
|
493
|
-
let month = periodFormGroup.
|
|
494
|
-
let year = periodFormGroup.
|
|
480
|
+
let day = periodFormGroup.querySelector('select.day')?.value;
|
|
481
|
+
let month = periodFormGroup.querySelector('select.month')?.value;
|
|
482
|
+
let year = periodFormGroup.querySelector('select.year')?.value;
|
|
495
483
|
if (null != day && null != month && null != year) {
|
|
496
484
|
return new Date(year, month - 1, day);
|
|
497
485
|
}
|
|
@@ -499,9 +487,12 @@ class FormDate {
|
|
|
499
487
|
}
|
|
500
488
|
|
|
501
489
|
static setSelectedDate(periodFormGroup, day, month, year) {
|
|
502
|
-
periodFormGroup.
|
|
503
|
-
periodFormGroup.
|
|
504
|
-
periodFormGroup.
|
|
490
|
+
const daySelect = periodFormGroup.querySelector('select.day');
|
|
491
|
+
const monthSelect = periodFormGroup.querySelector('select.month');
|
|
492
|
+
const yearSelect = periodFormGroup.querySelector('select.year');
|
|
493
|
+
if (daySelect) daySelect.value = day;
|
|
494
|
+
if (monthSelect) monthSelect.value = month;
|
|
495
|
+
if (yearSelect) yearSelect.value = year;
|
|
505
496
|
}
|
|
506
497
|
|
|
507
498
|
|
|
@@ -607,4 +598,4 @@ class FormDate {
|
|
|
607
598
|
*/
|
|
608
599
|
}
|
|
609
600
|
|
|
610
|
-
module.exports = { FormDate, InputPeriod };
|
|
601
|
+
module.exports = { FormDate, InputPeriod };
|
package/import_from_csv.js
CHANGED
|
@@ -1,7 +1,33 @@
|
|
|
1
|
+
require('./string');
|
|
1
2
|
|
|
2
3
|
class ImportFromCsv {
|
|
3
4
|
|
|
4
|
-
static
|
|
5
|
+
static _defaults = {
|
|
6
|
+
errorMessageFileNotValid: 'Le fichier sélectionné n\'est pas un fichier CSV valide.',
|
|
7
|
+
errorMessageFileEmpty: 'Veuillez indiquer le fichier CSV à importer.',
|
|
8
|
+
errorMessageImportSelectColumns: 'Veuillez sélectionner les colonnes à importer.',
|
|
9
|
+
selectDefaultOptionLabel: 'Sélectionnez la colonne\u2026',
|
|
10
|
+
lineLabel: 'Ligne {0} :',
|
|
11
|
+
errorMessageImportFailed: 'L\'importation a échouée :',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
static setDefault(options) {
|
|
15
|
+
ImportFromCsv._defaults = { ...ImportFromCsv._defaults, ...options };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static initForm(div, options = {}) {
|
|
19
|
+
const {
|
|
20
|
+
importColumns,
|
|
21
|
+
requestImportData,
|
|
22
|
+
specificDescDiv,
|
|
23
|
+
additionalFormField,
|
|
24
|
+
errorMessageFileNotValid,
|
|
25
|
+
errorMessageFileEmpty,
|
|
26
|
+
errorMessageImportSelectColumns,
|
|
27
|
+
selectDefaultOptionLabel,
|
|
28
|
+
lineLabel,
|
|
29
|
+
errorMessageImportFailed,
|
|
30
|
+
} = { ...ImportFromCsv._defaults, ...options };
|
|
5
31
|
div.empty().append($('.import_form_base').clone().removeClass('import_form_base hide'));
|
|
6
32
|
|
|
7
33
|
let formUpload = div.find('.form_upload');
|
|
@@ -53,7 +79,7 @@ class ImportFromCsv {
|
|
|
53
79
|
let header = hasHeader?results.meta.fields:results.data[0];
|
|
54
80
|
|
|
55
81
|
ImportFromCsv.displayData(divResult, parsedImportList, (hasHeader?header:null), formMatching);
|
|
56
|
-
ImportFromCsv.displayFormMatching(formMatching, importColumns, header, hasHeader);
|
|
82
|
+
ImportFromCsv.displayFormMatching(formMatching, importColumns, header, hasHeader, selectDefaultOptionLabel);
|
|
57
83
|
|
|
58
84
|
formUpload.addClass('hide');
|
|
59
85
|
}
|
|
@@ -101,7 +127,7 @@ class ImportFromCsv {
|
|
|
101
127
|
formMatching.find('div.errors').html(json['import_list']).removeClass('hide');
|
|
102
128
|
}
|
|
103
129
|
else {
|
|
104
|
-
formMatching.find('div.errors').html(ImportFromCsv.getErrorsHtmlOfImportData(json, divResult)).removeClass('hide');
|
|
130
|
+
formMatching.find('div.errors').html(ImportFromCsv.getErrorsHtmlOfImportData(json, divResult, errorMessageImportFailed, lineLabel)).removeClass('hide');
|
|
105
131
|
}
|
|
106
132
|
FormHelper.buttonLoader(formMatching.find('button[type="submit"]'), 'reset');
|
|
107
133
|
}
|
|
@@ -218,7 +244,9 @@ class ImportFromCsv {
|
|
|
218
244
|
});
|
|
219
245
|
}
|
|
220
246
|
|
|
221
|
-
static getErrorsHtmlOfImportData(json, divResult=null) {
|
|
247
|
+
static getErrorsHtmlOfImportData(json, divResult = null, errorMessageImportFailed = null, lineLabel = null) {
|
|
248
|
+
errorMessageImportFailed = errorMessageImportFailed ?? ImportFromCsv._defaults.errorMessageImportFailed;
|
|
249
|
+
lineLabel = lineLabel ?? ImportFromCsv._defaults.lineLabel;
|
|
222
250
|
let resultError = errorMessageImportFailed;
|
|
223
251
|
resultError += '<ul>';
|
|
224
252
|
$.each(json, function(idx, errorData) {
|
|
@@ -264,7 +292,8 @@ class ImportFromCsv {
|
|
|
264
292
|
return tabLink;
|
|
265
293
|
}
|
|
266
294
|
|
|
267
|
-
static displayFormMatching(formMatching, importColumns, header, hasHeader) {
|
|
295
|
+
static displayFormMatching(formMatching, importColumns, header, hasHeader, selectDefaultOptionLabel = null) {
|
|
296
|
+
selectDefaultOptionLabel = selectDefaultOptionLabel ?? ImportFromCsv._defaults.selectDefaultOptionLabel;
|
|
268
297
|
let options = '<option value="-1">'+selectDefaultOptionLabel+'</option>';
|
|
269
298
|
$.each(header, function (index, value) {
|
|
270
299
|
options += '<option value="'+(hasHeader?value:index)+'">' + value + '</option>';
|
package/multi_files_input.js
CHANGED