@osimatic/helpers-js 1.0.97 → 1.0.98
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/data_table.js +29 -27
- package/duration.js +2 -1
- package/form_helper.js +29 -27
- package/package.json +1 -1
- package/visitor.js +1 -0
package/data_table.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
class DataTable {
|
|
3
|
-
// criteres = {};
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
static setOptions(options) {
|
|
5
|
+
DataTable.dateTableOptions = Object.assign(...DataTable.getOptions(), options);
|
|
6
|
+
}
|
|
7
|
+
static getOptions() {
|
|
8
|
+
return DataTable.dateTableOptions || {};
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
static setCallbackOnLoadData(callback) {
|
|
@@ -39,8 +41,8 @@ class DataTable {
|
|
|
39
41
|
// ------------------------------------------------------------
|
|
40
42
|
|
|
41
43
|
static init(options) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
let div = options.div;
|
|
45
|
+
let defaultFilters = options.default_filters || {};
|
|
44
46
|
|
|
45
47
|
//let form = div.find('.filter_popover_content form');
|
|
46
48
|
//if (typeof form != 'undefined') {
|
|
@@ -49,7 +51,7 @@ class DataTable {
|
|
|
49
51
|
//}
|
|
50
52
|
|
|
51
53
|
// Bouton filtrer
|
|
52
|
-
|
|
54
|
+
let filterLink = div.find('a.filter_link');
|
|
53
55
|
if (filterLink.length) {
|
|
54
56
|
filterLink.popover({
|
|
55
57
|
content: div.find('.filter_popover_content').html(),
|
|
@@ -68,7 +70,7 @@ class DataTable {
|
|
|
68
70
|
});
|
|
69
71
|
|
|
70
72
|
filterLink.on('shown.bs.popover', function () {
|
|
71
|
-
|
|
73
|
+
let form = $('.filter_popover form');
|
|
72
74
|
|
|
73
75
|
DataTable.populateFormFromFilters(form);
|
|
74
76
|
|
|
@@ -89,7 +91,7 @@ class DataTable {
|
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
// Bouton exporter
|
|
92
|
-
|
|
94
|
+
let exportLink = div.find('a.export_link');
|
|
93
95
|
if (exportLink.length) {
|
|
94
96
|
if (typeof options.export_modal_enabled == 'undefined' || !options.export_modal_enabled) {
|
|
95
97
|
// sans modal
|
|
@@ -111,9 +113,9 @@ class DataTable {
|
|
|
111
113
|
});
|
|
112
114
|
|
|
113
115
|
$('div#modal_export').on('show.bs.modal', function (event) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
let button = $(event.relatedTarget);
|
|
117
|
+
let modal = $(this);
|
|
118
|
+
let form = modal.find('form');
|
|
117
119
|
|
|
118
120
|
// Fonction de callback permettant d'initialiser contenu du modal export, cette fonction doit renvoyer le contenu du modal
|
|
119
121
|
if (typeof options.set_export_form != 'undefined' && options.set_export_form != null) {
|
|
@@ -125,7 +127,7 @@ class DataTable {
|
|
|
125
127
|
modal.find('modal-body').html(options.on_show_export_form(modal, button));
|
|
126
128
|
}
|
|
127
129
|
|
|
128
|
-
|
|
130
|
+
let btnSubmit = form.find('button[type="submit"]').attr('disabled', false).button('reset');
|
|
129
131
|
btnSubmit.off('click').click(function(e) {
|
|
130
132
|
e.preventDefault();
|
|
131
133
|
$(this).attr('disabled', true).button('loading');
|
|
@@ -255,9 +257,9 @@ class DataTable {
|
|
|
255
257
|
}
|
|
256
258
|
static displayMessage(div, msg, cssClass /*, removeLoader=false*/) {
|
|
257
259
|
this.resetContent(div);
|
|
258
|
-
|
|
260
|
+
let table = div.find('table');
|
|
259
261
|
table.find('thead,tfoot').addClass('hide');
|
|
260
|
-
|
|
262
|
+
let msgHtml = '<div class="text-'+cssClass+' center">'+msg+'</div>';
|
|
261
263
|
if (table.find('tbody').length == 0) {
|
|
262
264
|
table.append('<tbody></tbody>');
|
|
263
265
|
}
|
|
@@ -269,7 +271,7 @@ class DataTable {
|
|
|
269
271
|
}
|
|
270
272
|
|
|
271
273
|
static displayError(div, data, defaultMessage) {
|
|
272
|
-
|
|
274
|
+
let error = null;
|
|
273
275
|
if (data != null) {
|
|
274
276
|
if (typeof data.error != 'undefined') {
|
|
275
277
|
error = data.error;
|
|
@@ -286,9 +288,9 @@ class DataTable {
|
|
|
286
288
|
}
|
|
287
289
|
|
|
288
290
|
static getDefaultColumnsForDisplayedTable(div) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
291
|
+
let table = div.find('table');
|
|
292
|
+
let columns = [];
|
|
293
|
+
let defaultHiddenColumns = table.data('hidden_fields') != null ? table.data('hidden_fields').split(',') : [];
|
|
292
294
|
table.find('thead tr th').each(function(idx, th) {
|
|
293
295
|
if (defaultHiddenColumns.indexOf($(th).data('key')) == -1) {
|
|
294
296
|
columns.push($(th).data('key'));
|
|
@@ -300,12 +302,12 @@ class DataTable {
|
|
|
300
302
|
|
|
301
303
|
static setDataContent(div, data, displayLineCallback, completeCallback) {
|
|
302
304
|
//console.log('setDataContent');
|
|
303
|
-
|
|
305
|
+
let table = div.find('table').removeClass('hide');
|
|
304
306
|
|
|
305
307
|
try {
|
|
306
308
|
DataTable.resetContent(div);
|
|
307
|
-
|
|
308
|
-
for (
|
|
309
|
+
let tableBody = table.find('tbody');
|
|
310
|
+
for (let i = 0; i < data.length; i++) {
|
|
309
311
|
tableBody.append(displayLineCallback(data[i]));
|
|
310
312
|
}
|
|
311
313
|
|
|
@@ -339,7 +341,7 @@ class DataTable {
|
|
|
339
341
|
|
|
340
342
|
static initDataContent(div) {
|
|
341
343
|
//console.log('initDataContent');
|
|
342
|
-
|
|
344
|
+
let table = div.find('table');
|
|
343
345
|
|
|
344
346
|
// Popover/Tooltip
|
|
345
347
|
div.find('[data-toggle="popover"]').popover({'trigger':'hover', 'html':true});
|
|
@@ -355,16 +357,16 @@ class DataTable {
|
|
|
355
357
|
|
|
356
358
|
if (table.length > 0 && !table.is('[data-no_datatables="1"]') && !$.fn.dataTable.isDataTable(table)) {
|
|
357
359
|
if (table.data('page_length') != null) {
|
|
358
|
-
|
|
360
|
+
DataTable.getOptions()['pageLength'] = table.data('page_length');
|
|
359
361
|
}
|
|
360
|
-
table.DataTable(
|
|
362
|
+
table.DataTable(DataTable.getOptions());
|
|
361
363
|
}
|
|
362
364
|
|
|
363
365
|
DataTable.updateDataContent(div);
|
|
364
366
|
}
|
|
365
367
|
|
|
366
368
|
static updateDataContent(div) {
|
|
367
|
-
|
|
369
|
+
let table = div.find('table');
|
|
368
370
|
|
|
369
371
|
// Maj colonnes
|
|
370
372
|
if (table.length > 0 && typeof div.data('table_name') != 'undefined' && div.data('table_name') != null && div.data('display_items').split(',').indexOf('table_columns') != -1) {
|
|
@@ -372,7 +374,7 @@ class DataTable {
|
|
|
372
374
|
// table.find('.'+$(th).data('key')+':not(.select):not(.action)').hide();
|
|
373
375
|
table.find('.'+$(th).data('key')+':not(.select):not(.action)').addClass('hide');
|
|
374
376
|
});
|
|
375
|
-
|
|
377
|
+
let columns = this.getDisplayParam(div, 'html', null, 'columns').split(',').removeEmptyValues();
|
|
376
378
|
$.each(columns, function(idx, key) {
|
|
377
379
|
table.find('.'+key).removeClass('hide');
|
|
378
380
|
// table.find('.'+key).show();
|
|
@@ -391,7 +393,7 @@ class DataTable {
|
|
|
391
393
|
|
|
392
394
|
$.fn.dataTable.ext.search = [];
|
|
393
395
|
//$.fn.dataTable.ext.search.pop();
|
|
394
|
-
|
|
396
|
+
let dataTableObject = table.DataTable();
|
|
395
397
|
$.fn.dataTable.ext.search.push(
|
|
396
398
|
function(settings, searchData, index, rowData, counter) {
|
|
397
399
|
return callback($(dataTableObject.row(index).node()));
|
package/duration.js
CHANGED
|
@@ -21,7 +21,8 @@ class Duration {
|
|
|
21
21
|
minutes = Math.floor(minutes / 60);
|
|
22
22
|
// minutes = minutes - (minutes % 60);
|
|
23
23
|
let minCentieme = Math.round( (minutes / 60 ) * 100 );
|
|
24
|
-
return
|
|
24
|
+
return hour+(minCentieme/100);
|
|
25
|
+
//return parseFloat(hour+'.'+minCentieme);
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
static convertToDurationAsInputTimeValue(durationInSeconds) {
|
package/form_helper.js
CHANGED
|
@@ -161,33 +161,35 @@ class FormHelper {
|
|
|
161
161
|
//if ( $('[type="date"]').prop('type') != 'date' ) {
|
|
162
162
|
// $('[type="date"]').datepicker();
|
|
163
163
|
//}
|
|
164
|
-
if (
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
.
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
164
|
+
if (typeof Modernizr != 'undefined') {
|
|
165
|
+
if (!Modernizr.inputtypes.date) {
|
|
166
|
+
// $.fn.datepicker.defaults.language = 'fr';
|
|
167
|
+
// $.datepicker.setDefaults( $.datepicker.regional["fr"]);
|
|
168
|
+
form.find('input[type="date"]')
|
|
169
|
+
.css('max-width', '120px')
|
|
170
|
+
// 28/06/2021 : désactivation du datepicker car safari le gere en natif
|
|
171
|
+
/*
|
|
172
|
+
.datepicker({
|
|
173
|
+
dateFormat: 'yy-mm-dd',
|
|
174
|
+
changeMonth: true,
|
|
175
|
+
changeYear: true,
|
|
176
|
+
showOn: "both",
|
|
177
|
+
buttonImage: ROOT_PATH+'images/icons/calendar-alt.png',
|
|
178
|
+
buttonImageOnly: true,
|
|
179
|
+
})
|
|
180
|
+
*/
|
|
181
|
+
;
|
|
182
|
+
//form.find('input[type="date"]').datepicker({dateFormat: 'yy-mm-dd', minDate: "-10Y", maxDate: "+3Y"});
|
|
183
|
+
// $("#date_conf").datepicker("option", $.datepicker.regional["fr"]);
|
|
184
|
+
// $("#date_conf").datepicker("option", "dateFormat", "yy-mm-dd");
|
|
185
|
+
}
|
|
186
|
+
if (!Modernizr.inputtypes.time) {
|
|
187
|
+
form.find('input[type="time"]')
|
|
188
|
+
.css('max-width', '100px')
|
|
189
|
+
.attr('placeholder', 'hh:mm')
|
|
190
|
+
;
|
|
191
|
+
form.find('input[type="time"][step="1"]').attr('placeholder', 'hh:mm:ss');
|
|
192
|
+
}
|
|
191
193
|
}
|
|
192
194
|
|
|
193
195
|
// Show/Hide password
|
package/package.json
CHANGED
package/visitor.js
CHANGED
|
@@ -12,6 +12,7 @@ class Browser {
|
|
|
12
12
|
return !!window.chrome && !!window.chrome.webstore;
|
|
13
13
|
}
|
|
14
14
|
static isIE() {
|
|
15
|
+
//return window.navigator.userAgent.indexOf("MSIE ") > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./);
|
|
15
16
|
return /*@cc_on!@*/false || !!document.documentMode;
|
|
16
17
|
}
|
|
17
18
|
static isEdge() {
|