@osimatic/helpers-js 1.4.26 → 1.4.27
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/multiple_action_in_table.js +27 -11
- package/package.json +1 -1
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
|
|
2
2
|
class MultipleActionInTable {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
|
|
4
|
+
// Ajoute les colonnes select (thead th + tbody td) dans le DOM.
|
|
5
|
+
// Idempotent : sans effet si les colonnes existent déjà.
|
|
6
|
+
// Doit être appelé AVANT l'initialisation DataTable.
|
|
7
|
+
static initCols(table, cellCssClass = 'select') {
|
|
8
|
+
if (!table.hasClass('table-action_multiple')) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (MultipleActionInTable.getDivBtn(table) == null) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (table.find('thead tr th[data-key="select"]').length === 0) {
|
|
16
|
+
table.find('thead tr').prepend($('<th class="' + cellCssClass + '" data-key="select"></th>'));
|
|
17
|
+
}
|
|
18
|
+
table.find('tbody tr:not(.no_items)').each(function(idx, tr) {
|
|
19
|
+
if ($(tr).find('td.select').length === 0) {
|
|
20
|
+
$(tr).prepend($('<td class="select"><input type="checkbox" class="action_multiple_checkbox" name="' + $(tr).data('action_multiple_input_name') + '" value="' + $(tr).data('action_multiple_item_id') + '"></td>'));
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Initialise les colonnes (via initCols) puis branche les event handlers.
|
|
26
|
+
// Peut être appelé après l'initialisation DataTable.
|
|
27
|
+
static init(table, cellCssClass = 'select') {
|
|
5
28
|
if (!table.hasClass('table-action_multiple')) {
|
|
6
29
|
return;
|
|
7
30
|
}
|
|
@@ -11,21 +34,14 @@ class MultipleActionInTable {
|
|
|
11
34
|
return;
|
|
12
35
|
}
|
|
13
36
|
|
|
37
|
+
MultipleActionInTable.initCols(table, cellCssClass);
|
|
38
|
+
|
|
14
39
|
if (!divBtn.hasClass('action_multiple_buttons_initialized')) {
|
|
15
40
|
divBtn.prepend($('<img src="'+ROOT_PATH+DOSSIER_IMAGES+'arrow_ltr.png" alt="" /> '));
|
|
16
41
|
divBtn.append($('<br/><br/>'));
|
|
17
42
|
divBtn.addClass('action_multiple_buttons_initialized');
|
|
18
43
|
}
|
|
19
44
|
|
|
20
|
-
if (table.find('thead tr th[data-key="select"]').length === 0) {
|
|
21
|
-
table.find('thead tr').prepend($('<th class="'+cellCssClass+'" data-key="select"></th>'));
|
|
22
|
-
}
|
|
23
|
-
table.find('tbody tr:not(.no_items)').each(function(idx, tr) {
|
|
24
|
-
if ($(tr).find('td.select').length === 0) {
|
|
25
|
-
$(tr).prepend($('<td class="select"><input type="checkbox" class="action_multiple_checkbox" name="'+$(tr).data('action_multiple_input_name')+'" value="'+$(tr).data('action_multiple_item_id')+'"></td>'));
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
|
|
29
45
|
let firstTh = table.find('thead tr th').first();
|
|
30
46
|
if (firstTh.find('input').length === 0) {
|
|
31
47
|
firstTh.html('<input type="checkbox" class="action_multiple_check_all" />');
|