@osimatic/helpers-js 1.5.11 → 1.5.12
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/form_date.js +7 -0
- package/form_helper.js +3 -2
- package/package.json +1 -1
- package/select_all.js +3 -0
package/form_date.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
const { toEl } = require('./util');
|
|
1
2
|
const { DateTime } = require('./date_time');
|
|
2
3
|
|
|
3
4
|
// input period de type : Du <input type="date" name="start_date" /> au <input type="date" name="end_date" />
|
|
4
5
|
class InputPeriod {
|
|
5
6
|
|
|
6
7
|
static addLinks(form) {
|
|
8
|
+
form = toEl(form);
|
|
7
9
|
let divParent = form.querySelector('input[type="date"][data-add_period_select_links]').parentElement;
|
|
8
10
|
if (divParent.classList.contains('input-group')) {
|
|
9
11
|
divParent = divParent.parentElement;
|
|
@@ -22,6 +24,7 @@ class InputPeriod {
|
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
static init(form) {
|
|
27
|
+
form = toEl(form);
|
|
25
28
|
//console.log(form.querySelector('a.period_select_current_week'));
|
|
26
29
|
|
|
27
30
|
const linkToday = form.querySelector('a.period_select_today');
|
|
@@ -136,6 +139,7 @@ class InputPeriod {
|
|
|
136
139
|
class FormDate {
|
|
137
140
|
|
|
138
141
|
static fillYearSelect(select, nbYearsBefore=5, nbYearsAfter=0) {
|
|
142
|
+
select = toEl(select);
|
|
139
143
|
const currentDate = new Date();
|
|
140
144
|
for (let year=currentDate.getUTCFullYear()-nbYearsBefore; year<=(currentDate.getUTCFullYear()+nbYearsAfter); year++) {
|
|
141
145
|
select.insertAdjacentHTML('beforeend', '<option value="'+year+'">'+year+'</option>');
|
|
@@ -143,18 +147,21 @@ class FormDate {
|
|
|
143
147
|
}
|
|
144
148
|
|
|
145
149
|
static fillMonthSelect(select, locale) {
|
|
150
|
+
select = toEl(select);
|
|
146
151
|
for (let month=1; month<=12; month++) {
|
|
147
152
|
select.insertAdjacentHTML('beforeend', '<option value="'+month+'">'+DateTime.getMonthNameByMonth(month, locale).capitalize()+'</option>');
|
|
148
153
|
}
|
|
149
154
|
}
|
|
150
155
|
|
|
151
156
|
static fillDayOfWeekSelect(select, locale) {
|
|
157
|
+
select = toEl(select);
|
|
152
158
|
for (let dayOfWeek=1; dayOfWeek<=7; dayOfWeek++) {
|
|
153
159
|
select.insertAdjacentHTML('beforeend', '<option value="'+dayOfWeek+'">'+DateTime.getDayNameByDayOfWeek(dayOfWeek, locale).capitalize()+'</option>');
|
|
154
160
|
}
|
|
155
161
|
}
|
|
156
162
|
|
|
157
163
|
static initForm(form) {
|
|
164
|
+
form = toEl(form);
|
|
158
165
|
|
|
159
166
|
function fillPeriodSelect(select) {
|
|
160
167
|
Object.entries(FormDate.getPeriodList()).forEach(([idx, tabListPeriode]) => {
|
package/form_helper.js
CHANGED
|
@@ -366,10 +366,11 @@ class FormHelper {
|
|
|
366
366
|
// ------------------------------------------------------------
|
|
367
367
|
|
|
368
368
|
static buttonLoader(button, action) {
|
|
369
|
+
const wasJQuery = button && button.jquery;
|
|
369
370
|
button = toEl(button);
|
|
370
371
|
if (action === 'start' || action === 'loading') {
|
|
371
372
|
if (button.disabled) {
|
|
372
|
-
return button;
|
|
373
|
+
return wasJQuery && typeof $ !== 'undefined' ? $(button) : button;
|
|
373
374
|
}
|
|
374
375
|
button.disabled = true;
|
|
375
376
|
button.dataset.btnText = button.innerHTML;
|
|
@@ -391,7 +392,7 @@ class FormHelper {
|
|
|
391
392
|
button.classList.remove('disabled');
|
|
392
393
|
button.disabled = false;
|
|
393
394
|
}
|
|
394
|
-
return button;
|
|
395
|
+
return wasJQuery && typeof $ !== 'undefined' ? $(button) : button;
|
|
395
396
|
}
|
|
396
397
|
|
|
397
398
|
|
package/package.json
CHANGED
package/select_all.js
CHANGED
|
@@ -29,6 +29,7 @@ class SelectAll {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
static updateFormGroup(formGroup) {
|
|
32
|
+
formGroup = toEl(formGroup);
|
|
32
33
|
const allCheckbox = formGroup.querySelectorAll('input[type="checkbox"]:not(.check_all)');
|
|
33
34
|
const allCheckboxChecked = formGroup.querySelectorAll('input[type="checkbox"]:not(.check_all):checked');
|
|
34
35
|
const lienSelectAll = formGroup.querySelector('a.check_all');
|
|
@@ -70,6 +71,7 @@ class SelectAll {
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
static updateTable(table) {
|
|
74
|
+
table = toEl(table);
|
|
73
75
|
const allCheckbox = table.querySelectorAll('tbody input[type="checkbox"]');
|
|
74
76
|
const allCheckboxChecked = table.querySelectorAll('tbody input[type="checkbox"]:checked');
|
|
75
77
|
const checkboxSelectAll = table.querySelector('thead input.check_all');
|
|
@@ -107,6 +109,7 @@ class SelectAll {
|
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
static updateDiv(div) {
|
|
112
|
+
div = toEl(div);
|
|
110
113
|
// 22/11/2021 : rajout :not(.check_all) sinon si toutes les cases sont coché, la case select all n'est pas coché à l'initialisation
|
|
111
114
|
const allCheckbox = div.querySelectorAll('div.checkbox input[type="checkbox"]:not(.check_all), div.form-check input[type="checkbox"]:not(.check_all)');
|
|
112
115
|
const allCheckboxChecked = div.querySelectorAll('div.checkbox input[type="checkbox"]:not(.check_all):checked, div.form-check input[type="checkbox"]:not(.check_all):checked');
|