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,640 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<v-layout justify-center>
|
|
4
|
+
<!-- dialogo para guardar una configuración de grid nueva -->
|
|
5
|
+
<pui-save-config-dialog v-if="dialogs.edit === true" :modelName="modelName"></pui-save-config-dialog>
|
|
6
|
+
<!-- dialogo alerta borrado de configuracion -->
|
|
7
|
+
<pui-modal-dialog
|
|
8
|
+
v-if="dialogs.deleteConfigAlert"
|
|
9
|
+
:cancelText="$t('form.cancel')"
|
|
10
|
+
:okText="$t('form.ok')"
|
|
11
|
+
:titleText="$t('puidatatables.grid_configuration')"
|
|
12
|
+
:messageText="`${$t('puidatatables.sure_delete')} ${model.configuration.name}`"
|
|
13
|
+
:dialogName="`deleteConfigAlert-${this.modelName}`"
|
|
14
|
+
></pui-modal-dialog>
|
|
15
|
+
<!-- dialogo alerta cambios no guardados (salta al cambiar de configuracion habiendo sido editada) -->
|
|
16
|
+
<pui-modal-dialog
|
|
17
|
+
v-if="dialogs.unsavedChanges"
|
|
18
|
+
:cancelText="$t('form.cancel')"
|
|
19
|
+
:okText="$t('puidatatables.discard_changes')"
|
|
20
|
+
:titleText="$t('puidatatables.unsaved_changes')"
|
|
21
|
+
:messageText="$t('puidatatables.unsaved_changes.desc')"
|
|
22
|
+
:dialogName="`unsavedChanges-${this.modelName}`"
|
|
23
|
+
></pui-modal-dialog>
|
|
24
|
+
<!-- dialogo para seleccionar columnas visibles -->
|
|
25
|
+
<v-dialog persistent eager v-model="dialogs.columnSelector" max-width="850px">
|
|
26
|
+
<v-card flat style="border-radius: 6px">
|
|
27
|
+
<v-card-title>
|
|
28
|
+
<div class="puiDialog__title pl-2">{{ $t('puidatatables.select_columns') }}</div>
|
|
29
|
+
</v-card-title>
|
|
30
|
+
<v-card-text>
|
|
31
|
+
<pui-multi-select
|
|
32
|
+
v-if="dialogs.columnSelector"
|
|
33
|
+
:items="columns"
|
|
34
|
+
:trackItemsToSelect="true"
|
|
35
|
+
:itemsToSelect="visibleColumns"
|
|
36
|
+
itemValue="name"
|
|
37
|
+
itemText="title"
|
|
38
|
+
:textSelected="this.$t('puidatatables.visible')"
|
|
39
|
+
:textAvailable="this.$t('puidatatables.hidden')"
|
|
40
|
+
:heightList="columnPickerHeight"
|
|
41
|
+
v-model="selectedColumns"
|
|
42
|
+
:flat="true"
|
|
43
|
+
></pui-multi-select>
|
|
44
|
+
</v-card-text>
|
|
45
|
+
<v-card-actions class="pl-3 pr-3 pb-2">
|
|
46
|
+
<v-btn text outlined @click="dialogs.columnSelector = false" class="elevation-0">{{ $t('form.cancel') }}</v-btn>
|
|
47
|
+
<v-spacer />
|
|
48
|
+
<v-btn color="primary" @click="applyColumnConfig()" class="elevation-0">{{ $t('form.apply') }}</v-btn>
|
|
49
|
+
</v-card-actions>
|
|
50
|
+
</v-card>
|
|
51
|
+
</v-dialog>
|
|
52
|
+
</v-layout>
|
|
53
|
+
<!-- dialogo principal para seleccionar y guardar configuración activa -->
|
|
54
|
+
<div class="pui-dialog pui-dialog--conf elevation-5" ref="dialog" @click.stop>
|
|
55
|
+
<v-card-text class="ma-0 pt-2 pl-2 pr-2 pb-0">
|
|
56
|
+
<v-layout :ref="'header'" wrap class="mb-3">
|
|
57
|
+
<v-toolbar class="elevation-0 pui-dialog__bar" height="50">
|
|
58
|
+
<v-toolbar-title class="pui-dialog__title pui-dialog__margin">{{ $t('puidatatables.configure') }}</v-toolbar-title>
|
|
59
|
+
<v-btn @click="undo()" class="pui-dialog__toolbarBtn elevation-0">
|
|
60
|
+
<v-icon small>fa fa-undo-alt</v-icon>
|
|
61
|
+
</v-btn>
|
|
62
|
+
<v-spacer></v-spacer>
|
|
63
|
+
<v-btn class="pui-dialog__toolbarBtn elevation-0" @click="dialogs.edit = true" :title="$t('puidatatables.save_changes')">
|
|
64
|
+
<v-icon small>fa fa-save</v-icon>
|
|
65
|
+
</v-btn>
|
|
66
|
+
</v-toolbar>
|
|
67
|
+
</v-layout>
|
|
68
|
+
<v-autocomplete
|
|
69
|
+
class="puiConf-dialog__select"
|
|
70
|
+
:class="{ 'puiConf-dialog--unsaved': updated }"
|
|
71
|
+
:items="modelGridConfigurations"
|
|
72
|
+
v-model="configurationId"
|
|
73
|
+
:disabled="configurationSelectorDisabled"
|
|
74
|
+
solo
|
|
75
|
+
flat
|
|
76
|
+
:return-object="false"
|
|
77
|
+
item-value="id"
|
|
78
|
+
:item-text="(item) => item.configuration.name"
|
|
79
|
+
clearable
|
|
80
|
+
>
|
|
81
|
+
<template v-slot:selection="data">
|
|
82
|
+
<div style="min-width: 25px">
|
|
83
|
+
<span class="puiConf-dialog__dot" v-if="updated === true">.</span>
|
|
84
|
+
<v-icon v-else-if="data.item.id === -1" class="puiConf-dialog__icon">fa fa-lock</v-icon>
|
|
85
|
+
<v-icon v-else class="puiConf-dialog__icon pointer" @click.stop="dialogs.deleteConfigAlert = true">fa fa-trash</v-icon>
|
|
86
|
+
</div>
|
|
87
|
+
<v-list-item-content class="pt-2 pb-2" :class="{ 'pl-3': updated }" style="max-width: 87%">
|
|
88
|
+
<v-list-item-title v-html="data.item.configuration.name"></v-list-item-title>
|
|
89
|
+
</v-list-item-content>
|
|
90
|
+
</template>
|
|
91
|
+
</v-autocomplete>
|
|
92
|
+
</v-card-text>
|
|
93
|
+
<v-card-actions class="pl-1 pr-1 pb-2 pt-0" :ref="'btnBar'">
|
|
94
|
+
<v-btn text outlined @click="showColumnDialog()" class="elevation-0">{{ $t('puidatatables.select_columns') }}</v-btn>
|
|
95
|
+
<v-spacer />
|
|
96
|
+
<v-btn v-if="updated === true" color="primary" @click="save()" class="elevation-0">{{ $t('form.update') }}</v-btn>
|
|
97
|
+
</v-card-actions>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
</template>
|
|
101
|
+
|
|
102
|
+
<script>
|
|
103
|
+
import PuiGridFormMethodsMixin from '../../../../mixins/PuiGridFormMethodsMixin';
|
|
104
|
+
import PuiToolbarDialogMixin from '../../../../mixins/PuiToolbarDialogMixin';
|
|
105
|
+
import PuiModelConfigurationMixin from '../../../../mixins/PuiModelConfigurationMixin';
|
|
106
|
+
import PuiSaveConfigDialog from './PuiSaveConfigDialog';
|
|
107
|
+
|
|
108
|
+
export default {
|
|
109
|
+
name: 'PuiGridConfDialog',
|
|
110
|
+
components: {
|
|
111
|
+
PuiSaveConfigDialog
|
|
112
|
+
},
|
|
113
|
+
mixins: [PuiGridFormMethodsMixin, PuiToolbarDialogMixin, PuiModelConfigurationMixin],
|
|
114
|
+
props: {
|
|
115
|
+
columns: {
|
|
116
|
+
type: Array,
|
|
117
|
+
required: true
|
|
118
|
+
},
|
|
119
|
+
position: {
|
|
120
|
+
type: Object
|
|
121
|
+
},
|
|
122
|
+
modelName: {
|
|
123
|
+
type: String,
|
|
124
|
+
required: true
|
|
125
|
+
},
|
|
126
|
+
modelNameSuffix: {
|
|
127
|
+
type: String,
|
|
128
|
+
default: ''
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
data() {
|
|
132
|
+
return {
|
|
133
|
+
updated: false,
|
|
134
|
+
selectedColumns: [],
|
|
135
|
+
notifyChange: true,
|
|
136
|
+
configurationId: null,
|
|
137
|
+
configurationSelectorDisabled: false,
|
|
138
|
+
dialogs: {
|
|
139
|
+
unsavedChanges: false,
|
|
140
|
+
edit: false,
|
|
141
|
+
deleteConfigAlert: false,
|
|
142
|
+
columnSelector: false
|
|
143
|
+
},
|
|
144
|
+
width: 350,
|
|
145
|
+
modelDependencyName: 'puiusermodelconfig',
|
|
146
|
+
method: 'create',
|
|
147
|
+
modelTemplate: {
|
|
148
|
+
name: null,
|
|
149
|
+
description: null,
|
|
150
|
+
isdefault: false,
|
|
151
|
+
columns: [],
|
|
152
|
+
grouped: false,
|
|
153
|
+
pinColumn: false,
|
|
154
|
+
columnSearch: false,
|
|
155
|
+
rows: 20,
|
|
156
|
+
order: []
|
|
157
|
+
},
|
|
158
|
+
visibleColumns: null
|
|
159
|
+
};
|
|
160
|
+
},
|
|
161
|
+
created() {
|
|
162
|
+
this.setGridModel();
|
|
163
|
+
this.setVisibleColumns(this.columns);
|
|
164
|
+
this.subscribeToOtherGridConfigurations();
|
|
165
|
+
this.subscribeToModalDialogsEvents();
|
|
166
|
+
},
|
|
167
|
+
mounted() {
|
|
168
|
+
this.calculatePosition();
|
|
169
|
+
},
|
|
170
|
+
updated() {
|
|
171
|
+
this.calculatePosition();
|
|
172
|
+
},
|
|
173
|
+
destroyed() {
|
|
174
|
+
this.$puiEvents.$off(`onPui-apply-sorting-${this.modelName}${this.modelNameSuffix}`);
|
|
175
|
+
this.$puiEvents.$off(`onPui-apply-sorting-dataTable-${this.modelName}${this.modelNameSuffix}`);
|
|
176
|
+
this.$puiEvents.$off(`onPui-changeRowNum-dataTable-${this.modelName}${this.modelNameSuffix}`);
|
|
177
|
+
this.$puiEvents.$off(`onPui-groupColumn-dataTable-${this.modelName}${this.modelNameSuffix}`);
|
|
178
|
+
this.$puiEvents.$off(`onPui-fixedColumn-dataTable-${this.modelName}${this.modelNameSuffix}`);
|
|
179
|
+
this.$puiEvents.$off(`onPui-selectItem-dataTable-${this.modelName}${this.modelNameSuffix}`);
|
|
180
|
+
this.$puiEvents.$off(`onPui-pageChange-dataTable-${this.modelName}${this.modelNameSuffix}`);
|
|
181
|
+
this.$puiEvents.$off(`onPui-clearSelection-dataTable-${this.modelName}${this.modelNameSuffix}`);
|
|
182
|
+
this.$puiEvents.$off(`onPui-colReorder-dataTable-${this.modelName}${this.modelNameSuffix}`);
|
|
183
|
+
this.unsubscribeToModalDialogEvent(`pui-modalDialog-deleteConfigAlert-${this.modelName}`);
|
|
184
|
+
this.unsubscribeToModalDialogEvent(`pui-modalDialog-unsavedChanges-${this.modelName}`);
|
|
185
|
+
},
|
|
186
|
+
computed: {
|
|
187
|
+
columnPickerHeight() {
|
|
188
|
+
return window.innerHeight > 600 ? 300 : 225;
|
|
189
|
+
},
|
|
190
|
+
onPuiModelsLoadedAndSaved() {
|
|
191
|
+
return this.$store.state.modelsLoadedAndSaved;
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
watch: {
|
|
195
|
+
onPuiModelsLoadedAndSaved() {
|
|
196
|
+
if (this.modelGridConfigurations === undefined) {
|
|
197
|
+
this.modelGridConfigurations = this.$store.getters.getGridConfigurationsForModel(this.modelName);
|
|
198
|
+
this.setConfiguration();
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
configurationId(newId, prevIdConfig) {
|
|
202
|
+
if (this.avoidWatch === true) {
|
|
203
|
+
this.avoidWatch = false;
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
//this means not a valid configuration
|
|
207
|
+
if (isNaN(parseInt(newId))) {
|
|
208
|
+
this.$parent.states.applied = false;
|
|
209
|
+
this.model.edited = false;
|
|
210
|
+
this.method = 'create';
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
//this means, jumping from one unsaved configuration to another
|
|
214
|
+
//we show the unsaved changes dialog
|
|
215
|
+
if (this.model.edited === true && prevIdConfig !== -1 && prevIdConfig !== null) {
|
|
216
|
+
if (this.dialogs.unsavedChanges === true || this.dialogs.edit === true) {
|
|
217
|
+
this.dialogs.unsavedChanges = false;
|
|
218
|
+
} else {
|
|
219
|
+
this.dialogs.unsavedChanges = true;
|
|
220
|
+
}
|
|
221
|
+
this.configurationUnsavedId = prevIdConfig;
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
//this means, jumping without unsaved changes to another configuration
|
|
225
|
+
if (this.configurationSelectorDisabled === false && this.dialogs.unsavedChanges === false) {
|
|
226
|
+
this.model.edited = false;
|
|
227
|
+
this.setModelConfigurationById(newId, prevIdConfig);
|
|
228
|
+
}
|
|
229
|
+
this.dialogs.unsavedChanges = false;
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
methods: {
|
|
233
|
+
setNameAndDescription(configId) {
|
|
234
|
+
const models = this.$store.getters.getGridConfigurationsForModel(this.modelName);
|
|
235
|
+
for (let i = 0, length = models.length; i < length; i++) {
|
|
236
|
+
if (models[i].id === configId) {
|
|
237
|
+
this.model.configuration.name = models[i].configuration.name;
|
|
238
|
+
this.model.configuration.description = models[i].configuration.description;
|
|
239
|
+
this.model.configuration.isdefault = models[i].configuration.isdefault;
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
subscribeToModalDialogsEvents() {
|
|
245
|
+
this.$puiEvents.$on(`pui-modalDialog-deleteConfigAlert-${this.modelName}-ok`, () => {
|
|
246
|
+
this.dialogs.deleteConfigAlert = false;
|
|
247
|
+
this.deleteConfig();
|
|
248
|
+
});
|
|
249
|
+
this.$puiEvents.$on(`pui-modalDialog-deleteConfigAlert-${this.modelName}-cancel`, () => {
|
|
250
|
+
this.dialogs.deleteConfigAlert = false;
|
|
251
|
+
});
|
|
252
|
+
this.$puiEvents.$on(`pui-modalDialog-unsavedChanges-${this.modelName}-ok`, () => {
|
|
253
|
+
this.dialogs.unsavedChanges = false;
|
|
254
|
+
this.discardChangesAndGoForward();
|
|
255
|
+
});
|
|
256
|
+
this.$puiEvents.$on(`pui-modalDialog-unsavedChanges-${this.modelName}-cancel`, () => {
|
|
257
|
+
this.cancelChangeUnsavedConfig();
|
|
258
|
+
this.dialogs.unsavedChanges = false;
|
|
259
|
+
});
|
|
260
|
+
},
|
|
261
|
+
unsubscribeToModalDialogEvent(topicPrefix) {
|
|
262
|
+
this.$puiEvents.$off(`${topicPrefix}-ok`);
|
|
263
|
+
this.$puiEvents.$off(`${topicPrefix}-cancel`);
|
|
264
|
+
},
|
|
265
|
+
onSaveError() {
|
|
266
|
+
this.model.configuration = JSON.parse(this.model.configuration);
|
|
267
|
+
},
|
|
268
|
+
onConfDeleted(configPk) {
|
|
269
|
+
this.$store.commit('deleteGridConfiguration', { model: this.modelName, configuration: configPk });
|
|
270
|
+
this.modelGridConfigurations = this.$store.getters.getGridConfigurationsForModel(this.modelName);
|
|
271
|
+
this.configurationSelectorDisabled = false;
|
|
272
|
+
if (this.modelGridConfigurations.length === 0) {
|
|
273
|
+
this.method = 'create';
|
|
274
|
+
this.configurationSelectorDisabled = true;
|
|
275
|
+
} else if (configPk.id === this.model.id) {
|
|
276
|
+
this.model = this.$store.getters.getDefaultGridConfiguration(this.modelName);
|
|
277
|
+
this.configurationId = this.model.id;
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
cancelChangeUnsavedConfig() {
|
|
281
|
+
if (this.toggling === true) {
|
|
282
|
+
this.dialogs.unsavedChanges = false;
|
|
283
|
+
this.toggling = false;
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
this.configurationId = this.configurationUnsavedId;
|
|
287
|
+
this.model.edited = true;
|
|
288
|
+
},
|
|
289
|
+
discardChangesAndGoForward() {
|
|
290
|
+
this.model.edited = false;
|
|
291
|
+
if (this.toggling === true) {
|
|
292
|
+
this.toggleConfiguration();
|
|
293
|
+
this.toggling = false;
|
|
294
|
+
} else {
|
|
295
|
+
this.setModelConfigurationById(this.configurationId, this.configurationUnsavedId);
|
|
296
|
+
}
|
|
297
|
+
this.dialogs.unsavedChanges = false;
|
|
298
|
+
},
|
|
299
|
+
setModelConfigurationById(idConfig, prevIdConfig, configuration) {
|
|
300
|
+
if (configuration) {
|
|
301
|
+
this.model = configuration;
|
|
302
|
+
}
|
|
303
|
+
for (let i = 0, length = this.modelGridConfigurations.length; i < length; i++) {
|
|
304
|
+
const config = this.modelGridConfigurations[i];
|
|
305
|
+
if (config.id === idConfig) {
|
|
306
|
+
//here we clone the configuration object in order to do the undo action later on
|
|
307
|
+
this.model = this.cloneConfiguration(config);
|
|
308
|
+
this.setVisibleColumns(this.model.configuration.columns);
|
|
309
|
+
this.method = 'update';
|
|
310
|
+
//if prevIdConfig is null means this is the first time a configuration is setted and if also is the default one, we not publish the event because the completeDatatables componente already has that configuration
|
|
311
|
+
if (!(prevIdConfig === null && (this.model.configuration.isdefault === true || idConfig === -1))) {
|
|
312
|
+
this.$puiEvents.$emit(`onPui-apply-configuration-${this.modelName}`, this.model.configuration);
|
|
313
|
+
}
|
|
314
|
+
this.notifyChange = false;
|
|
315
|
+
this.onConfigurationChange();
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
toggleConfiguration() {
|
|
321
|
+
if (this.model.id !== -1) {
|
|
322
|
+
if (this.model.edited === true) {
|
|
323
|
+
this.toggling = true;
|
|
324
|
+
this.dialogs.unsavedChanges = true;
|
|
325
|
+
this.configurationUnsavedId = this.model.id;
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
this.setModelConfigurationById(-1, this.model.id);
|
|
329
|
+
this.configurationId = -1;
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
undo() {
|
|
333
|
+
const defaultConfiguration = this.$store.getters.getDefaultGridConfiguration(this.modelName);
|
|
334
|
+
if (defaultConfiguration) {
|
|
335
|
+
this.configurationId = defaultConfiguration.id;
|
|
336
|
+
this.setModelConfigurationById(defaultConfiguration.id);
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
onConfigurationChange() {
|
|
340
|
+
if (this.method === 'update') {
|
|
341
|
+
this.model.edited = this.notifyChange;
|
|
342
|
+
if (this.model.id === -1) {
|
|
343
|
+
this.notifyChange = false;
|
|
344
|
+
}
|
|
345
|
+
this.$store.commit('puiModelsSetCurrentGridConfiguration', { model: this.modelName, configuration: this.model });
|
|
346
|
+
this.$parent.states.unsaved = this.notifyChange;
|
|
347
|
+
this.updated = this.notifyChange;
|
|
348
|
+
this.notifyChange = true;
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
subscribeToOtherGridConfigurations() {
|
|
352
|
+
this.$puiEvents.$on(`onPui-pageChange-dataTable-${this.modelName}${this.modelNameSuffix}`, (page) => {
|
|
353
|
+
this.model.configuration.page = page;
|
|
354
|
+
this.notifyChange = false;
|
|
355
|
+
this.onConfigurationChange();
|
|
356
|
+
});
|
|
357
|
+
this.$puiEvents.$on(`onPui-colReorder-dataTable-${this.modelName}${this.modelNameSuffix}`, (orderArray) => {
|
|
358
|
+
clearTimeout(this.delayTimer);
|
|
359
|
+
//WHY USING SETTIMEOUT IN 2 SEC???
|
|
360
|
+
this.delayTimer = setTimeout(() => {
|
|
361
|
+
const orderedArray = [];
|
|
362
|
+
for (let order = 0, length = this.visibleColumns.length; order <= length; order++) {
|
|
363
|
+
if (order === 0) {
|
|
364
|
+
//skip check column
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
const indexCol = orderArray[order];
|
|
368
|
+
this.model.configuration.columns[indexCol - 1].order = order - 1;
|
|
369
|
+
orderedArray.push(this.model.configuration.columns[indexCol - 1]);
|
|
370
|
+
}
|
|
371
|
+
this.setVisibleColumns(orderedArray);
|
|
372
|
+
this.onConfigurationChange();
|
|
373
|
+
}, 2000);
|
|
374
|
+
this.onConfigurationChange();
|
|
375
|
+
});
|
|
376
|
+
this.$puiEvents.$on(`onPui-apply-sorting-${this.modelName}${this.modelNameSuffix}`, (sortingRules) => {
|
|
377
|
+
this.model.configuration.order = sortingRules;
|
|
378
|
+
this.onConfigurationChange();
|
|
379
|
+
});
|
|
380
|
+
this.$puiEvents.$on(`onPui-apply-sorting-dataTable-${this.modelName}${this.modelNameSuffix}`, (sortingRules) => {
|
|
381
|
+
this.model.configuration.order = sortingRules;
|
|
382
|
+
this.onConfigurationChange();
|
|
383
|
+
});
|
|
384
|
+
this.$puiEvents.$on(`onPui-changeRowNum-dataTable-${this.modelName}${this.modelNameSuffix}`, (rowNum) => {
|
|
385
|
+
this.model.configuration.rows = rowNum;
|
|
386
|
+
this.onConfigurationChange();
|
|
387
|
+
});
|
|
388
|
+
this.$puiEvents.$on(`onPui-fixedColumn-dataTable-${this.modelName}${this.modelNameSuffix}`, (columnInfo) => {
|
|
389
|
+
const columnIndex = columnInfo[0];
|
|
390
|
+
const newCols = columnInfo[1];
|
|
391
|
+
const pinColumn = columnIndex !== -1;
|
|
392
|
+
if (pinColumn === true) {
|
|
393
|
+
this.moveColumnToFirst(newCols);
|
|
394
|
+
this.model.configuration.grouped = false;
|
|
395
|
+
}
|
|
396
|
+
this.model.configuration.pinColumn = pinColumn;
|
|
397
|
+
this.onConfigurationChange();
|
|
398
|
+
});
|
|
399
|
+
this.$puiEvents.$on(`onPui-groupColumn-dataTable-${this.modelName}${this.modelNameSuffix}`, (columnIndex) => {
|
|
400
|
+
const grouped = columnIndex !== -1;
|
|
401
|
+
if (grouped === true) {
|
|
402
|
+
this.model.configuration.pinColumn = false;
|
|
403
|
+
}
|
|
404
|
+
this.model.configuration.grouped = grouped;
|
|
405
|
+
this.onConfigurationChange();
|
|
406
|
+
});
|
|
407
|
+
this.$puiEvents.$on(`onPui-selectItem-dataTable-${this.modelName}${this.modelNameSuffix}`, (selectedRows) => {
|
|
408
|
+
this.model.configuration.selectedRows = selectedRows;
|
|
409
|
+
});
|
|
410
|
+
this.$puiEvents.$on(`onPui-clearSelection-dataTable-${this.modelName}${this.modelNameSuffix}`, () => {
|
|
411
|
+
this.model.configuration.selectedRows = [];
|
|
412
|
+
});
|
|
413
|
+
},
|
|
414
|
+
moveColumnToFirst(newCols) {
|
|
415
|
+
for (let i = 0, length = newCols.length; i < length; i++) {
|
|
416
|
+
const name = newCols[i].name;
|
|
417
|
+
const iteratedCol = this.model.configuration.columns.find((col) => col.name === name);
|
|
418
|
+
iteratedCol.order = i;
|
|
419
|
+
}
|
|
420
|
+
this.setVisibleColumns(this.model.configuration.columns);
|
|
421
|
+
},
|
|
422
|
+
setGridModel() {
|
|
423
|
+
this.modelGridConfigurations = this.$store.getters.getGridConfigurationsForModel(this.modelName);
|
|
424
|
+
if (this.modelGridConfigurations !== undefined) {
|
|
425
|
+
this.setConfiguration();
|
|
426
|
+
}
|
|
427
|
+
},
|
|
428
|
+
setConfiguration() {
|
|
429
|
+
const addNewConfiguration = () => {
|
|
430
|
+
this.model = {};
|
|
431
|
+
this.model.id = null;
|
|
432
|
+
this.method = 'create';
|
|
433
|
+
this.model.configuration = this.modelTemplate;
|
|
434
|
+
this.model.configuration.columns = this.columns;
|
|
435
|
+
this.model.configuration.order = [];
|
|
436
|
+
this.$store.commit('puiModelsSetCurrentGridConfiguration', { model: this.modelName, configuration: this.model });
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
if (this.modelGridConfigurations !== undefined && this.modelGridConfigurations.length > 0) {
|
|
440
|
+
const currentConfig = this.$store.getters.getCurrentGridConfiguration(this.modelName);
|
|
441
|
+
if (currentConfig) {
|
|
442
|
+
//here we clone the configuration object in order to do the undo action later on
|
|
443
|
+
this.avoidWatch = true;
|
|
444
|
+
this.$parent.states.unsaved = (currentConfig.edited && currentConfig.id !== -1) || false;
|
|
445
|
+
this.updated = this.$parent.states.unsaved;
|
|
446
|
+
this.model = currentConfig;
|
|
447
|
+
this.method = 'update';
|
|
448
|
+
this.$parent.states.applied = true;
|
|
449
|
+
this.configurationId = this.model.id;
|
|
450
|
+
} else {
|
|
451
|
+
addNewConfiguration(this.modelGridConfigurations.length);
|
|
452
|
+
}
|
|
453
|
+
} else {
|
|
454
|
+
this.configurationSelectorDisabled = true;
|
|
455
|
+
addNewConfiguration();
|
|
456
|
+
}
|
|
457
|
+
},
|
|
458
|
+
showColumnDialog() {
|
|
459
|
+
//subscribeOrNotSubscribe
|
|
460
|
+
this.$parent.states.active = false;
|
|
461
|
+
this.dialogs.columnSelector = true;
|
|
462
|
+
},
|
|
463
|
+
beforeSave(configProperties) {
|
|
464
|
+
if (configProperties) {
|
|
465
|
+
this.model.configuration.name = configProperties.name;
|
|
466
|
+
this.model.configuration.description = configProperties.description;
|
|
467
|
+
this.model.configuration.isdefault = configProperties.isdefault;
|
|
468
|
+
}
|
|
469
|
+
this.model.type = 'datatables';
|
|
470
|
+
this.model.usr = this.$store.getters.getUser;
|
|
471
|
+
this.model.model = this.modelName;
|
|
472
|
+
this.model.configuration.columns.forEach((theColumn) => {
|
|
473
|
+
delete theColumn.bSortable;
|
|
474
|
+
delete theColumn.bVisible;
|
|
475
|
+
delete theColumn.mData;
|
|
476
|
+
delete theColumn.orderable;
|
|
477
|
+
delete theColumn.sName;
|
|
478
|
+
delete theColumn.sTitle;
|
|
479
|
+
delete theColumn.sType;
|
|
480
|
+
});
|
|
481
|
+
delete this.model.configuration.selectedRows;
|
|
482
|
+
delete this.model.configuration.page;
|
|
483
|
+
delete this.model.name;
|
|
484
|
+
this.model.configuration = JSON.stringify(this.model.configuration);
|
|
485
|
+
this.configurationSelectorDisabled = true;
|
|
486
|
+
return this.model;
|
|
487
|
+
},
|
|
488
|
+
afterSave(savedConfig) {
|
|
489
|
+
const onFinishAfterSave = () => {
|
|
490
|
+
this.configurationSelectorDisabled = false;
|
|
491
|
+
this.dialogs.edit = false;
|
|
492
|
+
this.notifyChange = false;
|
|
493
|
+
this.onConfigurationChange();
|
|
494
|
+
};
|
|
495
|
+
this.model = savedConfig;
|
|
496
|
+
let patching = false;
|
|
497
|
+
this.model.configuration = JSON.parse(savedConfig.configuration);
|
|
498
|
+
this.setVisibleColumns(this.model.configuration.columns);
|
|
499
|
+
if (this.model.configuration.isdefault === true) {
|
|
500
|
+
this.modelGridConfigurations.forEach((config) => {
|
|
501
|
+
if (this.model.id !== config.id && config.id !== -1 && config.configuration.isdefault) {
|
|
502
|
+
patching = true;
|
|
503
|
+
config.configuration.isdefault = false;
|
|
504
|
+
this.$puiRequests.patchRequest(
|
|
505
|
+
`${this.modelDependency.url.patch}?id=${config.id}`,
|
|
506
|
+
{
|
|
507
|
+
configuration: JSON.stringify(config.configuration)
|
|
508
|
+
},
|
|
509
|
+
() => {
|
|
510
|
+
patching = false;
|
|
511
|
+
onFinishAfterSave();
|
|
512
|
+
},
|
|
513
|
+
() => {
|
|
514
|
+
patching = false;
|
|
515
|
+
onFinishAfterSave();
|
|
516
|
+
}
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
const currentConfig = this.cloneConfiguration(this.model);
|
|
522
|
+
if (this.method === 'update') {
|
|
523
|
+
this.$store.commit('deleteGridConfiguration', { model: this.modelName, configuration: currentConfig });
|
|
524
|
+
}
|
|
525
|
+
this.$store.commit('addGridConfiguration', { model: this.modelName, configuration: currentConfig });
|
|
526
|
+
this.modelGridConfigurations = this.$store.getters.getGridConfigurationsForModel(this.modelName);
|
|
527
|
+
this.configurationId = this.model.id;
|
|
528
|
+
!patching && onFinishAfterSave();
|
|
529
|
+
},
|
|
530
|
+
calculatePosition() {
|
|
531
|
+
if (this.position === undefined || this.$refs.dialog === undefined) {
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
this.$refs.dialog.style.top = this.position.top + 'px';
|
|
535
|
+
this.$refs.dialog.style.right = '0px';
|
|
536
|
+
},
|
|
537
|
+
setVisibleColumns(columns, sort = true) {
|
|
538
|
+
sort === true &&
|
|
539
|
+
columns.sort((col1, col2) => {
|
|
540
|
+
return col1.order - col2.order;
|
|
541
|
+
});
|
|
542
|
+
//las columnas que en esta configuración se ven
|
|
543
|
+
this.visibleColumns = columns.filter((column) => {
|
|
544
|
+
return column.visible === true;
|
|
545
|
+
});
|
|
546
|
+
},
|
|
547
|
+
getData() {
|
|
548
|
+
return this.model;
|
|
549
|
+
},
|
|
550
|
+
applyColumnConfig() {
|
|
551
|
+
if (this.selectedColumns.length === 0) {
|
|
552
|
+
this.dialogs.columnSelector = false;
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
this.model.configuration.columns = this.columns;
|
|
556
|
+
this.model.configuration.columns.forEach((theColumn, index) => {
|
|
557
|
+
theColumn.visible = false;
|
|
558
|
+
theColumn.data = theColumn.name;
|
|
559
|
+
theColumn.order = this.columns.length + index;
|
|
560
|
+
for (let i = 0, length = this.selectedColumns.length; i < length; i++) {
|
|
561
|
+
if (theColumn.name === this.selectedColumns[i].name) {
|
|
562
|
+
theColumn.order = i;
|
|
563
|
+
theColumn.visible = true;
|
|
564
|
+
theColumn.bVisible = true;
|
|
565
|
+
break;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
this.setVisibleColumns(this.model.configuration.columns);
|
|
570
|
+
this.dialogs.columnSelector = false;
|
|
571
|
+
this.$puiEvents.$emit(`onPui-apply-configuration-${this.modelName}`, this.model.configuration);
|
|
572
|
+
this.onConfigurationChange();
|
|
573
|
+
},
|
|
574
|
+
deleteConfig() {
|
|
575
|
+
this.configurationSelectorDisabled = true;
|
|
576
|
+
const params = { id: this.model.id };
|
|
577
|
+
this.$puiRequests.deleteRequest(
|
|
578
|
+
`/${this.modelDependencyName}/delete`,
|
|
579
|
+
null,
|
|
580
|
+
(response) => {
|
|
581
|
+
this.onConfDeleted(response.data);
|
|
582
|
+
this.serverMessage = this.$t('pui9.delete.success');
|
|
583
|
+
this.colorMessage = 'success';
|
|
584
|
+
this.showMessage = true;
|
|
585
|
+
},
|
|
586
|
+
(error) => {
|
|
587
|
+
if (error.response) {
|
|
588
|
+
if (error.response.data && error.response.data.message) {
|
|
589
|
+
this.serverMessage = error.response.data.message;
|
|
590
|
+
} else if (error.response.status === 400) {
|
|
591
|
+
this.serverMessage = this.$t('pui9.error.service_not_found');
|
|
592
|
+
} else if (error.response.status === 500) {
|
|
593
|
+
this.serverMessage = this.$t('pui9.error.service_not_available');
|
|
594
|
+
}
|
|
595
|
+
} else if (error.data) {
|
|
596
|
+
this.serverMessage = error.data.message;
|
|
597
|
+
} else if (error.message) {
|
|
598
|
+
this.serverMessage = error.message;
|
|
599
|
+
}
|
|
600
|
+
this.colorMessage = 'error';
|
|
601
|
+
this.showMessage = true;
|
|
602
|
+
this.configurationSelectorDisabled = false;
|
|
603
|
+
},
|
|
604
|
+
params
|
|
605
|
+
);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
</script>
|
|
610
|
+
<style lang="postcss">
|
|
611
|
+
.puiDialog__title {
|
|
612
|
+
font-size: 25px;
|
|
613
|
+
line-height: 40px;
|
|
614
|
+
font-weight: 500;
|
|
615
|
+
}
|
|
616
|
+
.puiConf-dialog {
|
|
617
|
+
&--unsaved {
|
|
618
|
+
&.puiConf-dialog__select .v-input__slot {
|
|
619
|
+
background-color: var(--Y-25) !important;
|
|
620
|
+
border-color: var(--secondarycolor) !important;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
&__dot {
|
|
624
|
+
color: var(--secondarycolor);
|
|
625
|
+
font-size: 60px;
|
|
626
|
+
position: absolute;
|
|
627
|
+
top: -5px;
|
|
628
|
+
}
|
|
629
|
+
&__icon {
|
|
630
|
+
font-size: 12px !important;
|
|
631
|
+
color: var(--N-200);
|
|
632
|
+
}
|
|
633
|
+
&__select {
|
|
634
|
+
& .v-list__tile__title {
|
|
635
|
+
white-space: normal !important;
|
|
636
|
+
height: 100%;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
</style>
|