pui9-datatables 1.16.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.
Files changed (86) hide show
  1. package/README.md +24 -0
  2. package/dist/demo.html +10 -0
  3. package/dist/pui9-datatables.common.js +89206 -0
  4. package/dist/pui9-datatables.common.js.map +1 -0
  5. package/dist/pui9-datatables.css +5 -0
  6. package/dist/pui9-datatables.umd.js +89216 -0
  7. package/dist/pui9-datatables.umd.js.map +1 -0
  8. package/dist/pui9-datatables.umd.min.js +55 -0
  9. package/dist/pui9-datatables.umd.min.js.map +1 -0
  10. package/package-lock.json +15982 -0
  11. package/package.json +89 -0
  12. package/src/App.vue +37 -0
  13. package/src/components/desktop/PuiDatatable.vue +709 -0
  14. package/src/components/desktop/PuiQuickEditionDatatable.vue +548 -0
  15. package/src/components/desktop/PuiSimpleDatatable.vue +1498 -0
  16. package/src/components/desktop/datatables.net-plugins/pagination/input.js +213 -0
  17. package/src/components/desktop/footer/PuiDatatableFooter.vue +65 -0
  18. package/src/components/desktop/footer/PuiGridActionFooter.vue +132 -0
  19. package/src/components/desktop/quickedition/PuiQuickEditionExportBtn.vue +138 -0
  20. package/src/components/desktop/quickedition/PuiQuickEditionForm.vue +60 -0
  21. package/src/components/desktop/quickedition/PuiQuickEditionToolbar.vue +144 -0
  22. package/src/components/desktop/row/PuiGridRowActions.vue +112 -0
  23. package/src/components/desktop/subdialogs/PuiDatatableColumnMenu.vue +186 -0
  24. package/src/components/desktop/toolbar/PuiGridToolbar.vue +310 -0
  25. package/src/components/desktop/toolbar/actions/PuiGridActionListItem.vue +34 -0
  26. package/src/components/desktop/toolbar/actions/PuiGridActionsBtn.vue +56 -0
  27. package/src/components/desktop/toolbar/actions/PuiGridActionsDialog.vue +66 -0
  28. package/src/components/desktop/toolbar/actions/audit/PuiAuditDialog.vue +92 -0
  29. package/src/components/desktop/toolbar/actions/docgen/PuiDocgenTemplateMatchingsDialog.vue +139 -0
  30. package/src/components/desktop/toolbar/actions/docgen/PuiDocgenTemplateParametersDialog.vue +317 -0
  31. package/src/components/desktop/toolbar/actions/importexport/PuiGridExportDialog.vue +187 -0
  32. package/src/components/desktop/toolbar/actions/importexport/PuiGridImportDialog.vue +421 -0
  33. package/src/components/desktop/toolbar/export/PuiGridExportBtn.vue +175 -0
  34. package/src/components/desktop/toolbar/filtercombo/PuiGridFilterCombo.vue +237 -0
  35. package/src/components/desktop/toolbar/filtering/PuiGridFilterBtns.vue +163 -0
  36. package/src/components/desktop/toolbar/filtering/PuiGridFilterDialog.vue +434 -0
  37. package/src/components/desktop/toolbar/filtering/PuiGridFilterGroup.vue +313 -0
  38. package/src/components/desktop/toolbar/filtering/PuiGridFilterListBtn.vue +85 -0
  39. package/src/components/desktop/toolbar/filtering/PuiGridFilterListDialog.vue +254 -0
  40. package/src/components/desktop/toolbar/filtering/PuiGridFilterListItem.vue +192 -0
  41. package/src/components/desktop/toolbar/filtering/PuiGridFilterRule.vue +517 -0
  42. package/src/components/desktop/toolbar/grid-configuration/PuiGridConfBtns.vue +99 -0
  43. package/src/components/desktop/toolbar/grid-configuration/PuiGridConfDialog.vue +640 -0
  44. package/src/components/desktop/toolbar/grid-configuration/PuiSaveConfigDialog.vue +154 -0
  45. package/src/components/desktop/toolbar/row/PuiGridCreateBtn.vue +39 -0
  46. package/src/components/desktop/toolbar/row/PuiGridDeleteBtn.vue +86 -0
  47. package/src/components/desktop/toolbar/row/PuiGridRefreshBtn.vue +39 -0
  48. package/src/components/desktop/toolbar/row/PuiGridUpdateBtn.vue +56 -0
  49. package/src/components/desktop/toolbar/searching/PuiGridSearcher.vue +67 -0
  50. package/src/components/desktop/toolbar/searching/PuiGridSearcherColumnsList.vue +43 -0
  51. package/src/components/desktop/toolbar/sorting/PuiGridSortBtn.vue +44 -0
  52. package/src/components/desktop/toolbar/sorting/PuiGridSortDialog.vue +113 -0
  53. package/src/components/mobile/PuiDatalist.vue +477 -0
  54. package/src/components/mobile/PuiSimpleDatalist.vue +313 -0
  55. package/src/components/mobile/actions/PuiListActionListItem.vue +34 -0
  56. package/src/components/mobile/actions/PuiListActionsBtn.vue +38 -0
  57. package/src/components/mobile/actions/PuiListActionsDialog.vue +66 -0
  58. package/src/components/mobile/footer/PuiListActionFooter.vue +56 -0
  59. package/src/components/mobile/toolbar/PuiListToolbar.vue +60 -0
  60. package/src/components/mobile/toolbar/searching/PuiListSearcher.vue +53 -0
  61. package/src/components/mobile/toolbar/searching/PuiListSearcherColumnsList.vue +43 -0
  62. package/src/components/mobile/toolbar/sorting/PuiListSortBtn.vue +46 -0
  63. package/src/components/mobile/toolbar/sorting/PuiListSortDialog.vue +140 -0
  64. package/src/components/puiaudit/PuiAuditForm.vue +107 -0
  65. package/src/generalActions.js +135 -0
  66. package/src/index.js +31 -0
  67. package/src/main.js +67 -0
  68. package/src/mixins/PuiActionsBtnMixin.js +287 -0
  69. package/src/mixins/PuiActionsDialogMixin.js +161 -0
  70. package/src/mixins/PuiActionsListItemMixin.js +62 -0
  71. package/src/mixins/PuiDatatablesKeepPage.js +15 -0
  72. package/src/mixins/PuiGridFormMethodsMixin.js +133 -0
  73. package/src/mixins/PuiModelConfigurationMixin.js +15 -0
  74. package/src/mixins/PuiSearcherColumnsListMixin.js +108 -0
  75. package/src/mixins/PuiSearcherMixin.js +192 -0
  76. package/src/mixins/PuiSortBtnMixin.js +54 -0
  77. package/src/mixins/PuiSortDialogMixin.js +256 -0
  78. package/src/mixins/PuiToolbarBtnMixin.js +66 -0
  79. package/src/mixins/PuiToolbarDialogMixin.js +12 -0
  80. package/src/router.js +18 -0
  81. package/src/tests/PuiContainer.vue +139 -0
  82. package/src/tests/PuiProfileTestSimpleDatatable.vue +66 -0
  83. package/src/tests/PuiUserTestCompleteDatatable.vue +126 -0
  84. package/src/tests/PuiVariableTestQuickEditionDatatable.vue +39 -0
  85. package/src/tests/PuiVariableTestQuickEditionForm.vue +18 -0
  86. package/src/tests/modelConfigurations.json +3516 -0
@@ -0,0 +1,709 @@
1
+ <template>
2
+ <div row wrap :class="puiCompleteDatatableClass" ref="grid" v-if="showTemplate">
3
+ <pui-grid-toolbar
4
+ v-if="showToolbar && ready"
5
+ :columns="columns"
6
+ :modelName="modelName"
7
+ :modelNameSuffix="modelNameSuffix"
8
+ :actions="actions"
9
+ :searcherShowOnlyVisibleColumns="searcherShowOnlyVisibleColumns"
10
+ :groupedColumn="groupedColumn"
11
+ :masterDetail="masterDetail"
12
+ :readOnly="readOnly"
13
+ :showActionsBtn="showActionsBtn"
14
+ :showExportsBtn="showExportsBtn"
15
+ :showCreateBtn="showCreateBtn"
16
+ :showUpdateBtn="showUpdateBtn"
17
+ :showDeleteBtn="showDeleteBtn"
18
+ :showRefreshBtn="showRefreshBtn"
19
+ :showFilterListBtn="showFilterListBtn"
20
+ :showFilterBtn="showFilterBtn"
21
+ :showSortBtn="showSortBtn"
22
+ :showConfBtn="showConfBtn"
23
+ :showSearcher="showSearcher"
24
+ :showMasterDetailFilterListBtn="showMasterDetailFilterListBtn"
25
+ :showMasterDetailFilterBtn="showMasterDetailFilterBtn"
26
+ :showMasterDetailSortBtn="showMasterDetailSortBtn"
27
+ :showMasterDetailConfBtn="showMasterDetailConfBtn"
28
+ :showFilterComboSelect="filterCombo"
29
+ ></pui-grid-toolbar>
30
+ <pui-simple-datatable
31
+ v-if="ready"
32
+ :class="puiCompleteDatatableClass + '__table'"
33
+ ref="table"
34
+ :modelName="modelName"
35
+ :modelNameSuffix="modelNameSuffix"
36
+ :columns="columns"
37
+ :info="info"
38
+ :lengthMenu="lengthMenu"
39
+ :pageLength="pageLength"
40
+ :search="search"
41
+ :select="select"
42
+ :multiselect="multiselect"
43
+ :tableMaxHeight="tableMaxHeight"
44
+ :showPaginator="showPaginator"
45
+ :scrollX="scrollX"
46
+ :scrollY="scrollY"
47
+ :scrollCollapse="scrollCollapse"
48
+ :externalSearch="currentSearch"
49
+ :externalFilter="getCurrentFilter()"
50
+ :modelColumnDefs="columnDefs"
51
+ :masterDetail="masterDetail"
52
+ :navigableDetail="navigableDetail"
53
+ :parentModelName="parentModelName"
54
+ :isEditableRegistry="isEditableRegistry"
55
+ :showRowActions="showRowActions"
56
+ :readOnly="readOnly"
57
+ :defaultActionRead="defaultActionRead"
58
+ :modalDialog="modalDialog"
59
+ :selectStyle="selectStyle"
60
+ ></pui-simple-datatable>
61
+ </div>
62
+ </template>
63
+
64
+ <script>
65
+ import PuiModelConfigurationMixin from '../../mixins/PuiModelConfigurationMixin';
66
+ import PuiGridToolbar from './toolbar/PuiGridToolbar';
67
+ import PuiSimpleDatatable from './PuiSimpleDatatable';
68
+
69
+ export default {
70
+ name: 'PuiDatatable',
71
+ mixins: [PuiModelConfigurationMixin],
72
+ components: {
73
+ PuiGridToolbar,
74
+ PuiSimpleDatatable
75
+ },
76
+ data() {
77
+ return {
78
+ scrolling: 0,
79
+ columns: [],
80
+ gridConfiguration: null,
81
+ ready: false,
82
+ model: null,
83
+ filtering: null,
84
+ currentSearch: null,
85
+ currentFilterCombo: null,
86
+ isMenuExpaded: false,
87
+ showTemplate: false,
88
+ refreshTimeout: null,
89
+ topicPreffix: '/topic/model/'
90
+ };
91
+ },
92
+ props: {
93
+ info: {
94
+ type: Boolean,
95
+ default: true
96
+ },
97
+ lengthMenu: {
98
+ type: [Array],
99
+ default: () => [10, 20, 30, 50, 100]
100
+ },
101
+ modelName: {
102
+ type: String,
103
+ required: true
104
+ },
105
+ modelNameSuffix: {
106
+ type: String,
107
+ default: ''
108
+ },
109
+ pageLength: {
110
+ type: Number
111
+ },
112
+ search: {
113
+ type: Boolean,
114
+ default: false
115
+ },
116
+ select: {
117
+ type: [Boolean],
118
+ default: true
119
+ },
120
+ multiselect: {
121
+ type: [Boolean],
122
+ default: false
123
+ },
124
+ tableMaxHeight: {
125
+ type: Number,
126
+ default: 70
127
+ },
128
+ readOnly: {
129
+ type: Boolean,
130
+ default: false
131
+ },
132
+ defaultActionRead: {
133
+ type: Boolean,
134
+ default: false
135
+ },
136
+ showPaginator: {
137
+ type: Boolean,
138
+ default: true
139
+ },
140
+ scrollX: {
141
+ type: Boolean,
142
+ default: true
143
+ },
144
+ scrollY: {
145
+ type: [Boolean, String],
146
+ default: true
147
+ },
148
+ scrollCollapse: {
149
+ type: Boolean,
150
+ default: false
151
+ },
152
+ showToolbar: {
153
+ type: Boolean,
154
+ default: true
155
+ },
156
+ actions: {
157
+ type: Array,
158
+ default: () => {
159
+ return [];
160
+ }
161
+ },
162
+ searcherShowOnlyVisibleColumns: {
163
+ type: Boolean,
164
+ default: true
165
+ },
166
+ externalFilter: {
167
+ type: Object
168
+ },
169
+ masterDetail: {
170
+ type: Boolean,
171
+ default: false
172
+ },
173
+ navigableDetail: {
174
+ type: Boolean,
175
+ default: true
176
+ },
177
+ masterDetailColumnVisibles: {
178
+ Object: Object
179
+ },
180
+ parentModelName: {
181
+ type: String,
182
+ default: null
183
+ },
184
+ isEditableRegistry: {
185
+ type: Function,
186
+ default: () => {
187
+ return true;
188
+ }
189
+ },
190
+ showRowActions: {
191
+ type: Boolean,
192
+ default: true
193
+ },
194
+ modelColumnDefs: {
195
+ type: Object
196
+ },
197
+ showActionsBtn: {
198
+ type: Boolean,
199
+ default: true
200
+ },
201
+ showExportsBtn: {
202
+ type: Boolean,
203
+ default: true
204
+ },
205
+ showCreateBtn: {
206
+ type: Boolean,
207
+ default: true
208
+ },
209
+ showUpdateBtn: {
210
+ type: Boolean,
211
+ default: true
212
+ },
213
+ showDeleteBtn: {
214
+ type: Boolean,
215
+ default: true
216
+ },
217
+ showRefreshBtn: {
218
+ type: Boolean,
219
+ default: true
220
+ },
221
+ showFilterListBtn: {
222
+ type: Boolean,
223
+ default: true
224
+ },
225
+ showFilterBtn: {
226
+ type: Boolean,
227
+ default: true
228
+ },
229
+ showSortBtn: {
230
+ type: Boolean,
231
+ default: true
232
+ },
233
+ showConfBtn: {
234
+ type: Boolean,
235
+ default: true
236
+ },
237
+ showSearcher: {
238
+ type: Boolean,
239
+ default: true
240
+ },
241
+ showMasterDetailFilterListBtn: {
242
+ type: Boolean,
243
+ default: false
244
+ },
245
+ showMasterDetailFilterBtn: {
246
+ type: Boolean,
247
+ default: false
248
+ },
249
+ showMasterDetailSortBtn: {
250
+ type: Boolean,
251
+ default: false
252
+ },
253
+ showMasterDetailConfBtn: {
254
+ type: Boolean,
255
+ default: false
256
+ },
257
+ modalDialog: {
258
+ type: Boolean,
259
+ default: false
260
+ },
261
+ selectStyle: {
262
+ type: String,
263
+ default: 'single'
264
+ },
265
+ filterCombo: {
266
+ type: Boolean,
267
+ default: true
268
+ }
269
+ },
270
+ computed: {
271
+ puiCompleteDatatableClass() {
272
+ return 'pui-completeDatatable' + (this.$store.getters.isMobile ? '_mobile' : !this.masterDetail ? '_desktop' : '_desktop_detail');
273
+ },
274
+ onPuiModelsLoadedAndSaved() {
275
+ return this.$store.state.modelsLoadedAndSaved;
276
+ },
277
+ onPuiExpandMenu() {
278
+ return this.$store.state.menu.expandMenuForce;
279
+ },
280
+ onPuiSecondMenuShowed() {
281
+ return this.$store.state.menu.secondMenuShowedForce;
282
+ }
283
+ },
284
+ watch: {
285
+ onPuiModelsLoadedAndSaved() {
286
+ this.model = this.$store.getters.getModelByName(this.modelName);
287
+ this.onReady();
288
+ },
289
+ onPuiExpandMenu() {
290
+ this.onMenuExpandedShowed(this.$store.state.menu.expandMenu);
291
+ },
292
+ onPuiSecondMenuShowed() {
293
+ this.onMenuExpandedShowed(this.$store.state.menu.secondMenuShowed);
294
+ }
295
+ },
296
+ mounted() {
297
+ this.model = this.$store.getters.getModelByName(this.modelName);
298
+ if (this.model) {
299
+ this.onReady();
300
+ }
301
+ this.subscribeToToolbarEvents();
302
+
303
+ if (this.$store.getters.webSocketsEnabled) {
304
+ var self = this;
305
+ // wait until websocket connection established
306
+ setTimeout(function() {
307
+ self.$puiWebSockets.subscribe(self.$store.getters.getUser, self.topicPreffix + self.modelName, () => {
308
+ self.$refs.table.reloadGrid(self.gridConfiguration.configuration, self.columnDefs);
309
+ });
310
+ }, 250);
311
+ }
312
+ },
313
+ beforeDestroy() {
314
+ if (this.refreshTimeout) {
315
+ clearTimeout(this.refreshTimeout);
316
+ }
317
+
318
+ if (this.$store.getters.webSocketsEnabled) {
319
+ this.$puiWebSockets.unsubscribe(this.$store.getters.getUser, this.topicPreffix + this.modelName);
320
+ }
321
+ },
322
+ destroyed() {
323
+ this.$puiEvents.$off(`onPui-apply-edit-${this.modelName}${this.modelNameSuffix}`);
324
+ this.$puiEvents.$off(`onPui-apply-delete-${this.modelName}${this.modelNameSuffix}`);
325
+ if (this.filterCombo) {
326
+ this.$puiEvents.$off(`onPui-apply-filtercombo-${this.modelName}${this.modelNameSuffix}`);
327
+ }
328
+ this.$puiEvents.$off(`onPui-apply-filtering-${this.modelName}${this.modelNameSuffix}`);
329
+ this.$puiEvents.$off(`onPui-apply-searching-${this.modelName}${this.modelNameSuffix}`);
330
+ this.$puiEvents.$off(`onPui-apply-sorting-${this.modelName}${this.modelNameSuffix}`);
331
+ this.$puiEvents.$off(`onPui-apply-configuration-${this.modelName}${this.modelNameSuffix}`);
332
+ this.$puiEvents.$off(`onPui-created-dataTable-${this.modelName}${this.modelNameSuffix}`);
333
+ this.$puiEvents.$off(`onPui-active-toolbarBtn-${this.modelName}`);
334
+ this.$puiEvents.$off(`onPui-inactive-toolbarBtn-${this.modelName}`);
335
+ this.$puiEvents.$off(`onPui-action-before-running-${this.modelName}${this.modelNameSuffix}`);
336
+ this.$puiEvents.$off(`onPui-action-running-ended-${this.modelName}${this.modelNameSuffix}`);
337
+ this.$puiEvents.$off(`onPui-action-running-cancelled-${this.modelName}${this.modelNameSuffix}`);
338
+ },
339
+ methods: {
340
+ setColumnsAndGridConfigurationForDatatable(loadDefaultConfiguration, loadCurrentConfiguration) {
341
+ this.columns = [];
342
+ this.columnDefs = [];
343
+ this.customColumnDefs = [];
344
+ this.dateColumnIndexes = [];
345
+ this.dateTimeColumnIndexes = [];
346
+ this.decimalColumnIndexes = [];
347
+ // Get the current configuration
348
+ if (loadCurrentConfiguration) {
349
+ const currentConfig = this.$store.getters.getCurrentGridConfiguration(this.modelName);
350
+ if (currentConfig) {
351
+ this.gridConfiguration = this.cloneConfiguration(currentConfig);
352
+ }
353
+ } else if (loadDefaultConfiguration) {
354
+ // Or load the default
355
+ const defaultConfig = this.$store.getters.getDefaultGridConfiguration(this.modelName);
356
+ if (defaultConfig) {
357
+ this.gridConfiguration = this.cloneConfiguration(defaultConfig);
358
+ this.$store.commit('puiModelsSetCurrentGridConfiguration', { model: this.modelName, configuration: this.gridConfiguration });
359
+ }
360
+ }
361
+
362
+ // If there is no configuration (first time in the grid) a new one should be created to work with on runtime
363
+ if (!this.gridConfiguration || this.gridConfiguration === -1) {
364
+ this.gridConfiguration = {
365
+ model: this.modelName,
366
+ usr: this.$store.getters.getUser,
367
+ configuration: {
368
+ grouped: false,
369
+ columnSearch: false
370
+ }
371
+ };
372
+ let hiddenColsCounter = 0;
373
+ this.model.columns.forEach((colObj, index) => {
374
+ if (this.masterDetailColumnVisibles) {
375
+ if (this.masterDetailColumnVisibles[colObj.name]) {
376
+ this.setCustomColumnDefs(colObj.name, colObj.type, index + 1 - hiddenColsCounter);
377
+
378
+ this.columns.push({
379
+ order: colObj.order || index,
380
+ title: this.$parent.$t(colObj.title),
381
+ name: colObj.name,
382
+ data: colObj.name,
383
+ visible: true,
384
+ type: colObj.type,
385
+ orderable: true
386
+ });
387
+ } else {
388
+ hiddenColsCounter++;
389
+ }
390
+ } else {
391
+ if (colObj.visibility !== 'completelyhidden') {
392
+ this.setCustomColumnDefs(colObj.name, colObj.type, index + 1 - hiddenColsCounter);
393
+
394
+ this.columns.push({
395
+ order: colObj.order || index,
396
+ title: this.$parent.$t(colObj.title),
397
+ name: colObj.name,
398
+ data: colObj.name,
399
+ visible: colObj.visibility === 'visible',
400
+ type: colObj.type,
401
+ orderable: true
402
+ });
403
+ } else {
404
+ hiddenColsCounter++;
405
+ }
406
+ }
407
+ });
408
+ } else {
409
+ this.gridConfiguration = this.cloneConfiguration(this.gridConfiguration);
410
+ this.avoidOrder = this.gridConfiguration.configuration.order !== undefined;
411
+ this.gridConfiguration.configuration.columns
412
+ .sort((a, b) => {
413
+ return a.order - b.order;
414
+ })
415
+ .forEach((colObj, index) => {
416
+ delete colObj.bVisible;
417
+ this.setCustomColumnDefs(colObj.name, colObj.type, index + 1);
418
+
419
+ let colExist = false;
420
+ this.model.columns.forEach((colObj2) => {
421
+ if (colObj.name === colObj2.name) {
422
+ colExist = true;
423
+ colObj.title = colObj2.title;
424
+ colObj.type = colObj2.type;
425
+ }
426
+ });
427
+
428
+ if (colExist) {
429
+ colObj.title = this.$parent.$t(colObj.title);
430
+ this.columns.push({
431
+ order: colObj.order || index,
432
+ title: colObj.title,
433
+ name: colObj.name,
434
+ data: colObj.name,
435
+ visible: colObj.visible,
436
+ type: colObj.type,
437
+ orderable: true
438
+ });
439
+ }
440
+ });
441
+ }
442
+ this.groupedColumn = this.gridConfiguration.configuration.grouped;
443
+ this.setColumnDefs();
444
+ },
445
+ setCustomColumnDefs(columnName, columnType, index) {
446
+ if (this.modelColumnDefs && this.modelColumnDefs[columnName]) {
447
+ let hasCustomColumnDef = false;
448
+ const columnDef = { targets: [index] };
449
+ if (this.modelColumnDefs[columnName].render) {
450
+ hasCustomColumnDef = true;
451
+ columnDef.render = this.modelColumnDefs[columnName].render;
452
+ }
453
+ if (this.modelColumnDefs[columnName].createdCell) {
454
+ hasCustomColumnDef = true;
455
+ columnDef.createdCell = this.modelColumnDefs[columnName].createdCell;
456
+ }
457
+ if (hasCustomColumnDef) {
458
+ this.customColumnDefs.push(columnDef);
459
+ } else if (columnType === 'date' || columnType === 'datetime') {
460
+ if (this.modelColumnDefs[columnName].withoutHours) {
461
+ this.dateColumnIndexes.push(index);
462
+ } else {
463
+ this.dateTimeColumnIndexes.push(index);
464
+ }
465
+ } else if (columnType === 'decimal') {
466
+ this.decimalColumnIndexes.push(index);
467
+ }
468
+ } else {
469
+ if (columnType === 'date' || columnType === 'datetime') {
470
+ this.dateTimeColumnIndexes.push(index);
471
+ } else if (columnType === 'decimal') {
472
+ this.decimalColumnIndexes.push(index);
473
+ }
474
+ }
475
+ },
476
+ setColumnDefs() {
477
+ this.dateFormat = this.$store.getters.dateFormat;
478
+ this.timeFormat = this.$store.getters.timeFormat;
479
+ this.thousandSeparator = this.$store.getters.thousandSeparator;
480
+ this.decimalSeparator = this.$store.getters.decimalSeparator;
481
+
482
+ const dateColumnDefs = {
483
+ targets: this.dateColumnIndexes,
484
+ render: (val) => {
485
+ if (val === null) {
486
+ return '';
487
+ }
488
+ return this.$dateTimeUtils.getLocalFormattedDate(val, `${this.dateFormat}`);
489
+ }
490
+ };
491
+
492
+ const dateTimeColumnDefs = {
493
+ targets: this.dateTimeColumnIndexes,
494
+ render: (val) => {
495
+ if (val === null) {
496
+ return '';
497
+ }
498
+ return this.$dateTimeUtils.getLocalFormattedDate(val, `${this.dateFormat} ${this.timeFormat}`);
499
+ }
500
+ };
501
+
502
+ const decimalColumnDefs = {
503
+ targets: this.decimalColumnIndexes,
504
+ render: (val) => {
505
+ if (val === null) {
506
+ return '';
507
+ }
508
+ if (val.toString().includes('.')) {
509
+ const parts = val.toString().split('.');
510
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandSeparator);
511
+ return parts.join(this.decimalSeparator);
512
+ }
513
+ return val.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, `$1${this.thousandSeparator}`);
514
+ }
515
+ };
516
+
517
+ this.columnDefs.push(dateColumnDefs);
518
+ this.columnDefs.push(dateTimeColumnDefs);
519
+ this.columnDefs.push(decimalColumnDefs);
520
+ this.columnDefs.push(...this.customColumnDefs);
521
+ },
522
+ shouldCreateToolbar() {
523
+ return this.modelName && this.columns.length > 0;
524
+ },
525
+ subscribeToToolbarEvents() {
526
+ this.$puiEvents.$on(`onPui-apply-edit-${this.modelName}${this.modelNameSuffix}`, (data) => {
527
+ this.$refs.table.editRegistry(data.row, data.method);
528
+ });
529
+ this.$puiEvents.$on(`onPui-apply-delete-${this.modelName}${this.modelNameSuffix}`, (row) => {
530
+ this.$refs.table.deleteRegistry(row);
531
+ });
532
+ if (this.filterCombo) {
533
+ this.$puiEvents.$on(`onPui-apply-filtercombo-${this.modelName}${this.modelNameSuffix}`, (filteringObject) => {
534
+ this.currentFilterCombo = filteringObject;
535
+ this.currentFilter = this.getCurrentFilter();
536
+ this.$refs.table.applyFilter(this.currentFilter);
537
+ });
538
+ }
539
+ this.$puiEvents.$on(`onPui-apply-filtering-${this.modelName}${this.modelNameSuffix}`, (filteringObject) => {
540
+ this.filtering = filteringObject;
541
+ this.currentFilter = this.getCurrentFilter();
542
+ this.$refs.table.applyFilter(this.currentFilter);
543
+ });
544
+ this.$puiEvents.$on(`onPui-apply-sorting-${this.modelName}${this.modelNameSuffix}`, (sortingRules) => {
545
+ this.currentSorting = sortingRules;
546
+ this.$refs.table.applySort(sortingRules, true);
547
+ });
548
+ this.$puiEvents.$on(`onPui-apply-searching-${this.modelName}${this.modelNameSuffix}`, (columnsAndElement) => {
549
+ this.currentSearch = columnsAndElement;
550
+ const text = columnsAndElement[0];
551
+ const columns = columnsAndElement[1];
552
+ this.$refs.table.applySearch(text, columns);
553
+ });
554
+ this.$puiEvents.$on(`onPui-apply-configuration-${this.modelName}${this.modelNameSuffix}`, (config) => {
555
+ this.gridConfiguration.configuration = config;
556
+ this.setColumnsAndGridConfigurationForDatatable(false, false);
557
+ this.$refs.table.reloadGrid(this.gridConfiguration.configuration, this.columnDefs);
558
+ });
559
+ this.$puiEvents.$on(`onPui-active-toolbarBtn-${this.modelName}`, (idTool) => {
560
+ if (idTool === 'actions' && this.refreshTimeout) {
561
+ clearTimeout(this.refreshTimeout);
562
+ this.refreshTimeout = null;
563
+ }
564
+ });
565
+ this.$puiEvents.$on(`onPui-inactive-toolbarBtn-${this.modelName}`, (idTool) => {
566
+ if (idTool === 'actions' && !this.actionRunning) {
567
+ if (this.model.defaultConfiguration.refreshSeconds && !this.refreshTimeout) {
568
+ this.refreshAutomatically(this.model.defaultConfiguration.refreshSeconds);
569
+ }
570
+ }
571
+ });
572
+ this.$puiEvents.$on(`onPui-action-before-running-${this.modelName}${this.modelNameSuffix}`, () => {
573
+ this.actionRunning = true;
574
+ if (this.refreshTimeout) {
575
+ clearTimeout(this.refreshTimeout);
576
+ this.refreshTimeout = null;
577
+ }
578
+ });
579
+ this.$puiEvents.$on(`onPui-action-running-ended-${this.modelName}${this.modelNameSuffix}`, () => {
580
+ this.actionRunning = false;
581
+ if (this.model.defaultConfiguration.refreshSeconds && !this.refreshTimeout) {
582
+ this.refreshAutomatically(this.model.defaultConfiguration.refreshSeconds);
583
+ }
584
+ });
585
+ this.$puiEvents.$on(`onPui-action-running-cancelled-${this.modelName}${this.modelNameSuffix}`, () => {
586
+ this.actionRunning = false;
587
+ if (this.model.defaultConfiguration.refreshSeconds && !this.refreshTimeout) {
588
+ this.refreshAutomatically(this.model.defaultConfiguration.refreshSeconds);
589
+ }
590
+ });
591
+ },
592
+ onMenuExpandedShowed(expanded) {
593
+ const className = `${this.puiCompleteDatatableClass}--compressed`;
594
+ if (expanded === true) {
595
+ this.$refs.grid && this.$refs.grid.classList && this.$refs.grid.classList.add(className);
596
+ } else {
597
+ this.$refs.grid && this.$refs.grid.classList && this.$refs.grid.classList.remove(className);
598
+ }
599
+ },
600
+ getCurrentFilter() {
601
+ const filter = { groupOp: 'and', groups: [], rules: [] };
602
+ if (this.filterCombo && this.currentFilterCombo) {
603
+ filter.groups.push(this.currentFilterCombo);
604
+ }
605
+ if (!this.masterDetail && this.filtering) {
606
+ filter.groups.push(this.filtering);
607
+ }
608
+ if (this.externalFilter) {
609
+ filter.groups.push(this.externalFilter);
610
+ }
611
+ return filter;
612
+ },
613
+ getCurrentSorting() {
614
+ if (this.$refs.table.order) {
615
+ this.currentSorting = this.$refs.table.order;
616
+ }
617
+ return this.currentSorting;
618
+ },
619
+ getCurrentSearch() {
620
+ return this.currentSearch;
621
+ },
622
+ onReady() {
623
+ this.$emit('ready');
624
+
625
+ if (this.$store.getters.hasFunctionality(this.model.functionalities.list)) {
626
+ this.$puiEvents.$on(`onPui-created-dataTable-${this.modelName}${this.modelNameSuffix}`, this.onMenuExpandedShowed);
627
+
628
+ if (this.masterDetailColumnVisibles) {
629
+ this.setColumnsAndGridConfigurationForDatatable(false, false);
630
+ } else if (!this.$store.getters.gridIsInitialized(this.modelName)) {
631
+ this.setColumnsAndGridConfigurationForDatatable(true, false);
632
+ } else {
633
+ // If the grid was created and we are coming back
634
+ this.setColumnsAndGridConfigurationForDatatable(false, true);
635
+ }
636
+ this.beforeCreateDatatable();
637
+ // Create the datatable
638
+ this.ready = true;
639
+ this.showTemplate = true;
640
+ } else {
641
+ this.$store.dispatch('puiRequestShowServerError', { error: { response: { status: 403 } } });
642
+ this.$store.dispatch('puiRouterGoToDefaultEntryPage', this.$router);
643
+ }
644
+ },
645
+ beforeCreateDatatable() {
646
+ if (this.model.searcher) {
647
+ // apply searchText & searchColumns from model store
648
+ this.currentSearch = [this.model.searcher.searchText, this.model.searcher.searchingColumns];
649
+ }
650
+ if (this.filterCombo && this.model.currentFilterCombo) {
651
+ // apply filter combo from model store
652
+ this.currentFilterCombo = this.model.currentFilterCombo;
653
+ }
654
+ if (this.model.currentFilter && this.model.currentFilter.filter && this.model.currentFilter.checked) {
655
+ // apply filter user from model store
656
+ this.filtering = this.model.currentFilter.filter;
657
+ }
658
+ if (this.model.defaultConfiguration.refreshSeconds) {
659
+ this.refreshAutomatically(this.model.defaultConfiguration.refreshSeconds);
660
+ }
661
+ },
662
+ refreshAutomatically(seconds) {
663
+ const milliseconds = seconds * 1000;
664
+ this.refreshTimeout = setTimeout(() => {
665
+ this.$refs.table.reloadGrid(this.gridConfiguration.configuration, this.columnDefs);
666
+ this.refreshAutomatically(seconds);
667
+ }, milliseconds);
668
+ }
669
+ }
670
+ };
671
+ </script>
672
+
673
+ <style lang="postcss">
674
+ .pui-completeDatatable {
675
+ display: grid;
676
+ grid-template-rows: auto 1fr;
677
+ width: 100%;
678
+ &_desktop .bottom {
679
+ position: fixed;
680
+ bottom: 5px;
681
+ width: 92%;
682
+ padding-left: 8px;
683
+ padding-right: 20px;
684
+ & .left {
685
+ float: left;
686
+ }
687
+ & .right {
688
+ float: right;
689
+ }
690
+ }
691
+ &_desktop_detail .bottom {
692
+ & .left {
693
+ float: left;
694
+ }
695
+ & .right {
696
+ float: right;
697
+ }
698
+ }
699
+ &_desktop--compressed .bottom {
700
+ width: calc(92% - 304px);
701
+ }
702
+ &_mobile .bottom .left {
703
+ float: none !important;
704
+ }
705
+ &_mobile .bottom .right {
706
+ float: none !important;
707
+ }
708
+ }
709
+ </style>