@osimatic/helpers-js 1.5.3 → 1.5.4
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/details_sub_array.js +45 -41
- package/form_helper.js +283 -232
- package/google_charts.js +154 -144
- package/google_maps.js +1 -1
- package/import_from_csv.js +166 -157
- package/multi_files_input.js +42 -34
- package/multiple_action_in_table.js +115 -105
- package/package.json +1 -1
- package/paging.js +103 -84
- package/select_all.js +65 -70
- package/sortable_list.js +12 -13
- package/tests/details_sub_array.test.js +211 -239
- package/tests/form_helper.test.js +553 -673
- package/tests/google_charts.test.js +338 -339
- package/tests/google_maps.test.js +3 -15
- package/tests/import_from_csv.test.js +391 -652
- package/tests/multi_files_input.test.js +292 -722
- package/tests/multiple_action_in_table.test.js +439 -417
- package/tests/paging.test.js +344 -475
- package/tests/select_all.test.js +232 -318
- package/tests/sortable_list.test.js +176 -500
- package/tests/user.test.js +163 -54
- package/user.js +35 -38
package/details_sub_array.js
CHANGED
|
@@ -13,66 +13,73 @@ class DetailsSubArray {
|
|
|
13
13
|
} = options;
|
|
14
14
|
|
|
15
15
|
function getNbColumns(tr) {
|
|
16
|
-
return tr.closest('table').
|
|
16
|
+
return tr.closest('table').querySelector('thead tr').children.length;
|
|
17
17
|
}
|
|
18
18
|
function displayErrorRow(tr) {
|
|
19
|
-
tr.
|
|
19
|
+
tr.insertAdjacentHTML('afterend', '<tr class="text-error"><td colspan="'+getNbColumns(tr)+'">'+labelErrorOccurred+'</td></tr>');
|
|
20
20
|
}
|
|
21
21
|
function displayDetailsRow(tr, content) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
const td = document.createElement('td');
|
|
23
|
+
td.setAttribute('colspan', getNbColumns(tr));
|
|
24
|
+
if (content instanceof Node) {
|
|
25
|
+
td.appendChild(content);
|
|
26
|
+
} else {
|
|
27
|
+
td.innerHTML = content || '';
|
|
28
|
+
}
|
|
29
|
+
const trContent = document.createElement('tr');
|
|
30
|
+
trContent.className = 'participants';
|
|
31
|
+
trContent.appendChild(td);
|
|
32
|
+
tr.insertAdjacentElement('afterend', trContent);
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
function hideDetailsRow(link) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
const tr = link.closest('tr');
|
|
37
|
+
tr.classList.add('folded');
|
|
38
|
+
const next = tr.nextElementSibling;
|
|
39
|
+
if (next && next.classList.contains('participants')) {
|
|
40
|
+
next.remove();
|
|
36
41
|
}
|
|
37
42
|
showPlusButton(link);
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
function showPlusButton(link) {
|
|
41
|
-
link.
|
|
46
|
+
link.title = showDetailsLabel;
|
|
47
|
+
link.disabled = false;
|
|
48
|
+
link.innerHTML = '<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>';
|
|
42
49
|
}
|
|
43
50
|
function showMinusButton(link) {
|
|
44
|
-
link.
|
|
51
|
+
link.title = hideDetailsLabel;
|
|
52
|
+
link.disabled = false;
|
|
53
|
+
link.innerHTML = '<span class="glyphicon glyphicon-minus" aria-hidden="true"></span>';
|
|
45
54
|
}
|
|
46
55
|
|
|
47
56
|
function displayLoading(link) {
|
|
48
|
-
link.
|
|
49
|
-
|
|
50
|
-
tr
|
|
57
|
+
link.disabled = true;
|
|
58
|
+
link.innerHTML = '<i class="fa fa-circle-notch fa-spin"></i>';
|
|
59
|
+
const tr = link.closest('tr');
|
|
60
|
+
tr.insertAdjacentHTML('afterend', '<tr class="waiting_icon"><td colspan="'+getNbColumns(tr)+'" class="center"><i class="fa fa-circle-notch fa-spin"></i></td></tr>');
|
|
51
61
|
}
|
|
52
|
-
function hideLoading(
|
|
62
|
+
function hideLoading() {
|
|
53
63
|
// todo : cacher que le loader du lien au lieu de tous les loaders (cas ou l'user clique sur tous les boutons rapidement)
|
|
54
|
-
|
|
55
|
-
$(('tr.waiting_icon')).remove();
|
|
56
|
-
}
|
|
64
|
+
document.querySelectorAll('tr.waiting_icon').forEach(el => el.remove());
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
function setHideDetailsLink(link) {
|
|
60
68
|
showMinusButton(link);
|
|
61
|
-
link.
|
|
62
|
-
|
|
69
|
+
link.onclick = function(e) {
|
|
70
|
+
e.preventDefault();
|
|
63
71
|
hideDetailsRow(link);
|
|
64
72
|
setDisplayDetailsLink(link);
|
|
65
|
-
|
|
66
|
-
});
|
|
73
|
+
};
|
|
67
74
|
}
|
|
68
75
|
|
|
69
76
|
function setDisplayDetailsLink(link) {
|
|
70
|
-
link.
|
|
71
|
-
|
|
77
|
+
link.onclick = function(e) {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
link.onclick = null;
|
|
72
80
|
hideDetailsRow(link);
|
|
73
81
|
doDetailsActionRequest(link);
|
|
74
|
-
|
|
75
|
-
});
|
|
82
|
+
};
|
|
76
83
|
}
|
|
77
84
|
|
|
78
85
|
function doDetailsActionRequest(link) {
|
|
@@ -80,19 +87,17 @@ class DetailsSubArray {
|
|
|
80
87
|
|
|
81
88
|
if (onBeforeSend != null) {
|
|
82
89
|
displayDetailsRow(link.closest('tr'), onBeforeSend(link));
|
|
83
|
-
hideLoading(
|
|
90
|
+
hideLoading();
|
|
84
91
|
setHideDetailsLink(link);
|
|
85
92
|
return;
|
|
86
93
|
}
|
|
87
94
|
|
|
88
95
|
function onComplete() {
|
|
89
|
-
hideLoading(
|
|
96
|
+
hideLoading();
|
|
90
97
|
setHideDetailsLink(link);
|
|
91
|
-
//link.attr('disabled', false).button('reset');
|
|
92
98
|
}
|
|
93
99
|
|
|
94
|
-
|
|
95
|
-
HTTPClient.request('GET', link.data('url_details'), null,
|
|
100
|
+
HTTPClient.request('GET', link.dataset.url_details, null,
|
|
96
101
|
(jsonObj) => {
|
|
97
102
|
if (jsonObj == null) {
|
|
98
103
|
if (onError != null) {
|
|
@@ -115,18 +120,17 @@ class DetailsSubArray {
|
|
|
115
120
|
return;
|
|
116
121
|
}
|
|
117
122
|
|
|
118
|
-
link.closest('tr').
|
|
123
|
+
link.closest('tr').insertAdjacentHTML('afterend', '<tr class="error"><td colspan="6" class="center">'+(labelErrorOccurred ?? 'Une erreur s\'est produite.')+'</td></tr>');
|
|
119
124
|
|
|
120
125
|
onComplete();
|
|
121
|
-
//window.location.replace(decodeURIComponent(urlRetour));
|
|
122
126
|
}
|
|
123
127
|
);
|
|
124
128
|
}
|
|
125
129
|
|
|
126
|
-
table.
|
|
127
|
-
|
|
128
|
-
setDisplayDetailsLink(
|
|
129
|
-
showPlusButton(
|
|
130
|
+
table.querySelectorAll('a.details_link').forEach((link) => {
|
|
131
|
+
link.classList.remove('hide');
|
|
132
|
+
setDisplayDetailsLink(link);
|
|
133
|
+
showPlusButton(link);
|
|
130
134
|
});
|
|
131
135
|
}
|
|
132
136
|
|