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,287 @@
|
|
|
1
|
+
import generalActions from '../generalActions';
|
|
2
|
+
import PuiToolbarBtnMixin from './PuiToolbarBtnMixin';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
mixins: [PuiToolbarBtnMixin],
|
|
6
|
+
props: {
|
|
7
|
+
modelName: {
|
|
8
|
+
type: String,
|
|
9
|
+
required: true
|
|
10
|
+
},
|
|
11
|
+
actions: {
|
|
12
|
+
type: [Array],
|
|
13
|
+
default: () => {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
insideForm: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: false
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
data() {
|
|
23
|
+
return {
|
|
24
|
+
idTool: 'actions',
|
|
25
|
+
internalActions: [],
|
|
26
|
+
favoriteIds: [],
|
|
27
|
+
panel: {
|
|
28
|
+
position: {}
|
|
29
|
+
},
|
|
30
|
+
label: '',
|
|
31
|
+
selectedRows: [],
|
|
32
|
+
externalActions: [],
|
|
33
|
+
generalActions: [],
|
|
34
|
+
sessionUser: null,
|
|
35
|
+
controller: '/puiusermodelconfig',
|
|
36
|
+
serverConfigId: null,
|
|
37
|
+
showPuiCopyAction: false,
|
|
38
|
+
showPuiImportExportAction: false,
|
|
39
|
+
importExportModelName: null
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
computed: {
|
|
43
|
+
compClass() {
|
|
44
|
+
return {
|
|
45
|
+
'pui-toolbar__btn--darkapplied': this.states.applied,
|
|
46
|
+
'pui-toolbar__btn--active': this.states.active
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
showPuiDocgenAction() {
|
|
50
|
+
const thisModel = this.$store.getters.getModelByName(this.modelName);
|
|
51
|
+
return thisModel && thisModel.name !== 'puidocgentemplate' && thisModel.entity !== null && thisModel.withDocgen;
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
methods: {
|
|
55
|
+
getFavoriteActionsSavedAtServer(model) {
|
|
56
|
+
if (model && model.configurations && model.configurations.favactions) {
|
|
57
|
+
if (Array.isArray(model.configurations.favactions)) {
|
|
58
|
+
var config = model.configurations.favactions[0];
|
|
59
|
+
this.serverConfigId = config.id;
|
|
60
|
+
this.favoriteIds = config.configuration;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Cargar acciones
|
|
64
|
+
this.loadActions();
|
|
65
|
+
},
|
|
66
|
+
isActionFavorite(action) {
|
|
67
|
+
if (this.favoriteIds) {
|
|
68
|
+
for (let i = 0, length = this.favoriteIds.length; i < length; i++) {
|
|
69
|
+
const actId = this.favoriteIds[i];
|
|
70
|
+
if (action.id === actId) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
},
|
|
77
|
+
loadActions() {
|
|
78
|
+
// crear el array de acciones para trabajar
|
|
79
|
+
for (let i = 0, length = this.actions.length; i < length; i++) {
|
|
80
|
+
const action = this.actions[i];
|
|
81
|
+
const decoratedAction = this.decorateAction(action);
|
|
82
|
+
this.internalActions.push(decoratedAction);
|
|
83
|
+
}
|
|
84
|
+
for (let j = 0, length = this.externalActions.length; j < length; j++) {
|
|
85
|
+
const extAction = this.externalActions[j];
|
|
86
|
+
const decoratedExtAction = this.decorateAction(extAction);
|
|
87
|
+
this.internalActions.push(decoratedExtAction);
|
|
88
|
+
}
|
|
89
|
+
for (let k = 0, length = this.generalActions.length; k < length; k++) {
|
|
90
|
+
const generalAction = this.generalActions[k];
|
|
91
|
+
if (this.insideForm && !generalAction.showInForm) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (this.showPuiCopyAction && generalAction.id === 'copyAction') {
|
|
95
|
+
const decoratedGeneralAction = this.decorateAction(generalAction);
|
|
96
|
+
this.internalActions.push(decoratedGeneralAction);
|
|
97
|
+
} else if (this.showPuiImportExportAction && (generalAction.id === 'puiImportAction' || generalAction.id === 'puiExportAction')) {
|
|
98
|
+
const decoratedGeneralAction = this.decorateAction(generalAction);
|
|
99
|
+
this.internalActions.push(decoratedGeneralAction);
|
|
100
|
+
} else if (this.showPuiDocgenAction && generalAction.id === 'puiDocgenAction') {
|
|
101
|
+
const decoratedGeneralAction = this.decorateAction(generalAction);
|
|
102
|
+
this.internalActions.push(decoratedGeneralAction);
|
|
103
|
+
} else if (generalAction.id === 'puiAuditAction') {
|
|
104
|
+
const decoratedGeneralAction = this.decorateAction(generalAction);
|
|
105
|
+
this.internalActions.push(decoratedGeneralAction);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
decorateAction(action) {
|
|
110
|
+
var actionImprovements = {
|
|
111
|
+
runnable: true,
|
|
112
|
+
disabled: false,
|
|
113
|
+
favorite: this.isActionFavorite(action)
|
|
114
|
+
};
|
|
115
|
+
return Object.assign(actionImprovements, action);
|
|
116
|
+
},
|
|
117
|
+
showSubPanel() {
|
|
118
|
+
if (!this.states.applied) {
|
|
119
|
+
this.validateActions();
|
|
120
|
+
this.states.active = !this.states.active;
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
validateActions() {
|
|
124
|
+
for (let i = 0, length = this.internalActions.length; i < length; i++) {
|
|
125
|
+
const action = this.internalActions[i];
|
|
126
|
+
if (action.selectionType === 'single') {
|
|
127
|
+
var enable = action.checkAvailability.call(this, this.selectedRows);
|
|
128
|
+
if (this.selectedRows.length === 1 && enable) {
|
|
129
|
+
action.runnable = true;
|
|
130
|
+
} else {
|
|
131
|
+
action.runnable = false;
|
|
132
|
+
}
|
|
133
|
+
} else if (action.selectionType === 'multiple') {
|
|
134
|
+
action.runnable = true;
|
|
135
|
+
} else if (action.selectionType === 'general') {
|
|
136
|
+
action.runnable = true;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
saveFavoriteActionsSelected() {
|
|
141
|
+
var saveInStore = obj => {
|
|
142
|
+
this.$store.commit('saveFavsAction', obj);
|
|
143
|
+
};
|
|
144
|
+
var favIds = [];
|
|
145
|
+
for (let i = 0, length = this.internalActions.length; i < length; i++) {
|
|
146
|
+
const action = this.internalActions[i];
|
|
147
|
+
if (action.favorite) {
|
|
148
|
+
favIds.push(action.id);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
var usr = this.sessionUser;
|
|
152
|
+
var modelName = this.modelName;
|
|
153
|
+
var favIdsStr = JSON.stringify(favIds);
|
|
154
|
+
var me = this;
|
|
155
|
+
var messageError = this.$t('messageError');
|
|
156
|
+
var titleError = this.$t('titleError');
|
|
157
|
+
if (this.serverConfigId === null) {
|
|
158
|
+
var controllerInsert = this.controller + '/insert';
|
|
159
|
+
var paramsInsert = {
|
|
160
|
+
configuration: favIdsStr,
|
|
161
|
+
model: modelName,
|
|
162
|
+
type: 'favactions',
|
|
163
|
+
usr: usr
|
|
164
|
+
};
|
|
165
|
+
this.$puiRequests.postRequest(
|
|
166
|
+
controllerInsert,
|
|
167
|
+
paramsInsert,
|
|
168
|
+
response => {
|
|
169
|
+
const data = response.data;
|
|
170
|
+
data.configuration = JSON.parse(data.configuration);
|
|
171
|
+
me.serverConfigId = data.id;
|
|
172
|
+
saveInStore({ model: modelName, data: data });
|
|
173
|
+
},
|
|
174
|
+
err => {
|
|
175
|
+
if (err) {
|
|
176
|
+
this.$puiNotify.error(messageError, titleError);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
} else {
|
|
181
|
+
var controllerUpdate = this.controller + '/update';
|
|
182
|
+
var paramsUpdate = {
|
|
183
|
+
configuration: favIdsStr,
|
|
184
|
+
model: modelName,
|
|
185
|
+
id: this.serverConfigId,
|
|
186
|
+
type: 'favactions',
|
|
187
|
+
usr: usr
|
|
188
|
+
};
|
|
189
|
+
this.$puiRequests.putRequest(
|
|
190
|
+
controllerUpdate,
|
|
191
|
+
paramsUpdate,
|
|
192
|
+
response => {
|
|
193
|
+
const data = response.data;
|
|
194
|
+
data.configuration = JSON.parse(data.configuration);
|
|
195
|
+
saveInStore({ model: modelName, data: data });
|
|
196
|
+
},
|
|
197
|
+
err => {
|
|
198
|
+
if (err) {
|
|
199
|
+
this.$puiNotify.error(messageError, titleError);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
created() {
|
|
207
|
+
this.sessionUser = this.$store.getters.getUser;
|
|
208
|
+
this.generalActions = generalActions.actions;
|
|
209
|
+
// añadir las acciones externas
|
|
210
|
+
this.$puiEvents.$emit(`onPui-action-get-externals-${this.modelName}`, { actions: this.externalActions });
|
|
211
|
+
// estados del botón principal de acciones
|
|
212
|
+
this.$puiEvents.$on(`onPui-action-before-running-${this.modelName}`, obj => {
|
|
213
|
+
this.states.active = false;
|
|
214
|
+
this.states.applied = true;
|
|
215
|
+
this.label = this.$t(obj.action.label);
|
|
216
|
+
});
|
|
217
|
+
this.$puiEvents.$on(`onPui-action-running-ended-${this.modelName}`, () => {
|
|
218
|
+
this.states.active = false;
|
|
219
|
+
this.states.applied = false;
|
|
220
|
+
this.label = '';
|
|
221
|
+
});
|
|
222
|
+
this.$puiEvents.$on(`onPui-action-running-cancelled-${this.modelName}`, () => {
|
|
223
|
+
this.states.active = false;
|
|
224
|
+
this.states.applied = false;
|
|
225
|
+
this.label = '';
|
|
226
|
+
});
|
|
227
|
+
// trabajar con las acciones favoritas
|
|
228
|
+
this.$puiEvents.$on('onPui-action-set-favorite-' + this.modelName, obj => {
|
|
229
|
+
var actId = obj.action.id;
|
|
230
|
+
for (let i = 0, length = this.internalActions.length; i < length; i++) {
|
|
231
|
+
const theaction = this.internalActions[i];
|
|
232
|
+
if (theaction.id === actId) {
|
|
233
|
+
theaction.favorite = true;
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
this.$puiEvents.$emit('onPui-action-refresh-favorites-' + this.modelName);
|
|
238
|
+
this.saveFavoriteActionsSelected();
|
|
239
|
+
});
|
|
240
|
+
this.$puiEvents.$on('onPui-action-unset-favorite-' + this.modelName, obj => {
|
|
241
|
+
var actId = obj.action.id;
|
|
242
|
+
for (let i = 0, length = this.internalActions.length; i < length; i++) {
|
|
243
|
+
const theaction = this.internalActions[i];
|
|
244
|
+
if (theaction.id === actId) {
|
|
245
|
+
theaction.favorite = false;
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
this.$puiEvents.$emit('onPui-action-refresh-favorites-' + this.modelName);
|
|
250
|
+
this.saveFavoriteActionsSelected();
|
|
251
|
+
});
|
|
252
|
+
// gestion de elementos seleccionados
|
|
253
|
+
this.$puiEvents.$on(`onPui-selectItem-dataTable-${this.modelName}`, selectedRows => {
|
|
254
|
+
this.selectedRows = selectedRows.map(row => {
|
|
255
|
+
return Object.values(row)[0];
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
this.$puiEvents.$on(`onPui-clearSelection-dataTable-${this.modelName}`, () => {
|
|
259
|
+
this.selectedRows = [];
|
|
260
|
+
});
|
|
261
|
+
this.$puiEvents.$on(`onPui-form-afterGetData-${this.modelName}`, selectedModel => {
|
|
262
|
+
this.selectedRows = [selectedModel];
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
const model = this.$store.getters.getModelByName(this.modelName);
|
|
266
|
+
|
|
267
|
+
this.showPuiCopyAction = model.defaultConfiguration.actionCopy && this.$store.getters.hasFunctionality(model.functionalities.insert);
|
|
268
|
+
this.showPuiImportExportAction = model && model.defaultConfiguration.actionImportExport;
|
|
269
|
+
if (this.showPuiImportExportAction) {
|
|
270
|
+
this.importExportModelName = `${model.name}_importexport`;
|
|
271
|
+
const modelImportExport = Object.assign({}, model);
|
|
272
|
+
modelImportExport.name = this.importExportModelName;
|
|
273
|
+
this.$store.commit('puiModelsAddModel', modelImportExport);
|
|
274
|
+
}
|
|
275
|
+
this.getFavoriteActionsSavedAtServer(model);
|
|
276
|
+
},
|
|
277
|
+
destroyed() {
|
|
278
|
+
this.$puiEvents.$off(`onPui-action-before-running-${this.modelName}`);
|
|
279
|
+
this.$puiEvents.$off(`onPui-action-running-ended-${this.modelName}`);
|
|
280
|
+
this.$puiEvents.$off(`onPui-action-running-cancelled-${this.modelName}`);
|
|
281
|
+
this.$puiEvents.$off(`onPui-action-set-favorite-${this.modelName}`);
|
|
282
|
+
this.$puiEvents.$off(`onPui-action-unset-favorite-${this.modelName}`);
|
|
283
|
+
this.$puiEvents.$off(`onPui-selectItem-dataTable-${this.modelName}`);
|
|
284
|
+
this.$puiEvents.$off(`onPui-clearSelection-dataTable-${this.modelName}`);
|
|
285
|
+
this.$puiEvents.$off(`onPui-form-afterGetData-${this.modelName}`);
|
|
286
|
+
}
|
|
287
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import PuiToolbarDialogMixin from './PuiToolbarDialogMixin';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
mixins: [PuiToolbarDialogMixin],
|
|
5
|
+
props: {
|
|
6
|
+
position: {
|
|
7
|
+
type: Object
|
|
8
|
+
},
|
|
9
|
+
modelName: {
|
|
10
|
+
type: String,
|
|
11
|
+
required: true
|
|
12
|
+
},
|
|
13
|
+
visibility: {
|
|
14
|
+
type: Boolean,
|
|
15
|
+
default: true
|
|
16
|
+
},
|
|
17
|
+
actions: {
|
|
18
|
+
type: [Array],
|
|
19
|
+
default: () => {
|
|
20
|
+
return [];
|
|
21
|
+
},
|
|
22
|
+
required: false
|
|
23
|
+
},
|
|
24
|
+
insideForm: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: false
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
data() {
|
|
30
|
+
return {
|
|
31
|
+
internalActions: {
|
|
32
|
+
all: [],
|
|
33
|
+
favorites: []
|
|
34
|
+
},
|
|
35
|
+
actionsAll: [],
|
|
36
|
+
actionsFavorites: [],
|
|
37
|
+
filteredActionsAll: [],
|
|
38
|
+
filteredActionsFavorites: [],
|
|
39
|
+
searchAll: '',
|
|
40
|
+
searchFav: '',
|
|
41
|
+
tabActive: 'tab2',
|
|
42
|
+
userFilterModelName: 'puiusermodelfilter',
|
|
43
|
+
firstLoad: true
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
created() {
|
|
47
|
+
this.$puiEvents.$on('onPui-action-refresh-favorites-' + this.modelName, () => {
|
|
48
|
+
this.loadRefreshActions();
|
|
49
|
+
});
|
|
50
|
+
//
|
|
51
|
+
this.loadRefreshActions();
|
|
52
|
+
},
|
|
53
|
+
mounted() {
|
|
54
|
+
this.calculatePosition();
|
|
55
|
+
},
|
|
56
|
+
beforeDestroy() {
|
|
57
|
+
this.$puiEvents.$off('onPui-action-refresh-favorites-' + this.modelName);
|
|
58
|
+
},
|
|
59
|
+
updated() {
|
|
60
|
+
this.calculatePosition();
|
|
61
|
+
},
|
|
62
|
+
computed: {
|
|
63
|
+
getPlaceholder() {
|
|
64
|
+
return this.$t('puidatatables.searchPlaceholder');
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
methods: {
|
|
68
|
+
loadRefreshActions() {
|
|
69
|
+
this.internalActions.all = [];
|
|
70
|
+
this.filteredActionsAll = [];
|
|
71
|
+
this.internalActions.favorites = [];
|
|
72
|
+
this.filteredActionsFavorites = [];
|
|
73
|
+
|
|
74
|
+
for (let i = 0, length = this.actions.length; i < length; i++) {
|
|
75
|
+
const action = this.actions[i];
|
|
76
|
+
const hasPermission = this.checkPermissionAction(action);
|
|
77
|
+
if (hasPermission) {
|
|
78
|
+
this.parseAction(action);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
refreshFavorites() {
|
|
83
|
+
this.filteredActionsFavorites = [];
|
|
84
|
+
for (let index = 0, length = this.filteredActionsAll.length; index < length; index++) {
|
|
85
|
+
const action = this.filteredActionsAll[index];
|
|
86
|
+
if (action.favorite) {
|
|
87
|
+
this.filteredActionsFavorites.push(action);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
parseAction(action) {
|
|
92
|
+
this.internalActions.all.push(action);
|
|
93
|
+
this.filteredActionsAll.push(action);
|
|
94
|
+
if (action.favorite) {
|
|
95
|
+
this.internalActions.favorites.push(action);
|
|
96
|
+
this.filteredActionsFavorites.push(action);
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
checkPermissionAction(action) {
|
|
100
|
+
const session = this.$store.getters.getSession;
|
|
101
|
+
if (session) {
|
|
102
|
+
const functionalities = session.functionalities;
|
|
103
|
+
if (functionalities && functionalities.length > 0) {
|
|
104
|
+
for (let index = 0, length = functionalities.length; index < length; index++) {
|
|
105
|
+
const func = functionalities[index];
|
|
106
|
+
if (action.functionality === null || func === action.functionality) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
113
|
+
},
|
|
114
|
+
resizeTabSlider() {
|
|
115
|
+
var self = this;
|
|
116
|
+
setTimeout(function () {
|
|
117
|
+
if (self.tabActive === 'tab1') {
|
|
118
|
+
self.$refs.tabs.sliderWidth = self.$refs.tab1.$el.offsetWidth;
|
|
119
|
+
}
|
|
120
|
+
if (self.tabActive === 'tab2') {
|
|
121
|
+
self.$refs.tabs.sliderWidth = self.$refs.tab2.$el.offsetWidth;
|
|
122
|
+
self.$refs.tabs.sliderLeft = self.$refs.tab1.$el.offsetWidth;
|
|
123
|
+
}
|
|
124
|
+
}, 100);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
watch: {
|
|
128
|
+
visibility(val) {
|
|
129
|
+
// HACK GET STYLE FIRST TAB
|
|
130
|
+
if (val && this.firstLoad) {
|
|
131
|
+
this.firstLoad = false;
|
|
132
|
+
this.$refs.tabs.$emit('change', 'tab1');
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
tabActive() {
|
|
136
|
+
this.resizeTabSlider();
|
|
137
|
+
},
|
|
138
|
+
searchAll(val) {
|
|
139
|
+
if (val && val.length > 0) {
|
|
140
|
+
this.filteredActionsAll = this.internalActions.all.filter((action) => {
|
|
141
|
+
var title = this.$puiI18n.t(action.label);
|
|
142
|
+
return title.toUpperCase().match(val.toUpperCase());
|
|
143
|
+
});
|
|
144
|
+
} else {
|
|
145
|
+
this.filteredActionsAll = this.internalActions.all;
|
|
146
|
+
}
|
|
147
|
+
this.resizeTabSlider();
|
|
148
|
+
},
|
|
149
|
+
searchFav(val) {
|
|
150
|
+
if (val && val.length > 0) {
|
|
151
|
+
this.filteredActionsFavorites = this.internalActions.favorites.filter((action) => {
|
|
152
|
+
var title = this.$puiI18n.t(action.label);
|
|
153
|
+
return title.toUpperCase().match(val.toUpperCase());
|
|
154
|
+
});
|
|
155
|
+
} else {
|
|
156
|
+
this.filteredActionsFavorites = this.internalActions.favorites;
|
|
157
|
+
}
|
|
158
|
+
this.resizeTabSlider();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
action: {
|
|
4
|
+
type: Object,
|
|
5
|
+
required: true
|
|
6
|
+
},
|
|
7
|
+
modelName: {
|
|
8
|
+
type: String,
|
|
9
|
+
required: true
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
computed: {
|
|
13
|
+
getUniqueID() {
|
|
14
|
+
return `${this.action.id}-${this.modelName}`;
|
|
15
|
+
},
|
|
16
|
+
isSingleAction() {
|
|
17
|
+
return this.action.selectionType === 'single';
|
|
18
|
+
},
|
|
19
|
+
isMultipleAction() {
|
|
20
|
+
return this.action.selectionType === 'multiple';
|
|
21
|
+
},
|
|
22
|
+
isGeneralAction() {
|
|
23
|
+
return this.action.selectionType === 'general';
|
|
24
|
+
},
|
|
25
|
+
isLockedAction() {
|
|
26
|
+
return !this.action.runnable;
|
|
27
|
+
},
|
|
28
|
+
isFavoriteAction() {
|
|
29
|
+
return this.action.favorite;
|
|
30
|
+
},
|
|
31
|
+
getTranslatedLabel() {
|
|
32
|
+
var xlabel = this.$puiI18n.t(this.action.label);
|
|
33
|
+
return xlabel;
|
|
34
|
+
},
|
|
35
|
+
getCompClass() {
|
|
36
|
+
return { 'puiGridActionListItem--locked': !this.action.runnable };
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
methods: {
|
|
40
|
+
selectItem() {
|
|
41
|
+
if (this.action.runnable) {
|
|
42
|
+
var obj = {
|
|
43
|
+
action: this.action,
|
|
44
|
+
modelName: this.modelName
|
|
45
|
+
};
|
|
46
|
+
this.$puiEvents.$emit(`onPui-action-before-running-${this.modelName}`, obj);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
setFavorite() {
|
|
50
|
+
var obj = {
|
|
51
|
+
action: this.action
|
|
52
|
+
};
|
|
53
|
+
this.$puiEvents.$emit(`onPui-action-set-favorite-${this.modelName}`, obj);
|
|
54
|
+
},
|
|
55
|
+
unsetFavorite() {
|
|
56
|
+
var obj = {
|
|
57
|
+
action: this.action
|
|
58
|
+
};
|
|
59
|
+
this.$puiEvents.$emit(`onPui-action-unset-favorite-${this.modelName}`, obj);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default () => ({
|
|
2
|
+
beforeRouteLeave(to, from, next) {
|
|
3
|
+
const comeFrom = this.$puiUtils.getModelFromRouter(from);
|
|
4
|
+
const goTo = this.$puiUtils.getModelFromRouter(to);
|
|
5
|
+
if (comeFrom != goTo && !to.fullPath.includes('/' + comeFrom) && (!this.parentModelName || this.parentModelName !== goTo)) {
|
|
6
|
+
// Delete grid pagination when not matching models in route
|
|
7
|
+
const currentConfig = this.$store.getters.getCurrentGridConfiguration(this.modelName);
|
|
8
|
+
if (currentConfig) {
|
|
9
|
+
currentConfig.page = 1;
|
|
10
|
+
this.$store.commit('puiModelsSetCurrentGridConfiguration', { model: this.modelName, configuration: currentConfig });
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
next();
|
|
14
|
+
}
|
|
15
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
data() {
|
|
3
|
+
return {
|
|
4
|
+
rules: {
|
|
5
|
+
required: value => !!value || this.$t('pui9.error.field_required')
|
|
6
|
+
},
|
|
7
|
+
valid: true,
|
|
8
|
+
formDisabled: false,
|
|
9
|
+
urlParam: null,
|
|
10
|
+
modelsLoaded: false,
|
|
11
|
+
modelLoaded: false,
|
|
12
|
+
model: {}
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
props: {
|
|
16
|
+
pk: {
|
|
17
|
+
type: [Object, String]
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
computed: {
|
|
21
|
+
isCreatingElement() {
|
|
22
|
+
return this.method === 'create';
|
|
23
|
+
},
|
|
24
|
+
onPuiModelsLoadedAndSaved() {
|
|
25
|
+
return this.$store.state.modelsLoadedAndSaved;
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
watch: {
|
|
29
|
+
modelsLoaded(val) {
|
|
30
|
+
val && this.onModelsLoaded();
|
|
31
|
+
val && this.onReady();
|
|
32
|
+
},
|
|
33
|
+
onPuiModelsLoadedAndSaved() {
|
|
34
|
+
this.modelsLoaded = true;
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
created() {
|
|
38
|
+
this.modelDependency = this.$store.getters.getModelByName(this.modelDependencyName);
|
|
39
|
+
},
|
|
40
|
+
mounted() {
|
|
41
|
+
if (this.modelDependency) {
|
|
42
|
+
this.onReady();
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
destroyed() {
|
|
46
|
+
this.$puiEvents.$emit(`onPuiFormDestroyed-${this.modelDependencyName}`);
|
|
47
|
+
},
|
|
48
|
+
methods: {
|
|
49
|
+
save() {
|
|
50
|
+
this.beforeSave && this.beforeSave();
|
|
51
|
+
if (this.$refs.form && this.$refs.form.validate && !this.$refs.form.validate()) {
|
|
52
|
+
this.$puiNotify.error(this.$t('pui9.error.form_errors'));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (this.method === 'update') {
|
|
57
|
+
this.update(this.modelDependency.url.update);
|
|
58
|
+
} else {
|
|
59
|
+
this.insert(this.modelDependency.url.insert);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
update(url) {
|
|
63
|
+
this.$puiRequests.putRequest(
|
|
64
|
+
url,
|
|
65
|
+
this.model,
|
|
66
|
+
response => {
|
|
67
|
+
this.$puiEvents.$emit(`onPui-updateRow-dataTable-${this.modelDependency.name}`, response.data);
|
|
68
|
+
this.afterSave && this.afterSave(response.data);
|
|
69
|
+
},
|
|
70
|
+
error => {
|
|
71
|
+
this.onSaveError && this.onSaveError();
|
|
72
|
+
this.onError(error);
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
},
|
|
76
|
+
insert(url) {
|
|
77
|
+
this.$puiRequests.postRequest(
|
|
78
|
+
url,
|
|
79
|
+
this.model,
|
|
80
|
+
response => {
|
|
81
|
+
this.$puiEvents.$emit(`onPui-insertRow-dataTable-${this.modelDependency.name}`, response.data);
|
|
82
|
+
this.afterSave && this.afterSave(response.data);
|
|
83
|
+
},
|
|
84
|
+
error => {
|
|
85
|
+
this.onSaveError && this.onSaveError();
|
|
86
|
+
this.onError(error);
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
},
|
|
90
|
+
onReady() {
|
|
91
|
+
var pk;
|
|
92
|
+
|
|
93
|
+
let param = null;
|
|
94
|
+
if (this.pk && this.pk !== 'new') {
|
|
95
|
+
pk = JSON.parse(this.$puiUtils.b64ToUtf8(this.pk));
|
|
96
|
+
param =
|
|
97
|
+
'?' +
|
|
98
|
+
Object.keys(pk)
|
|
99
|
+
.map(function(prop) {
|
|
100
|
+
return [prop, pk[prop]].map(encodeURIComponent).join('=');
|
|
101
|
+
})
|
|
102
|
+
.join('&');
|
|
103
|
+
|
|
104
|
+
if (this.method === 'read') {
|
|
105
|
+
this.formDisabled = true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
this.getData(param);
|
|
109
|
+
},
|
|
110
|
+
onModelsLoaded() {
|
|
111
|
+
if (!this.modelDependency) {
|
|
112
|
+
this.modelDependency = this.$store.getters.getModelByName(this.modelDependencyName);
|
|
113
|
+
}
|
|
114
|
+
const controller = this.modelDependency.url.template;
|
|
115
|
+
this.model = this.$puiRequests.getRequest(
|
|
116
|
+
controller,
|
|
117
|
+
null,
|
|
118
|
+
response => {
|
|
119
|
+
if (response && response.data) {
|
|
120
|
+
var data = response.data;
|
|
121
|
+
this.model = data;
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
error => {
|
|
125
|
+
this.onError(error);
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
},
|
|
129
|
+
onError(error) {
|
|
130
|
+
this.$store.dispatch('puiRequestShowServerError', { error });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
methods: {
|
|
3
|
+
cloneConfiguration(gridConfiguration) {
|
|
4
|
+
const newGridConfiguration = Object.assign({}, gridConfiguration);
|
|
5
|
+
newGridConfiguration.configuration = Object.assign({}, gridConfiguration.configuration);
|
|
6
|
+
const columns = [];
|
|
7
|
+
const order = [];
|
|
8
|
+
newGridConfiguration.configuration.order && newGridConfiguration.configuration.order.forEach(sortingRule => order.push(sortingRule));
|
|
9
|
+
newGridConfiguration.configuration.order = order;
|
|
10
|
+
newGridConfiguration.configuration.columns && newGridConfiguration.configuration.columns.forEach(column => columns.push(column));
|
|
11
|
+
newGridConfiguration.configuration.columns = columns;
|
|
12
|
+
return newGridConfiguration;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
};
|