@osimatic/helpers-js 1.0.76 → 1.0.79
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_helper.js +11 -0
- package/index.js +2 -2
- package/multiple_action_in_table.js +116 -18
- package/package.json +1 -1
package/form_helper.js
CHANGED
|
@@ -105,6 +105,17 @@ class FormHelper {
|
|
|
105
105
|
}).get().filter(word => word.length > 0);
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
static getInputValue(input) {
|
|
109
|
+
if (typeof input == 'undefined') {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
let value = $(input).val();
|
|
113
|
+
if (value === null || value === '') {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
return value;
|
|
117
|
+
}
|
|
118
|
+
|
|
108
119
|
static getLinesOfTextarea(textarea) {
|
|
109
120
|
return textarea.val().replace(/(\r\n|\n|\r)/g, "\n").split("\n").filter(word => word.length > 0);
|
|
110
121
|
}
|
package/index.js
CHANGED
|
@@ -26,7 +26,7 @@ const { DataTable } = require('./data_table');
|
|
|
26
26
|
const { Pagination, Navigation } = require('./paging');
|
|
27
27
|
const { DetailsSubArray } = require('./details_sub_array');
|
|
28
28
|
const { SelectAll } = require('./select_all');
|
|
29
|
-
const { MultipleActionInTable } = require('./multiple_action_in_table');
|
|
29
|
+
const { MultipleActionInTable, MultipleActionInDivList } = require('./multiple_action_in_table');
|
|
30
30
|
const { FormDate, InputPeriod } = require('./form_date');
|
|
31
31
|
const { ShoppingCart } = require('./shopping_cart');
|
|
32
32
|
const { FlashMessage } = require('./flash_message');
|
|
@@ -47,7 +47,7 @@ const { WebSocket } = require('./web_socket');
|
|
|
47
47
|
module.exports = {
|
|
48
48
|
Array, Object, Number, String,
|
|
49
49
|
HTTPRequest, Cookie, UrlAndQueryString, IBAN, BankCard, AudioMedia, UserMedia, PersonName, Email, TelephoneNumber, DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, Duration, File, CSV, Img, FormHelper, Country, PostalAddress, GeographicCoordinates, SocialNetwork,
|
|
50
|
-
Browser, DataTable, Pagination, Navigation, DetailsSubArray, SelectAll, MultipleActionInTable, EditValue, FormDate, InputPeriod, ShoppingCart, FlashMessage, CountDown, ImportFromCsv, JwtToken, JwtSession, ApiTokenSession, ListBox, WebRTC, WebSocket, EventBus,
|
|
50
|
+
Browser, DataTable, Pagination, Navigation, DetailsSubArray, SelectAll, MultipleActionInTable, MultipleActionInDivList, EditValue, FormDate, InputPeriod, ShoppingCart, FlashMessage, CountDown, ImportFromCsv, JwtToken, JwtSession, ApiTokenSession, ListBox, WebRTC, WebSocket, EventBus,
|
|
51
51
|
sleep, refresh, chr, ord, trim, empty,
|
|
52
52
|
GoogleCharts, GoogleRecaptcha, GoogleMap, OpenStreetMap
|
|
53
53
|
};
|
|
@@ -6,7 +6,7 @@ class MultipleActionInTable {
|
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
let divBtn = MultipleActionInTable.getDivBtn(table);
|
|
10
10
|
if (divBtn == null) {
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
@@ -26,23 +26,19 @@ class MultipleActionInTable {
|
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
table.find('
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
th.html('<input type="checkbox" class="action_multiple_check_all" />');
|
|
34
|
-
// th.html('Coucou');
|
|
35
|
-
}
|
|
36
|
-
});
|
|
29
|
+
let firstTh = table.find('thead tr th').first();
|
|
30
|
+
if (firstTh.find('input').length === 0) {
|
|
31
|
+
firstTh.html('<input type="checkbox" class="action_multiple_check_all" />');
|
|
32
|
+
}
|
|
37
33
|
|
|
38
34
|
table.find('input.action_multiple_checkbox').change(function() {
|
|
39
35
|
MultipleActionInTable.updateCheckbox(table);
|
|
40
36
|
});
|
|
41
37
|
|
|
42
38
|
table.find('input.action_multiple_check_all').off('click').click(function() {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
let table = $(this).closest('table');
|
|
40
|
+
let checkbox = table.find('input.action_multiple_checkbox');
|
|
41
|
+
let checkboxChecked = table.find('input.action_multiple_checkbox:checked');
|
|
46
42
|
if (checkbox.length === checkboxChecked.length) {
|
|
47
43
|
checkbox.prop('checked', false);
|
|
48
44
|
}
|
|
@@ -58,9 +54,9 @@ class MultipleActionInTable {
|
|
|
58
54
|
static updateCheckbox(table) {
|
|
59
55
|
MultipleActionInTable.showButtonsAction(table);
|
|
60
56
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
let allCheckbox = table.find('input.action_multiple_checkbox');
|
|
58
|
+
let allCheckboxChecked = table.find('input.action_multiple_checkbox:checked');
|
|
59
|
+
let checkboxSelectAll = table.find('thead tr th input.action_multiple_check_all');
|
|
64
60
|
if (allCheckbox.length === allCheckboxChecked.length) {
|
|
65
61
|
checkboxSelectAll.prop('checked', true);
|
|
66
62
|
}
|
|
@@ -70,8 +66,8 @@ class MultipleActionInTable {
|
|
|
70
66
|
}
|
|
71
67
|
|
|
72
68
|
static getDivBtn(table) {
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
let divTableResponsive = table.parent();
|
|
70
|
+
let divBtn = divTableResponsive.next();
|
|
75
71
|
if (divBtn.hasClass('action_multiple_buttons')) {
|
|
76
72
|
return divBtn;
|
|
77
73
|
}
|
|
@@ -111,7 +107,109 @@ class MultipleActionInTable {
|
|
|
111
107
|
|
|
112
108
|
}
|
|
113
109
|
|
|
114
|
-
|
|
110
|
+
class MultipleActionInDivList {
|
|
111
|
+
// init checkbox
|
|
112
|
+
static init(contentDiv) {
|
|
113
|
+
let buttonsDiv = MultipleActionInDivList.getButtonsDiv(contentDiv);
|
|
114
|
+
if (buttonsDiv == null) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
buttonsDiv.addClass('hide');
|
|
119
|
+
|
|
120
|
+
// Si aucune div sélectionnable, on n'applique pas le plugin
|
|
121
|
+
if (!contentDiv.find('.multiple_action').length) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (!buttonsDiv.data('action_multiple_buttons_initialized')) {
|
|
126
|
+
buttonsDiv.prepend($('<img src="'+ROOT_PATH+DOSSIER_IMAGES+'arrow_ltr.png" alt="" /> '));
|
|
127
|
+
buttonsDiv.append($('<br/><br/>'));
|
|
128
|
+
buttonsDiv.data('action_multiple_buttons_initialized', 1);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Ajout checkbox pour chaque div sélectionnable
|
|
132
|
+
contentDiv.find('.multiple_action').each(function(idx, div) {
|
|
133
|
+
if ($(div).find('div.multi_select').length === 0) {
|
|
134
|
+
$(div).prepend($('<div class="multi_select float-start me-2"><input type="checkbox" class="action_multiple_checkbox" name="'+$(div).data('action_multiple_input_name')+'" value="'+$(div).data('action_multiple_item_id')+'"></div>'));
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// Ajout checkbox select all
|
|
139
|
+
if (contentDiv.find('input.action_multiple_check_all').length === 0) {
|
|
140
|
+
contentDiv.prepend('<p class="mb-2"><input type="checkbox" class="action_multiple_check_all" /> Tout sélectionner</p>');
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
contentDiv.find('input.action_multiple_checkbox').change(function() {
|
|
144
|
+
MultipleActionInDivList.updateCheckbox(contentDiv);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
contentDiv.find('input.action_multiple_check_all').off('click').click(function() {
|
|
148
|
+
let checkbox = contentDiv.find('input.action_multiple_checkbox');
|
|
149
|
+
let checkboxChecked = contentDiv.find('input.action_multiple_checkbox:checked');
|
|
150
|
+
if (checkbox.length === checkboxChecked.length) {
|
|
151
|
+
checkbox.prop('checked', false);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
checkbox.prop('checked', true);
|
|
155
|
+
}
|
|
156
|
+
MultipleActionInDivList.updateCheckbox(contentDiv);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
MultipleActionInDivList.updateCheckbox(contentDiv);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
static updateCheckbox(contentDiv) {
|
|
163
|
+
MultipleActionInDivList.showButtonsAction(contentDiv);
|
|
164
|
+
|
|
165
|
+
let allCheckbox = contentDiv.find('input.action_multiple_checkbox');
|
|
166
|
+
let allCheckboxChecked = contentDiv.find('input.action_multiple_checkbox:checked');
|
|
167
|
+
let checkboxSelectAll = contentDiv.find('input.action_multiple_check_all');
|
|
168
|
+
if (allCheckbox.length === allCheckboxChecked.length) {
|
|
169
|
+
checkboxSelectAll.prop('checked', true);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
checkboxSelectAll.prop('checked', false);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
static getButtonsDiv(contentDiv) {
|
|
177
|
+
let buttonsDiv = contentDiv.next();
|
|
178
|
+
if (buttonsDiv.hasClass('action_multiple_buttons')) {
|
|
179
|
+
return buttonsDiv;
|
|
180
|
+
}
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
static showButtonsAction(contentDiv) {
|
|
185
|
+
let buttonsDiv = MultipleActionInDivList.getButtonsDiv(contentDiv);
|
|
186
|
+
if (buttonsDiv == null) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// console.log(divBtn);
|
|
191
|
+
//var nbItems = $('input[name="' + checkbox.attr('name') + '"]:checked').length;
|
|
192
|
+
let nbItems = contentDiv.find('input.action_multiple_checkbox:checked').length;
|
|
193
|
+
|
|
194
|
+
if (nbItems > 0 && buttonsDiv.is(':hidden')) {
|
|
195
|
+
buttonsDiv.removeClass('hide');
|
|
196
|
+
}
|
|
197
|
+
// 13/04/2021 : si le tableau est caché cela veut dire qu'il est en train de s'initialiser (après avoir chargé les données) et donc s'il n'y a pas de ligne sélectionnées, on cache la div buttons
|
|
198
|
+
else if ((nbItems === 0 && buttonsDiv.is(':visible')) || (nbItems === 0 && contentDiv.is(':hidden'))) {
|
|
199
|
+
buttonsDiv.addClass('hide');
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// affichage aucune action possible si aucun bouton n'est visible
|
|
203
|
+
if (buttonsDiv.is(':visible')) {
|
|
204
|
+
buttonsDiv.find('span.no_button').remove();
|
|
205
|
+
if (buttonsDiv.find('button:visible, a:visible').length === 0) {
|
|
206
|
+
buttonsDiv.find('img').after('<span class="no_button"><em>aucune action possible</em></span>');
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
module.exports = { MultipleActionInTable, MultipleActionInDivList };
|
|
115
213
|
|
|
116
214
|
/*
|
|
117
215
|
// init checkbox
|