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.
- package/README.md +24 -0
- package/dist/demo.html +10 -0
- package/dist/pui9-datatables.common.js +89206 -0
- package/dist/pui9-datatables.common.js.map +1 -0
- package/dist/pui9-datatables.css +5 -0
- package/dist/pui9-datatables.umd.js +89216 -0
- package/dist/pui9-datatables.umd.js.map +1 -0
- package/dist/pui9-datatables.umd.min.js +55 -0
- package/dist/pui9-datatables.umd.min.js.map +1 -0
- package/package-lock.json +15982 -0
- package/package.json +89 -0
- package/src/App.vue +37 -0
- package/src/components/desktop/PuiDatatable.vue +709 -0
- package/src/components/desktop/PuiQuickEditionDatatable.vue +548 -0
- package/src/components/desktop/PuiSimpleDatatable.vue +1498 -0
- package/src/components/desktop/datatables.net-plugins/pagination/input.js +213 -0
- package/src/components/desktop/footer/PuiDatatableFooter.vue +65 -0
- package/src/components/desktop/footer/PuiGridActionFooter.vue +132 -0
- package/src/components/desktop/quickedition/PuiQuickEditionExportBtn.vue +138 -0
- package/src/components/desktop/quickedition/PuiQuickEditionForm.vue +60 -0
- package/src/components/desktop/quickedition/PuiQuickEditionToolbar.vue +144 -0
- package/src/components/desktop/row/PuiGridRowActions.vue +112 -0
- package/src/components/desktop/subdialogs/PuiDatatableColumnMenu.vue +186 -0
- package/src/components/desktop/toolbar/PuiGridToolbar.vue +310 -0
- package/src/components/desktop/toolbar/actions/PuiGridActionListItem.vue +34 -0
- package/src/components/desktop/toolbar/actions/PuiGridActionsBtn.vue +56 -0
- package/src/components/desktop/toolbar/actions/PuiGridActionsDialog.vue +66 -0
- package/src/components/desktop/toolbar/actions/audit/PuiAuditDialog.vue +92 -0
- package/src/components/desktop/toolbar/actions/docgen/PuiDocgenTemplateMatchingsDialog.vue +139 -0
- package/src/components/desktop/toolbar/actions/docgen/PuiDocgenTemplateParametersDialog.vue +317 -0
- package/src/components/desktop/toolbar/actions/importexport/PuiGridExportDialog.vue +187 -0
- package/src/components/desktop/toolbar/actions/importexport/PuiGridImportDialog.vue +421 -0
- package/src/components/desktop/toolbar/export/PuiGridExportBtn.vue +175 -0
- package/src/components/desktop/toolbar/filtercombo/PuiGridFilterCombo.vue +237 -0
- package/src/components/desktop/toolbar/filtering/PuiGridFilterBtns.vue +163 -0
- package/src/components/desktop/toolbar/filtering/PuiGridFilterDialog.vue +434 -0
- package/src/components/desktop/toolbar/filtering/PuiGridFilterGroup.vue +313 -0
- package/src/components/desktop/toolbar/filtering/PuiGridFilterListBtn.vue +85 -0
- package/src/components/desktop/toolbar/filtering/PuiGridFilterListDialog.vue +254 -0
- package/src/components/desktop/toolbar/filtering/PuiGridFilterListItem.vue +192 -0
- package/src/components/desktop/toolbar/filtering/PuiGridFilterRule.vue +517 -0
- package/src/components/desktop/toolbar/grid-configuration/PuiGridConfBtns.vue +99 -0
- package/src/components/desktop/toolbar/grid-configuration/PuiGridConfDialog.vue +640 -0
- package/src/components/desktop/toolbar/grid-configuration/PuiSaveConfigDialog.vue +154 -0
- package/src/components/desktop/toolbar/row/PuiGridCreateBtn.vue +39 -0
- package/src/components/desktop/toolbar/row/PuiGridDeleteBtn.vue +86 -0
- package/src/components/desktop/toolbar/row/PuiGridRefreshBtn.vue +39 -0
- package/src/components/desktop/toolbar/row/PuiGridUpdateBtn.vue +56 -0
- package/src/components/desktop/toolbar/searching/PuiGridSearcher.vue +67 -0
- package/src/components/desktop/toolbar/searching/PuiGridSearcherColumnsList.vue +43 -0
- package/src/components/desktop/toolbar/sorting/PuiGridSortBtn.vue +44 -0
- package/src/components/desktop/toolbar/sorting/PuiGridSortDialog.vue +113 -0
- package/src/components/mobile/PuiDatalist.vue +477 -0
- package/src/components/mobile/PuiSimpleDatalist.vue +313 -0
- package/src/components/mobile/actions/PuiListActionListItem.vue +34 -0
- package/src/components/mobile/actions/PuiListActionsBtn.vue +38 -0
- package/src/components/mobile/actions/PuiListActionsDialog.vue +66 -0
- package/src/components/mobile/footer/PuiListActionFooter.vue +56 -0
- package/src/components/mobile/toolbar/PuiListToolbar.vue +60 -0
- package/src/components/mobile/toolbar/searching/PuiListSearcher.vue +53 -0
- package/src/components/mobile/toolbar/searching/PuiListSearcherColumnsList.vue +43 -0
- package/src/components/mobile/toolbar/sorting/PuiListSortBtn.vue +46 -0
- package/src/components/mobile/toolbar/sorting/PuiListSortDialog.vue +140 -0
- package/src/components/puiaudit/PuiAuditForm.vue +107 -0
- package/src/generalActions.js +135 -0
- package/src/index.js +31 -0
- package/src/main.js +67 -0
- package/src/mixins/PuiActionsBtnMixin.js +287 -0
- package/src/mixins/PuiActionsDialogMixin.js +161 -0
- package/src/mixins/PuiActionsListItemMixin.js +62 -0
- package/src/mixins/PuiDatatablesKeepPage.js +15 -0
- package/src/mixins/PuiGridFormMethodsMixin.js +133 -0
- package/src/mixins/PuiModelConfigurationMixin.js +15 -0
- package/src/mixins/PuiSearcherColumnsListMixin.js +108 -0
- package/src/mixins/PuiSearcherMixin.js +192 -0
- package/src/mixins/PuiSortBtnMixin.js +54 -0
- package/src/mixins/PuiSortDialogMixin.js +256 -0
- package/src/mixins/PuiToolbarBtnMixin.js +66 -0
- package/src/mixins/PuiToolbarDialogMixin.js +12 -0
- package/src/router.js +18 -0
- package/src/tests/PuiContainer.vue +139 -0
- package/src/tests/PuiProfileTestSimpleDatatable.vue +66 -0
- package/src/tests/PuiUserTestCompleteDatatable.vue +126 -0
- package/src/tests/PuiVariableTestQuickEditionDatatable.vue +39 -0
- package/src/tests/PuiVariableTestQuickEditionForm.vue +18 -0
- package/src/tests/modelConfigurations.json +3516 -0
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="showTemplate">
|
|
3
|
+
<v-layout wrap v-if="formPosition === 'top'">
|
|
4
|
+
<v-flex xs12>
|
|
5
|
+
<pui-quick-edition-form
|
|
6
|
+
v-if="formComponent && formModel && formLoaded"
|
|
7
|
+
:modelName="modelName"
|
|
8
|
+
:showSaveModal="showSaveModal"
|
|
9
|
+
:formComponent="formComponent"
|
|
10
|
+
:formModel="formModel"
|
|
11
|
+
:formDisabled="disabled"
|
|
12
|
+
:parentModel="parentModel"
|
|
13
|
+
></pui-quick-edition-form>
|
|
14
|
+
</v-flex>
|
|
15
|
+
</v-layout>
|
|
16
|
+
<v-layout wrap>
|
|
17
|
+
<v-flex xs12 md5 v-if="formPosition === 'left'">
|
|
18
|
+
<pui-quick-edition-form
|
|
19
|
+
v-if="formComponent && formModel && formLoaded"
|
|
20
|
+
:modelName="modelName"
|
|
21
|
+
:showSaveModal="showSaveModal"
|
|
22
|
+
:formComponent="formComponent"
|
|
23
|
+
:formModel="formModel"
|
|
24
|
+
:formDisabled="disabled"
|
|
25
|
+
:parentModel="parentModel"
|
|
26
|
+
></pui-quick-edition-form>
|
|
27
|
+
</v-flex>
|
|
28
|
+
<v-flex class="xs12" :class="getDatatableClass()">
|
|
29
|
+
<v-layout justify-end>
|
|
30
|
+
<pui-quick-edition-toolbar
|
|
31
|
+
:modelName="modelName"
|
|
32
|
+
:formDisabled="disabled"
|
|
33
|
+
:showSaveModal="showSaveModal"
|
|
34
|
+
:externalFilter="externalFilter"
|
|
35
|
+
:exportable="exportable"
|
|
36
|
+
></pui-quick-edition-toolbar>
|
|
37
|
+
</v-layout>
|
|
38
|
+
<pui-simple-datatable
|
|
39
|
+
v-if="ready"
|
|
40
|
+
:class="puiDatatableClass + '__table'"
|
|
41
|
+
ref="table"
|
|
42
|
+
:modelName="modelName"
|
|
43
|
+
:columns="columns"
|
|
44
|
+
:showRowActions="showRowActions"
|
|
45
|
+
:parentModelName="parentModelName"
|
|
46
|
+
:externalFilter="externalFilter"
|
|
47
|
+
:modelColumnDefs="columnDefs"
|
|
48
|
+
masterDetail
|
|
49
|
+
:navigableDetail="navigableDetail"
|
|
50
|
+
></pui-simple-datatable>
|
|
51
|
+
</v-flex>
|
|
52
|
+
<v-flex xs12 md5 v-if="formPosition === 'right'">
|
|
53
|
+
<pui-quick-edition-form
|
|
54
|
+
v-if="formComponent && formModel && formLoaded"
|
|
55
|
+
:modelName="modelName"
|
|
56
|
+
:formComponent="formComponent"
|
|
57
|
+
:formModel="formModel"
|
|
58
|
+
:formDisabled="disabled"
|
|
59
|
+
:showSaveModal="showSaveModal"
|
|
60
|
+
:parentModel="parentModel"
|
|
61
|
+
></pui-quick-edition-form>
|
|
62
|
+
</v-flex>
|
|
63
|
+
</v-layout>
|
|
64
|
+
<v-layout wrap v-if="formPosition === 'bottom'">
|
|
65
|
+
<v-flex xs12>
|
|
66
|
+
<pui-quick-edition-form
|
|
67
|
+
v-if="formComponent && formModel && formLoaded"
|
|
68
|
+
:modelName="modelName"
|
|
69
|
+
:formComponent="formComponent"
|
|
70
|
+
:formModel="formModel"
|
|
71
|
+
:formDisabled="disabled"
|
|
72
|
+
:showSaveModal="showSaveModal"
|
|
73
|
+
:parentModel="parentModel"
|
|
74
|
+
></pui-quick-edition-form>
|
|
75
|
+
</v-flex>
|
|
76
|
+
</v-layout>
|
|
77
|
+
<!-- delete registry modal dialog -->
|
|
78
|
+
<pui-modal-dialog
|
|
79
|
+
v-if="showDeleteRegistryDialog"
|
|
80
|
+
:cancelText="$t('form.cancel')"
|
|
81
|
+
:okText="$t('pui9.accept')"
|
|
82
|
+
:titleText="$t('pui9.delete.title')"
|
|
83
|
+
:messageText="$t('pui9.delete.confirm')"
|
|
84
|
+
:dialogName="`deleteRegistry-${this.modelName}`"
|
|
85
|
+
></pui-modal-dialog>
|
|
86
|
+
</div>
|
|
87
|
+
</template>
|
|
88
|
+
|
|
89
|
+
<script>
|
|
90
|
+
import $ from 'jquery';
|
|
91
|
+
import PuiGridDetailMixin from '../../../../pui9-mixins/PuiGridDetailMixin';
|
|
92
|
+
import PuiModelConfigurationMixin from '../../mixins/PuiModelConfigurationMixin';
|
|
93
|
+
import PuiSimpleDatatable from './PuiSimpleDatatable';
|
|
94
|
+
import PuiQuickEditionToolbar from './quickedition/PuiQuickEditionToolbar';
|
|
95
|
+
import PuiQuickEditionForm from './quickedition/PuiQuickEditionForm';
|
|
96
|
+
|
|
97
|
+
export default {
|
|
98
|
+
name: 'PuiQuickEditionDatatable',
|
|
99
|
+
mixins: [PuiGridDetailMixin, PuiModelConfigurationMixin],
|
|
100
|
+
components: {
|
|
101
|
+
PuiSimpleDatatable,
|
|
102
|
+
PuiQuickEditionToolbar,
|
|
103
|
+
PuiQuickEditionForm
|
|
104
|
+
},
|
|
105
|
+
data() {
|
|
106
|
+
return {
|
|
107
|
+
columns: [],
|
|
108
|
+
gridConfiguration: null,
|
|
109
|
+
ready: false,
|
|
110
|
+
showRowActions: false,
|
|
111
|
+
model: null,
|
|
112
|
+
formComponent: null,
|
|
113
|
+
formModel: null,
|
|
114
|
+
formModelTemplateInternal: null,
|
|
115
|
+
completeGridName: null,
|
|
116
|
+
showDeleteRegistryDialog: false,
|
|
117
|
+
selectedRows: null,
|
|
118
|
+
selectedRow: null,
|
|
119
|
+
showTemplate: false,
|
|
120
|
+
formLoaded: false
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
props: {
|
|
124
|
+
modelName: {
|
|
125
|
+
type: String,
|
|
126
|
+
required: true
|
|
127
|
+
},
|
|
128
|
+
formPosition: {
|
|
129
|
+
type: String,
|
|
130
|
+
default: 'top' // left|top|bottom|right
|
|
131
|
+
},
|
|
132
|
+
disabled: {
|
|
133
|
+
type: Boolean,
|
|
134
|
+
required: true
|
|
135
|
+
},
|
|
136
|
+
navigableDetail: {
|
|
137
|
+
type: Boolean,
|
|
138
|
+
default: false
|
|
139
|
+
},
|
|
140
|
+
formComponentName: {
|
|
141
|
+
type: String
|
|
142
|
+
},
|
|
143
|
+
formModelTemplate: {
|
|
144
|
+
type: Object,
|
|
145
|
+
default: null
|
|
146
|
+
},
|
|
147
|
+
parentModel: {
|
|
148
|
+
type: Object,
|
|
149
|
+
required: false
|
|
150
|
+
},
|
|
151
|
+
showSaveModal: {
|
|
152
|
+
type: Object,
|
|
153
|
+
required: false
|
|
154
|
+
},
|
|
155
|
+
modelColumnDefs: {
|
|
156
|
+
type: Object
|
|
157
|
+
},
|
|
158
|
+
exportable: {
|
|
159
|
+
type: Boolean,
|
|
160
|
+
default: false
|
|
161
|
+
},
|
|
162
|
+
quickEditionExternalFilter: {
|
|
163
|
+
type: Object,
|
|
164
|
+
default: null
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
computed: {
|
|
168
|
+
puiDatatableClass() {
|
|
169
|
+
return 'pui-quickEditionDatatable' + (!this.$store.getters.isMobile ? '_desktop' : '_mobile');
|
|
170
|
+
},
|
|
171
|
+
onPuiModelsLoadedAndSaved() {
|
|
172
|
+
return this.$store.state.modelsLoadedAndSaved;
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
watch: {
|
|
176
|
+
onPuiModelsLoadedAndSaved() {
|
|
177
|
+
this.model = this.$store.getters.getModelByName(this.modelName);
|
|
178
|
+
this.onReady();
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
mounted() {
|
|
182
|
+
if (this.formComponentName) {
|
|
183
|
+
this.formComponent = this.formComponentName;
|
|
184
|
+
} else {
|
|
185
|
+
this.formComponent = this.modelName + 'form';
|
|
186
|
+
}
|
|
187
|
+
this.completeGridName = this.modelName + '_' + this.$store.getters.getGridNumberOfInstances(this.modelName);
|
|
188
|
+
if (this.quickEditionExternalFilter) {
|
|
189
|
+
this.externalFilter = this.quickEditionExternalFilter;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
this.model = this.$store.getters.getModelByName(this.modelName);
|
|
193
|
+
if (this.model) {
|
|
194
|
+
this.onReady();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
this.subscribeEvents();
|
|
198
|
+
},
|
|
199
|
+
beforeDestroy() {
|
|
200
|
+
this.$puiEvents.$off(`onPui-selectItem-dataTable-${this.modelName}`);
|
|
201
|
+
this.$puiEvents.$off(`onPui-quickEditionForm-${this.modelName}-save`);
|
|
202
|
+
this.$puiEvents.$off(`onPui-quickEditionForm-${this.modelName}-delete`);
|
|
203
|
+
this.$puiEvents.$off(`pui-modalDialog-deleteRegistry-${this.modelName}-ok`);
|
|
204
|
+
this.$puiEvents.$off(`pui-modalDialog-deleteRegistry-${this.modelName}-cancel`);
|
|
205
|
+
this.$puiEvents.$off(`onPui-deleteRow-dataTable-${this.modelName}`);
|
|
206
|
+
this.$puiEvents.$off('onPui-form-changedModelLanguage');
|
|
207
|
+
},
|
|
208
|
+
methods: {
|
|
209
|
+
subscribeEvents() {
|
|
210
|
+
// quick edition datatable registry selected
|
|
211
|
+
this.$puiEvents.$on(`onPui-selectItem-dataTable-${this.modelName}`, (selectedRows) => {
|
|
212
|
+
this.selectedRows = selectedRows.map((row) => {
|
|
213
|
+
return Object.values(row)[0];
|
|
214
|
+
});
|
|
215
|
+
if (this.selectedRows && this.selectedRows.length === 1) {
|
|
216
|
+
this.formModel = Object.assign({}, this.selectedRows[0]);
|
|
217
|
+
} else if (this.formLoaded) {
|
|
218
|
+
this.formModel = Object.assign({}, this.formModelTemplateInternal);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
// quick edition form save press
|
|
222
|
+
this.$puiEvents.$on(`onPui-quickEditionForm-${this.modelName}-save`, () => {
|
|
223
|
+
if (!this.selectedRows || this.selectedRows.length === 0) {
|
|
224
|
+
this.insert();
|
|
225
|
+
} else {
|
|
226
|
+
this.update();
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
// quick edition form delete press
|
|
230
|
+
this.$puiEvents.$on(`onPui-quickEditionForm-${this.modelName}-delete`, () => {
|
|
231
|
+
this.delete();
|
|
232
|
+
});
|
|
233
|
+
// delete registry modal ok press
|
|
234
|
+
this.$puiEvents.$on(`pui-modalDialog-deleteRegistry-${this.modelName}-ok`, () => {
|
|
235
|
+
this.$refs.table.deleteRegistry(this.selectedRow);
|
|
236
|
+
this.selectedRows = null;
|
|
237
|
+
this.showDeleteRegistryDialog = false;
|
|
238
|
+
this.formModel = Object.assign({}, this.formModelTemplateInternal);
|
|
239
|
+
});
|
|
240
|
+
// delete registry modal cancel press
|
|
241
|
+
this.$puiEvents.$on(`pui-modalDialog-deleteRegistry-${this.modelName}-cancel`, () => {
|
|
242
|
+
this.showDeleteRegistryDialog = false;
|
|
243
|
+
});
|
|
244
|
+
// PuiDatatable delete a registry
|
|
245
|
+
this.$puiEvents.$on(`onPui-deleteRow-dataTable-${this.modelName}`, () => {
|
|
246
|
+
this.$puiEvents.$emit(`onPui-quickEditionDatatable-${this.modelName}-delete-ended`);
|
|
247
|
+
this.publishRequestEnded();
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
this.$puiEvents.$on('onPui-form-changedModelLanguage', () => {
|
|
251
|
+
this.onReady();
|
|
252
|
+
});
|
|
253
|
+
},
|
|
254
|
+
hasFunctionalities() {
|
|
255
|
+
if (this.model.functionalities.list && !this.$store.getters.hasFunctionality(this.model.functionalities.list)) {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
if (this.model.functionalities.insert && !this.$store.getters.hasFunctionality(this.model.functionalities.insert)) {
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
if (this.model.functionalities.update && !this.$store.getters.hasFunctionality(this.model.functionalities.update)) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
if (this.model.functionalities.delete && !this.$store.getters.hasFunctionality(this.model.functionalities.delete)) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
return true;
|
|
268
|
+
},
|
|
269
|
+
onReady() {
|
|
270
|
+
if (this.hasFunctionalities()) {
|
|
271
|
+
if (!this.$store.getters.gridIsInitialized(this.modelName)) {
|
|
272
|
+
this.setColumnsAndGridConfigurationForDatatable(true, false);
|
|
273
|
+
} else {
|
|
274
|
+
// If the grid was created and we are coming back
|
|
275
|
+
this.setColumnsAndGridConfigurationForDatatable(false, true);
|
|
276
|
+
}
|
|
277
|
+
// Create the datatable
|
|
278
|
+
this.ready = true;
|
|
279
|
+
this.showTemplate = true;
|
|
280
|
+
this.getTemplate();
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
setColumnsAndGridConfigurationForDatatable(loadDefaultConfiguration, loadCurrentConfiguration) {
|
|
284
|
+
this.columns = [];
|
|
285
|
+
this.columnDefs = [];
|
|
286
|
+
this.customColumnDefs = [];
|
|
287
|
+
this.dateColumnIndexes = [];
|
|
288
|
+
this.dateTimeColumnIndexes = [];
|
|
289
|
+
this.decimalColumnIndexes = [];
|
|
290
|
+
// Get the current configuration
|
|
291
|
+
if (loadCurrentConfiguration) {
|
|
292
|
+
this.gridConfiguration = this.cloneConfiguration(this.$store.getters.getDefaultGridConfiguration(this.modelName));
|
|
293
|
+
} else if (loadDefaultConfiguration) {
|
|
294
|
+
// Or load the default
|
|
295
|
+
const defaultConfig = this.$store.getters.getDefaultGridConfiguration(this.modelName);
|
|
296
|
+
if (defaultConfig) {
|
|
297
|
+
this.$store.commit('puiModelsSetCurrentGridConfiguration', { model: this.modelName, configuration: defaultConfig });
|
|
298
|
+
this.gridConfiguration = this.cloneConfiguration(defaultConfig);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// If there is no configuration (first time in the grid) a new one should be created to work with on runtime
|
|
303
|
+
if (!this.gridConfiguration) {
|
|
304
|
+
this.gridConfiguration = {
|
|
305
|
+
model: this.modelName,
|
|
306
|
+
usr: this.$store.getters.getUser,
|
|
307
|
+
configuration: {
|
|
308
|
+
grouped: false,
|
|
309
|
+
columnSearch: false
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
let hiddenColsCounter = 0;
|
|
313
|
+
this.model.columns.forEach((colObj, index) => {
|
|
314
|
+
if (colObj.visibility !== 'completelyhidden') {
|
|
315
|
+
this.setCustomColumnDefs(colObj.name, colObj.type, index + 1 - hiddenColsCounter);
|
|
316
|
+
|
|
317
|
+
let visible = colObj.visibility === 'visible';
|
|
318
|
+
if (this.modelColumnDefs) {
|
|
319
|
+
const columnDef = this.modelColumnDefs[colObj.name];
|
|
320
|
+
if (columnDef && columnDef.visible !== undefined) {
|
|
321
|
+
visible = columnDef.visible;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
this.columns.push({
|
|
326
|
+
order: colObj.order || index,
|
|
327
|
+
title: this.$puiI18n.t(colObj.title),
|
|
328
|
+
name: colObj.name,
|
|
329
|
+
data: colObj.name,
|
|
330
|
+
visible: visible,
|
|
331
|
+
type: colObj.type,
|
|
332
|
+
orderable: true
|
|
333
|
+
});
|
|
334
|
+
} else {
|
|
335
|
+
hiddenColsCounter++;
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
} else {
|
|
339
|
+
this.gridConfiguration = this.cloneConfiguration(this.gridConfiguration);
|
|
340
|
+
this.avoidOrder = this.gridConfiguration.configuration.order !== undefined;
|
|
341
|
+
this.gridConfiguration.configuration.columns
|
|
342
|
+
.sort((a, b) => {
|
|
343
|
+
return a.order - b.order;
|
|
344
|
+
})
|
|
345
|
+
.forEach((colObj, index) => {
|
|
346
|
+
delete colObj.bVisible;
|
|
347
|
+
this.setCustomColumnDefs(colObj.name, colObj.type, index + 1);
|
|
348
|
+
|
|
349
|
+
let visible = colObj.visible;
|
|
350
|
+
if (this.modelColumnDefs) {
|
|
351
|
+
const columnDef = this.modelColumnDefs[colObj.name];
|
|
352
|
+
if (columnDef && columnDef.visible !== undefined) {
|
|
353
|
+
visible = columnDef.visible;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
colObj.title = this.$puiI18n.t(colObj.title);
|
|
358
|
+
this.columns.push({
|
|
359
|
+
order: colObj.order || index,
|
|
360
|
+
title: colObj.title,
|
|
361
|
+
name: colObj.name,
|
|
362
|
+
data: colObj.name,
|
|
363
|
+
visible: visible,
|
|
364
|
+
type: colObj.type,
|
|
365
|
+
orderable: true
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
this.groupedColumn = this.gridConfiguration.configuration.grouped;
|
|
370
|
+
this.setColumnDefs();
|
|
371
|
+
},
|
|
372
|
+
setCustomColumnDefs(columnName, columnType, index) {
|
|
373
|
+
if (this.modelColumnDefs && this.modelColumnDefs[columnName]) {
|
|
374
|
+
let hasCustomColumnDef = false;
|
|
375
|
+
const columnDef = { targets: [index] };
|
|
376
|
+
if (this.modelColumnDefs[columnName].render) {
|
|
377
|
+
hasCustomColumnDef = true;
|
|
378
|
+
columnDef.render = this.modelColumnDefs[columnName].render;
|
|
379
|
+
}
|
|
380
|
+
if (this.modelColumnDefs[columnName].createdCell) {
|
|
381
|
+
hasCustomColumnDef = true;
|
|
382
|
+
columnDef.createdCell = this.modelColumnDefs[columnName].createdCell;
|
|
383
|
+
}
|
|
384
|
+
if (hasCustomColumnDef) {
|
|
385
|
+
this.customColumnDefs.push(columnDef);
|
|
386
|
+
} else if (columnType === 'date' || columnType === 'datetime') {
|
|
387
|
+
if (this.modelColumnDefs[columnName].withoutHours) {
|
|
388
|
+
this.dateColumnIndexes.push(index);
|
|
389
|
+
} else {
|
|
390
|
+
this.dateTimeColumnIndexes.push(index);
|
|
391
|
+
}
|
|
392
|
+
} else if (columnType === 'decimal') {
|
|
393
|
+
this.decimalColumnIndexes.push(index);
|
|
394
|
+
}
|
|
395
|
+
} else {
|
|
396
|
+
if (columnType === 'date' || columnType === 'datetime') {
|
|
397
|
+
this.dateTimeColumnIndexes.push(index);
|
|
398
|
+
} else if (columnType === 'decimal') {
|
|
399
|
+
this.decimalColumnIndexes.push(index);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
setColumnDefs() {
|
|
404
|
+
this.dateFormat = this.$store.getters.dateFormat;
|
|
405
|
+
this.timeFormat = this.$store.getters.timeFormat;
|
|
406
|
+
this.thousandSeparator = this.$store.getters.thousandSeparator;
|
|
407
|
+
this.decimalSeparator = this.$store.getters.decimalSeparator;
|
|
408
|
+
|
|
409
|
+
const dateColumnDefs = {
|
|
410
|
+
targets: this.dateColumnIndexes,
|
|
411
|
+
render: (val) => {
|
|
412
|
+
if (val === null) {
|
|
413
|
+
return '';
|
|
414
|
+
}
|
|
415
|
+
return this.$dateTimeUtils.getLocalFormattedDate(val, `${this.dateFormat}`);
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
const dateTimeColumnDefs = {
|
|
420
|
+
targets: this.dateTimeColumnIndexes,
|
|
421
|
+
render: (val) => {
|
|
422
|
+
if (val === null) {
|
|
423
|
+
return '';
|
|
424
|
+
}
|
|
425
|
+
return this.$dateTimeUtils.getLocalFormattedDate(val, `${this.dateFormat} ${this.timeFormat}`);
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
const decimalColumnDefs = {
|
|
430
|
+
targets: this.decimalColumnIndexes,
|
|
431
|
+
render: (val) => {
|
|
432
|
+
if (val === null) {
|
|
433
|
+
return '';
|
|
434
|
+
}
|
|
435
|
+
if (val.toString().includes('.')) {
|
|
436
|
+
const parts = val.toString().split('.');
|
|
437
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandSeparator);
|
|
438
|
+
return parts.join(this.decimalSeparator);
|
|
439
|
+
}
|
|
440
|
+
return val.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, `$1${this.thousandSeparator}`);
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
this.columnDefs.push(dateColumnDefs);
|
|
445
|
+
this.columnDefs.push(dateTimeColumnDefs);
|
|
446
|
+
this.columnDefs.push(decimalColumnDefs);
|
|
447
|
+
this.columnDefs.push(...this.customColumnDefs);
|
|
448
|
+
},
|
|
449
|
+
getDatatableClass() {
|
|
450
|
+
if (this.formPosition === 'left' || this.formPosition === 'right') {
|
|
451
|
+
return { md7: true };
|
|
452
|
+
}
|
|
453
|
+
return null;
|
|
454
|
+
},
|
|
455
|
+
getTemplate() {
|
|
456
|
+
if (this.formModel) {
|
|
457
|
+
this.formLoaded = true;
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
if (this.formModelTemplate) {
|
|
461
|
+
this.formModelTemplateInternal = Object.assign({}, this.formModelTemplate);
|
|
462
|
+
this.formModel = Object.assign({}, this.formModelTemplate);
|
|
463
|
+
this.formLoaded = true;
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
this.$puiRequests.getRequest(
|
|
467
|
+
this.model.url.template,
|
|
468
|
+
null,
|
|
469
|
+
(response) => {
|
|
470
|
+
this.formModelTemplateInternal = Object.assign({}, response.data);
|
|
471
|
+
const bpk = this.$puiUtils.b64ToUtf8(this.parentPk);
|
|
472
|
+
const ppPk = JSON.parse(bpk);
|
|
473
|
+
for (var key in ppPk) {
|
|
474
|
+
const field = this.parentPkChildFk != null ? this.parentPkChildFk[key] : key;
|
|
475
|
+
const data = ppPk[key];
|
|
476
|
+
this.formModelTemplateInternal[field] = data;
|
|
477
|
+
}
|
|
478
|
+
this.formModel = Object.assign({}, this.formModelTemplateInternal);
|
|
479
|
+
// Timeout needed due unnecessary multiple datatable Events Emited causing inconsistency
|
|
480
|
+
setTimeout(() => (this.formLoaded = true), 200);
|
|
481
|
+
},
|
|
482
|
+
(error) => {
|
|
483
|
+
this.$store.dispatch('puiRequestShowServerError', { error });
|
|
484
|
+
}
|
|
485
|
+
);
|
|
486
|
+
},
|
|
487
|
+
insert() {
|
|
488
|
+
this.$puiRequests.postRequest(
|
|
489
|
+
this.model.url.insert,
|
|
490
|
+
this.formModel,
|
|
491
|
+
() => {
|
|
492
|
+
this.$refs.table.reloadGrid(this.gridConfiguration.configuration);
|
|
493
|
+
this.getTemplate();
|
|
494
|
+
this.$puiEvents.$emit(`onPui-quickEditionDatatable-${this.modelName}-insert-ended`);
|
|
495
|
+
this.publishRequestEnded();
|
|
496
|
+
},
|
|
497
|
+
(error) => {
|
|
498
|
+
this.$store.dispatch('puiRequestShowServerError', { error });
|
|
499
|
+
}
|
|
500
|
+
);
|
|
501
|
+
},
|
|
502
|
+
update() {
|
|
503
|
+
this.$puiRequests.putRequest(
|
|
504
|
+
this.model.url.update,
|
|
505
|
+
this.formModel,
|
|
506
|
+
() => {
|
|
507
|
+
this.$refs.table.reloadGrid(this.gridConfiguration.configuration);
|
|
508
|
+
this.getTemplate();
|
|
509
|
+
this.$puiEvents.$emit(`onPui-quickEditionDatatable-${this.modelName}-update-ended`);
|
|
510
|
+
this.publishRequestEnded();
|
|
511
|
+
},
|
|
512
|
+
(error) => {
|
|
513
|
+
this.$store.dispatch('puiRequestShowServerError', { error });
|
|
514
|
+
}
|
|
515
|
+
);
|
|
516
|
+
},
|
|
517
|
+
delete() {
|
|
518
|
+
this.selectedRow = $('#' + this.completeGridName)
|
|
519
|
+
.DataTable()
|
|
520
|
+
.row('.selected');
|
|
521
|
+
if (this.selectedRow && this.selectedRow.data()) {
|
|
522
|
+
this.showDeleteRegistryDialog = true;
|
|
523
|
+
} else {
|
|
524
|
+
this.$puiNotify.warning(this.$t('puigriddelete.notselectedrow'), '', null, false);
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
publishRequestEnded() {
|
|
528
|
+
// Publish event when the puiquickeditiondatatable do some request insert/update/delete
|
|
529
|
+
this.$puiEvents.$emit(`onPui-quickEditionDatatable-${this.modelName}-request-ended`);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
</script>
|
|
534
|
+
|
|
535
|
+
<style lang="postcss">
|
|
536
|
+
.pui-quickEditionDatatable {
|
|
537
|
+
&_desktop__table {
|
|
538
|
+
& .bottom {
|
|
539
|
+
& .left {
|
|
540
|
+
float: left;
|
|
541
|
+
}
|
|
542
|
+
& .right {
|
|
543
|
+
float: right;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
</style>
|