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,237 @@
1
+ <template>
2
+ <v-layout justify-end @click="changeState()">
3
+ <pui-select
4
+ v-for="filterConfig in filterCombo"
5
+ :key="filterConfig.id"
6
+ toplabel
7
+ noeditable
8
+ clearable
9
+ hideDetails
10
+ v-model="gridFilterModel"
11
+ :id="filterConfig.id"
12
+ :attach="filterConfig.id"
13
+ :modelName="getModelNameByConfig(filterConfig)"
14
+ :itemsToSelect="getItemsToSelect(filterConfig)"
15
+ :modelFormMapping="getModelFormMapping(filterConfig)"
16
+ :itemValue="filterConfig.search.value"
17
+ :itemText="filterConfig.search.text"
18
+ :placeholder="getPlaceHolder(filterConfig)"
19
+ :filterId="getFilterId(filterConfig)"
20
+ :filterMap="getFilterMap(filterConfig)"
21
+ :filterParentMap="getFilterParentMap(filterConfig)"
22
+ :order="filterConfig.search.order"
23
+ :style="getFilterComboStyles(filterConfig)"
24
+ ></pui-select>
25
+ </v-layout>
26
+ </template>
27
+
28
+ <script>
29
+ import PuiToolbarBtnMixin from '../../../../mixins/PuiToolbarBtnMixin';
30
+
31
+ export default {
32
+ name: 'PuiGridFilterCombo',
33
+ mixins: [PuiToolbarBtnMixin],
34
+ data() {
35
+ return {
36
+ idTool: 'gridfiltercombo',
37
+ gridFilterProperties: [],
38
+ gridFilterModel: {},
39
+ gridFilterName: null,
40
+ propertiesArray: null
41
+ };
42
+ },
43
+ props: {
44
+ modelName: {
45
+ type: String,
46
+ required: true
47
+ },
48
+ filterCombo: {
49
+ type: Array,
50
+ required: true
51
+ }
52
+ },
53
+ created() {
54
+ this.model = this.$store.getters.getModelByName(this.modelName);
55
+
56
+ this.fillGridFilterModelFromStore();
57
+ this.subscribeToGridFilterModelChanges();
58
+ },
59
+ beforeDestroy() {
60
+ for (let i = 0, length = this.filterCombo.length; i < length; i++) {
61
+ const fieldName = this.filterCombo[i].id;
62
+ this.$puiEvents.$off(`onPuiSelect_selectedItems-${fieldName}`);
63
+ }
64
+ },
65
+ computed: {
66
+ getFilterMap() {
67
+ return (config) => {
68
+ let filterMap = null;
69
+ const columnValue = config.relatedCombo && config.relatedCombo.id;
70
+ const searchColumnName = config.search.related;
71
+ if (columnValue && searchColumnName) {
72
+ filterMap = {};
73
+ filterMap[searchColumnName] = this.gridFilterModel[columnValue];
74
+ filterMap = Object.assign({}, filterMap);
75
+ }
76
+ return filterMap;
77
+ };
78
+ },
79
+ getFilterParentMap() {
80
+ return (config) => {
81
+ let filterParentMap = null;
82
+ const searchColumnName = config.search.related;
83
+ const relatedColumnName = config.relatedCombo && config.relatedCombo.toColumn;
84
+ if (searchColumnName && relatedColumnName) {
85
+ filterParentMap = {};
86
+ filterParentMap[searchColumnName] = relatedColumnName;
87
+ filterParentMap = Object.assign({}, filterParentMap);
88
+ }
89
+ return filterParentMap;
90
+ };
91
+ }
92
+ },
93
+ methods: {
94
+ getModelNameByConfig(config) {
95
+ return config.search.model;
96
+ },
97
+ getItemsToSelect(config) {
98
+ const item = {};
99
+ if (!Array.isArray(config.search.value)) {
100
+ item[config.search.value] = this.gridFilterModel[config.local.value];
101
+ } else {
102
+ for (let i = 0, length = config.search.value.length; i < length; i++) {
103
+ item[config.search.value[i]] = this.gridFilterModel[config.local.value[i]];
104
+ }
105
+ }
106
+ return [item];
107
+ },
108
+ getModelFormMapping(config) {
109
+ const item = {};
110
+ if (!Array.isArray(config.search.value)) {
111
+ item[config.search.value] = config.local.value;
112
+ } else {
113
+ for (let i = 0, length = config.search.value.length; i < length; i++) {
114
+ item[config.search.value[i]] = config.local.value[i];
115
+ }
116
+ }
117
+ return item;
118
+ },
119
+ getPlaceHolder(config) {
120
+ return this.$t('filtercombo' + '.' + config.id);
121
+ },
122
+ getFilterId(config) {
123
+ return config.relatedCombo && config.relatedCombo.id;
124
+ },
125
+ /*
126
+ * Fill the gridFilterModel for each filterCombo.
127
+ * Only if not exist the gridFilterComboModel in the store,
128
+ * save gridFilterModel with null values in filterCombo.filterComboModel variable.
129
+ */
130
+ fillGridFilterModelFromStore() {
131
+ for (let i = 0, length = this.filterCombo.length; i < length; i++) {
132
+ if (!Array.isArray(this.filterCombo[i].local.value)) {
133
+ this.gridFilterProperties.push(this.filterCombo[i].local.value);
134
+ this.gridFilterModel[this.filterCombo[i].local.value] = null;
135
+ } else {
136
+ for (let j = 0; j < this.filterCombo[i].local.value.length; j++) {
137
+ this.gridFilterProperties.push(this.filterCombo[i].local.value[j]);
138
+ this.gridFilterModel[this.filterCombo[i].local.value[j]] = null;
139
+ }
140
+ }
141
+ if (this.gridFilterName === null) {
142
+ this.gridFilterName = this.filterCombo[i].search.model;
143
+ } else {
144
+ if (!this.$store.getters.isMobile) {
145
+ this.gridFilterName += '_' + this.filterCombo[i].search.model;
146
+ }
147
+ }
148
+ }
149
+
150
+ this.gridFilterModel = Object.assign({}, this.gridFilterModel);
151
+
152
+ const gridFilterComboModel = this.$store.getters.getGridFilterComboModelByName(this.gridFilterName);
153
+ if (gridFilterComboModel) {
154
+ this.gridFilterModel = Object.assign({}, gridFilterComboModel);
155
+ }
156
+ },
157
+ /*
158
+ * Subscribe to PuiSelect changes for each filterCombo.
159
+ * When PuiSelect changes:
160
+ * - save gridFilterComboModel in store,
161
+ * - create PUI9 filter from gridFilterModel and
162
+ * - publish PUI9 filter for grid reloading
163
+ */
164
+ subscribeToGridFilterModelChanges() {
165
+ for (let i = 0, length = this.filterCombo.length; i < length; i++) {
166
+ const fieldName = this.filterCombo[i].id;
167
+
168
+ this.$puiEvents.$off(`onPuiSelect_selectedItems-${fieldName}`);
169
+ this.$puiEvents.$on(`onPuiSelect_selectedItems-${fieldName}`, () => {
170
+ this.saveGridFilterModel();
171
+ const gridFilter = this.createPUI9FilterByGridFilterModel();
172
+ if (!this.filterApplied(gridFilter)) {
173
+ this.model.currentFilterComboName = this.gridFilterName;
174
+ this.model.currentFilterCombo = gridFilter;
175
+ !gridFilter && this.removeGridFilterModelInModelsStore();
176
+ this.$puiEvents.$emit(`onPui-apply-filtercombo-${this.modelName}`, gridFilter);
177
+ }
178
+ });
179
+ }
180
+ },
181
+ /*
182
+ * Save gridFilterModel in the store.
183
+ */
184
+ saveGridFilterModel() {
185
+ this.$store.commit('addGridFilterComboModel', {
186
+ name: this.gridFilterName,
187
+ model: this.gridFilterModel
188
+ });
189
+ this.$store.commit('saveModelNameWithGridFilterComboName', {
190
+ modelName: this.modelName,
191
+ gridFilterComboName: this.gridFilterName
192
+ });
193
+ },
194
+ /*
195
+ * Create PUI9 filter from the gridFilterModel values.
196
+ */
197
+ createPUI9FilterByGridFilterModel() {
198
+ const rules = [];
199
+ for (const property in this.gridFilterModel) {
200
+ for (let j = 0; j < this.gridFilterProperties.length; j++) {
201
+ const gridProperty = this.gridFilterProperties[j];
202
+ if (property === gridProperty) {
203
+ const value = this.gridFilterModel[property];
204
+ if (value) {
205
+ rules.push({ field: property, op: 'eq', data: value });
206
+ }
207
+ }
208
+ }
209
+ }
210
+
211
+ if (rules.length === 0) {
212
+ return null;
213
+ }
214
+ return { groups: [], groupOp: 'and', rules: rules };
215
+ },
216
+ filterApplied(gridFilter) {
217
+ return this.model.currentFilterComboName && JSON.stringify(this.model.currentFilterCombo) === JSON.stringify(gridFilter);
218
+ },
219
+ removeGridFilterModelInModelsStore() {
220
+ const allModels = this.$store.state.models;
221
+
222
+ for (const property in allModels) {
223
+ const model = allModels[property];
224
+ if (model.currentFilterComboName === this.gridFilterName) {
225
+ model.currentFilterCombo = null;
226
+ }
227
+ }
228
+ },
229
+ getFilterComboStyles(config) {
230
+ return this.$store.state.filterComboStyles && this.$store.state.filterComboStyles[config.id];
231
+ },
232
+ changeState() {
233
+ this.states.active = true;
234
+ }
235
+ }
236
+ };
237
+ </script>
@@ -0,0 +1,163 @@
1
+ <template>
2
+ <div class="pui-toolbar__multiBtn" :class="compClass">
3
+ <div ref="btn">
4
+ <v-btn
5
+ class="elevation-0 pui-toolbar__btn pui-toolbar__miniBtn"
6
+ @click.native="toggleFilter(!states.applied, true)"
7
+ :class="compClass"
8
+ :title="$t('puidatatables.toogleFilter')"
9
+ >
10
+ <v-icon small>fa fa-filter</v-icon>
11
+ </v-btn>
12
+ <div class="pui-toolbar__multiBtnSeparator">|</div>
13
+ <v-btn
14
+ class="elevation-0 pui-toolbar__btn pui-toolbar__superMiniBtn"
15
+ @click.native.stop="states.active = !states.active"
16
+ :class="compClass"
17
+ >
18
+ <v-icon v-if="!states.active" small>fa fa-angle-down</v-icon>
19
+ <v-icon v-else small>fa fa-angle-up</v-icon>
20
+ </v-btn>
21
+ </div>
22
+ <pui-grid-filter-dialog
23
+ v-if="columns.length > 0 && panel.position.right && states.active"
24
+ :columns="columns"
25
+ :modelName="modelName"
26
+ :position="panel.position"
27
+ ></pui-grid-filter-dialog>
28
+ </div>
29
+ </template>
30
+
31
+ <script>
32
+ import PuiGridFilterDialog from './PuiGridFilterDialog';
33
+ import PuiToolbarBtnMixin from '../../../../mixins/PuiToolbarBtnMixin';
34
+
35
+ export default {
36
+ name: 'PuiGridFilterBtns',
37
+ mixins: [PuiToolbarBtnMixin],
38
+ components: {
39
+ PuiGridFilterDialog
40
+ },
41
+ props: {
42
+ columns: {
43
+ type: Array,
44
+ required: true
45
+ },
46
+ modelName: {
47
+ type: String
48
+ }
49
+ },
50
+ data() {
51
+ return {
52
+ idTool: 'filter',
53
+ panel: {
54
+ position: {}
55
+ },
56
+ modalDialog: {
57
+ showDialog: false,
58
+ disabled: false
59
+ },
60
+ //the filter object in db
61
+ model: null
62
+ };
63
+ },
64
+ mounted() {
65
+ this.$puiEvents.$on(`onPui-apply-storedFilter-${this.modelName}`, (params) => {
66
+ if (params && params.length > 0 && params[0] != null) {
67
+ this.model = params[0];
68
+ this.model.checked = params[1] !== undefined ? params[1] : false;
69
+ this.model.filter = Object.assign({}, this.model.filter instanceof Object ? this.model.filter : JSON.parse(this.model.filter));
70
+ const modelConfig = this.$store.getters.getModelByName(this.modelName);
71
+ modelConfig.currentFilter = this.model;
72
+ }
73
+ });
74
+ this.$puiEvents.$on(`onPui-disapply-storedFilter-${this.modelName}`, () => {
75
+ const modelConfig = this.$store.getters.getModelByName(this.modelName);
76
+ if (modelConfig.currentFilter) {
77
+ modelConfig.currentFilter.checked = false;
78
+ }
79
+ });
80
+ this.$puiEvents.$on(`onPui-apply-filtering-${this.modelName}`, (theFilter) => {
81
+ let filterApplied = true;
82
+ if (theFilter) {
83
+ this.currentFilter = theFilter;
84
+ } else {
85
+ filterApplied = false;
86
+ }
87
+ !(this.skipNextToggle === true) && this.toggleFilter(filterApplied, false);
88
+ this.skipNextToggle = false;
89
+ });
90
+ this.$puiEvents.$on('onPui-readRow-dataTable-puiusermodelfilter', (data) => {
91
+ this.model = data;
92
+ this.model.filter = data.filter instanceof Object ? data.filter : JSON.parse(data.filter);
93
+ this.modalDialog.disabled = true;
94
+ this.modalDialog.showDialog = true;
95
+ this.$puiEvents.$on(`onPui-close-filtering-modalDialog-${this.modelName}`, () => {
96
+ this.$puiEvents.$off(`onPui-close-filtering-modalDialog-${this.modelName}`);
97
+ this.modalDialog.showDialog = false;
98
+ });
99
+ });
100
+ this.$puiEvents.$on('onPui-updateRow-dataTable-puiusermodelfilter', (data) => {
101
+ this.model = data;
102
+ this.model.filter = data.filter instanceof Object ? data.filter : JSON.parse(data.filter);
103
+ this.modalDialog.disabled = false;
104
+ this.modalDialog.showDialog = true;
105
+ this.$puiEvents.$on(`onPui-close-filtering-modalDialog-${this.modelName}`, () => {
106
+ this.$puiEvents.$off(`onPui-close-filtering-modalDialog-${this.modelName}`);
107
+ this.modalDialog.showDialog = false;
108
+ });
109
+ });
110
+ this.$puiEvents.$on('onPui-deleteRow-dataTable-puiusermodelfilter', (data) => {
111
+ if (this.model && this.model.id === data.id) {
112
+ this.model = null;
113
+ this.currentFilter = null;
114
+ }
115
+ });
116
+ this.onLoad();
117
+ this.calculateDialogPosition();
118
+ },
119
+ destroyed() {
120
+ this.$puiEvents.$off(`onPui-apply-storedFilter-${this.modelName}`);
121
+ this.$puiEvents.$off(`onPui-disapply-storedFilter-${this.modelName}`);
122
+ this.$puiEvents.$off(`onPui-apply-filtering-${this.modelName}`);
123
+ this.$puiEvents.$off('onPui-readRow-dataTable-puiusermodelfilter');
124
+ this.$puiEvents.$off('onPui-updateRow-dataTable-puiusermodelfilter');
125
+ this.$puiEvents.$off('onPui-deleteRow-dataTable-puiusermodelfilter');
126
+ },
127
+ methods: {
128
+ onLoad() {
129
+ const modelConfig = this.$store.getters.getModelByName(this.modelName);
130
+ if (modelConfig && modelConfig.currentFilter) {
131
+ this.currentFilter = modelConfig.currentFilter.filter;
132
+ !(this.skipNextToggle === true) && this.toggleFilter(modelConfig.currentFilter.checked, false);
133
+ this.skipNextToggle = false;
134
+ }
135
+ },
136
+ toggleFilter(value, publish) {
137
+ this.states.applied = value;
138
+ let filter = null;
139
+ if (this.states.applied === true) {
140
+ if (!this.currentFilter) {
141
+ this.states.applied = false;
142
+ }
143
+ filter = this.currentFilter;
144
+ }
145
+ this.skipNextToggle = true;
146
+ const theModel = this.$store.getters.getModelByName(this.modelName);
147
+ if (theModel !== undefined) {
148
+ theModel.hasActiveFilter = this.states.applied;
149
+ }
150
+ if (publish === true) {
151
+ if (filter) {
152
+ this.$puiEvents.$emit(`onPui-apply-storedFilter-${this.modelName}`, [theModel.currentFilter, this.states.applied]);
153
+ } else {
154
+ this.$puiEvents.$emit(`onPui-disapply-storedFilter-${this.modelName}`);
155
+ }
156
+ this.$puiEvents.$emit(`onPui-apply-filtering-${this.modelName}`, filter);
157
+ this.$puiEvents.$emit(`onPui-toggle-filtering-${this.modelName}`, [theModel.currentFilter, this.states.applied]);
158
+ this.states.active = false;
159
+ }
160
+ }
161
+ }
162
+ };
163
+ </script>