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,317 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<pui-modal-dialog-form
|
|
3
|
+
:overflow="false"
|
|
4
|
+
:titleText="$t('puidocgentemplate.generate.titleConfigDocGen')"
|
|
5
|
+
:modelName="modelName"
|
|
6
|
+
:dialogName="dialogNamePuiDocgenTemplateParameters"
|
|
7
|
+
v-model="dialogData"
|
|
8
|
+
:widthDialog="800"
|
|
9
|
+
:onOk="onOkGenerate"
|
|
10
|
+
:onShow="onShowGenerate"
|
|
11
|
+
:onCancel="onCancel"
|
|
12
|
+
>
|
|
13
|
+
<template slot="message">
|
|
14
|
+
<v-layout wrap class="pui-form-layout">
|
|
15
|
+
<v-flex xs12>
|
|
16
|
+
<pui-field-set
|
|
17
|
+
:title="$t('puidocgentemplate.generate.fieldset.parameters')"
|
|
18
|
+
v-if="model.parameters && model.parameters.length > 0"
|
|
19
|
+
>
|
|
20
|
+
<table class="puidocgentemplate-table">
|
|
21
|
+
<thead>
|
|
22
|
+
<tr>
|
|
23
|
+
<th class="docgen-table-column">{{ $t('puidocgentemplate.generate.parameter.name') }}</th>
|
|
24
|
+
<th class="docgen-table-column">{{ $t('puidocgentemplate.generate.parameter.operation') }}</th>
|
|
25
|
+
<th class="docgen-table-column">{{ $t('puidocgentemplate.generate.parameter.value') }}</th>
|
|
26
|
+
</tr>
|
|
27
|
+
</thead>
|
|
28
|
+
<tbody>
|
|
29
|
+
<tr v-for="parameter in model.parameters" :key="parameter.field">
|
|
30
|
+
<td class="puidocgentemplate-table-column">
|
|
31
|
+
<label>{{ parameter.field }}</label>
|
|
32
|
+
</td>
|
|
33
|
+
<td class="puidocgentemplate-table-column">
|
|
34
|
+
<label>{{ $t(`puidocgentemplate.ops.${parameter.op}`) }}</label>
|
|
35
|
+
</td>
|
|
36
|
+
<td class="puidocgentemplate-table-column">
|
|
37
|
+
<v-text-field
|
|
38
|
+
class="pr-2 inputFilterText"
|
|
39
|
+
type="text"
|
|
40
|
+
solo
|
|
41
|
+
flat
|
|
42
|
+
outlined
|
|
43
|
+
hide-details
|
|
44
|
+
required
|
|
45
|
+
:rules="getRules()"
|
|
46
|
+
v-model="parameter.data"
|
|
47
|
+
></v-text-field>
|
|
48
|
+
</td>
|
|
49
|
+
</tr>
|
|
50
|
+
</tbody>
|
|
51
|
+
</table>
|
|
52
|
+
</pui-field-set>
|
|
53
|
+
<pui-field-set :title="$t('puidocgentemplate.generate.fieldset.mapping')" v-if="model.mappings && model.mappings.length > 0">
|
|
54
|
+
<table class="puidocgentemplate-table">
|
|
55
|
+
<thead>
|
|
56
|
+
<tr>
|
|
57
|
+
<th class="docgen-table-column">{{ $t('puidocgentemplate.generate.mapping.name') }}</th>
|
|
58
|
+
<th class="docgen-table-column">{{ $t('puidocgentemplate.generate.mapping.value') }}</th>
|
|
59
|
+
</tr>
|
|
60
|
+
</thead>
|
|
61
|
+
<tbody>
|
|
62
|
+
<tr v-for="mapping in model.mappings" :key="mapping.field">
|
|
63
|
+
<td class="puidocgentemplate-table-column">
|
|
64
|
+
<label>{{ mapping.field }}</label>
|
|
65
|
+
</td>
|
|
66
|
+
<td class="puidocgentemplate-table-column">
|
|
67
|
+
<v-text-field
|
|
68
|
+
class="pr-2 inputFilterText"
|
|
69
|
+
type="text"
|
|
70
|
+
solo
|
|
71
|
+
flat
|
|
72
|
+
outlined
|
|
73
|
+
hide-details
|
|
74
|
+
required
|
|
75
|
+
:rules="getRules()"
|
|
76
|
+
v-model="mapping.val"
|
|
77
|
+
></v-text-field>
|
|
78
|
+
</td>
|
|
79
|
+
</tr>
|
|
80
|
+
</tbody>
|
|
81
|
+
</table>
|
|
82
|
+
</pui-field-set>
|
|
83
|
+
<pui-checkbox v-if="!hideGeneratePdf" :label="$t('puidocgentemplate.generate.topdf')" v-model="model.generatePdf"></pui-checkbox>
|
|
84
|
+
</v-flex>
|
|
85
|
+
</v-layout>
|
|
86
|
+
</template>
|
|
87
|
+
</pui-modal-dialog-form>
|
|
88
|
+
</template>
|
|
89
|
+
|
|
90
|
+
<script>
|
|
91
|
+
export default {
|
|
92
|
+
name: 'PuiDocgenTemplateParametersDialog',
|
|
93
|
+
data() {
|
|
94
|
+
return {
|
|
95
|
+
modelName: 'puidocgentemplate',
|
|
96
|
+
model: {},
|
|
97
|
+
dialogData: {},
|
|
98
|
+
dialogNamePuiDocgenTemplateParameters: 'puiDocgenTemplateParameters',
|
|
99
|
+
defaultFilter: null,
|
|
100
|
+
hideGeneratePdf: undefined
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
props: {
|
|
104
|
+
parentModelName: {
|
|
105
|
+
type: String,
|
|
106
|
+
default: ''
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
watch: {
|
|
110
|
+
dialogData: {
|
|
111
|
+
handler(newValue) {
|
|
112
|
+
if (Object.keys(newValue).length > 0) {
|
|
113
|
+
if (newValue.isAction && newValue.model && newValue.registry) {
|
|
114
|
+
this.getToGenerate(newValue);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
deep: true
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
methods: {
|
|
122
|
+
getRules() {
|
|
123
|
+
return [(value) => !!value || 'Required'];
|
|
124
|
+
},
|
|
125
|
+
getToGenerate(data) {
|
|
126
|
+
this.docgenModel = data.model;
|
|
127
|
+
this.docgenRegistries = data.registries;
|
|
128
|
+
this.docgenParameters = data.parameters;
|
|
129
|
+
const params = { id: data.registry.id };
|
|
130
|
+
|
|
131
|
+
this.$puiRequests.getRequest(
|
|
132
|
+
this.docgenModel.url.getToGenerate,
|
|
133
|
+
params,
|
|
134
|
+
(response) => {
|
|
135
|
+
this.$set(this.model, 'id', response.data.id);
|
|
136
|
+
this.$set(this.model, 'mainmodel', response.data.mainmodel);
|
|
137
|
+
this.$set(this.model, 'parameters', JSON.parse(response.data.parameters));
|
|
138
|
+
this.$set(this.model, 'gridFilter', JSON.parse(response.data.filter));
|
|
139
|
+
this.$set(this.model, 'generatePdf', false);
|
|
140
|
+
this.$set(this.model, 'mappings', []);
|
|
141
|
+
|
|
142
|
+
const mapping = JSON.parse(response.data.mapping);
|
|
143
|
+
for (let i = 0, mappingLength = mapping.length; i < mappingLength; i++) {
|
|
144
|
+
const mapp = mapping[i];
|
|
145
|
+
if (mapp.origin === 'U') {
|
|
146
|
+
this.model.mappings.push({
|
|
147
|
+
field: mapp.field,
|
|
148
|
+
val: null
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
for (const storeModelName in this.$store.state.models) {
|
|
153
|
+
const storeModel = this.$store.state.models[storeModelName];
|
|
154
|
+
if (response.data.dataview === storeModel.entity) {
|
|
155
|
+
this.$set(this.model, 'modelName', storeModel.name);
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (!this.requireConfiguration(this.model)) {
|
|
160
|
+
this.onOkGenerate();
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
(error) => {
|
|
164
|
+
const title = this.$puiI18n.t('puiaction.notifyTitle') + ' > ' + this.$t('puiaction.docgen.generate');
|
|
165
|
+
let message = this.$puiI18n.t('puiaction.notifyError');
|
|
166
|
+
if (error.response && error.response.data) {
|
|
167
|
+
message = error.response.data.message;
|
|
168
|
+
}
|
|
169
|
+
this.$puiEvents.$emit(`onPui-action-running-ended-${this.modelName}`);
|
|
170
|
+
// If is called directly from an action
|
|
171
|
+
if (data.parentModel) this.$puiEvents.$emit(`onPui-action-running-ended-${data.parentModel}`);
|
|
172
|
+
this.$puiNotify.error(message, title);
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
},
|
|
176
|
+
requireConfiguration(model) {
|
|
177
|
+
return (
|
|
178
|
+
(model.mappings && model.mappings.length > 0) ||
|
|
179
|
+
(model.parameters && model.parameters.length > 0) ||
|
|
180
|
+
this.hideGeneratePdf === undefined
|
|
181
|
+
);
|
|
182
|
+
},
|
|
183
|
+
onOkGenerate() {
|
|
184
|
+
this.$store.commit('showPuiLoader', this.$t('puidocgentemplate.generate.processing'));
|
|
185
|
+
|
|
186
|
+
const params = this.getParameters();
|
|
187
|
+
return new Promise((resolve) => {
|
|
188
|
+
this.$puiRequests.downloadFileRequest(
|
|
189
|
+
'post',
|
|
190
|
+
this.docgenModel.url.generate,
|
|
191
|
+
params,
|
|
192
|
+
(response) => {
|
|
193
|
+
const link = document.createElement('a');
|
|
194
|
+
link.href = window.URL.createObjectURL(new window.Blob([response.data]));
|
|
195
|
+
link.download = this.$puiUtils.getFilenameFromHeaders(response.headers);
|
|
196
|
+
link.click();
|
|
197
|
+
|
|
198
|
+
this.$store.commit('hidePuiLoader');
|
|
199
|
+
this.endAction();
|
|
200
|
+
resolve(true);
|
|
201
|
+
},
|
|
202
|
+
(error) => {
|
|
203
|
+
const title = this.$puiI18n.t('puiaction.notifyTitle') + ' > ' + this.$t('puiaction.docgen.generate');
|
|
204
|
+
let message = this.$puiI18n.t('puiaction.notifyError');
|
|
205
|
+
if (error.response && error.response.data) {
|
|
206
|
+
message = error.response.data.message;
|
|
207
|
+
}
|
|
208
|
+
this.$store.commit('hidePuiLoader');
|
|
209
|
+
this.endAction();
|
|
210
|
+
this.$puiNotify.error(message, title);
|
|
211
|
+
resolve(true);
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
});
|
|
215
|
+
},
|
|
216
|
+
onCancel() {
|
|
217
|
+
this.endAction();
|
|
218
|
+
return Promise.resolve(true);
|
|
219
|
+
},
|
|
220
|
+
onShowGenerate(modalData) {
|
|
221
|
+
if (modalData.default && (modalData.default.filter || modalData.default.generatePdf)) {
|
|
222
|
+
if (modalData.default.filter) this.defaultFilter = modalData.default.filter;
|
|
223
|
+
if (modalData.default.generatePdf) {
|
|
224
|
+
this.hideGeneratePdf = true;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
getParameters() {
|
|
229
|
+
const params = {
|
|
230
|
+
pk: { id: this.model.id },
|
|
231
|
+
model: this.model.mainmodel,
|
|
232
|
+
mappings: this.model.mappings,
|
|
233
|
+
parameters: this.model.parameters,
|
|
234
|
+
generatePdf: this.hideGeneratePdf || this.model.generatePdf,
|
|
235
|
+
filter: { groupOp: 'or', groups: [], rules: [] }
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
if (this.docgenRegistries && this.docgenRegistries.length > 0) {
|
|
239
|
+
params.filter = this.createFilter();
|
|
240
|
+
if (this.defaultFilter) {
|
|
241
|
+
params.filter.groups.push(this.defaultFilter);
|
|
242
|
+
}
|
|
243
|
+
} else if (this.docgenParameters) {
|
|
244
|
+
for (const prop in this.docgenParameters) {
|
|
245
|
+
if (!Object.prototype.hasOwnProperty.call(this.docgenParameters, prop)) {
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
params[prop] = this.docgenParameters[prop];
|
|
249
|
+
}
|
|
250
|
+
/*
|
|
251
|
+
const currentSearch = this.$parent.$parent.$parent.getCurrentSearch();
|
|
252
|
+
let queryText = '';
|
|
253
|
+
let queryFields = [];
|
|
254
|
+
if (currentSearch !== undefined && currentSearch !== null) {
|
|
255
|
+
queryText = currentSearch[0];
|
|
256
|
+
queryFields = currentSearch[1].map(field => {
|
|
257
|
+
return field.name;
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
params.filter = this.$parent.$parent.$parent.getCurrentFilter();
|
|
261
|
+
params.order = this.$parent.$parent.$parent.getCurrentSorting();
|
|
262
|
+
params.queryText = queryText;
|
|
263
|
+
params.queryFields = queryFields;
|
|
264
|
+
params.queryLang = this.$store.getters.getUserLanguage;
|
|
265
|
+
*/
|
|
266
|
+
}
|
|
267
|
+
return params;
|
|
268
|
+
},
|
|
269
|
+
createFilter() {
|
|
270
|
+
const filter = {
|
|
271
|
+
groupOp: 'or',
|
|
272
|
+
groups: [],
|
|
273
|
+
rules: []
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
for (let i = 0, registriesLength = this.docgenRegistries.length; i < registriesLength; i++) {
|
|
277
|
+
const group = {
|
|
278
|
+
groupOp: 'and',
|
|
279
|
+
groups: [],
|
|
280
|
+
rules: []
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
filter.groups.push(group);
|
|
284
|
+
const registry = this.docgenRegistries[i];
|
|
285
|
+
|
|
286
|
+
for (const property in registry) {
|
|
287
|
+
group.rules.push({ field: property, op: 'eq', data: registry[property] });
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return filter;
|
|
292
|
+
},
|
|
293
|
+
endAction() {
|
|
294
|
+
// No entiendo porque se finaliza this.modelName y no el modelo de donde viene (El Grid), lo mantengo por si las moscas y añado el modelo del grid
|
|
295
|
+
this.$puiEvents.$emit(`onPui-action-running-ended-${this.modelName}`);
|
|
296
|
+
this.$puiEvents.$emit(`onPui-action-running-ended-${this.parentModelName}`);
|
|
297
|
+
this.model = {};
|
|
298
|
+
this.hideGeneratePdf = undefined;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
</script>
|
|
303
|
+
|
|
304
|
+
<style lang="postcss">
|
|
305
|
+
.puidocgentemplate-table {
|
|
306
|
+
margin: 0px auto;
|
|
307
|
+
th.docgen-table-column {
|
|
308
|
+
padding-left: 2px;
|
|
309
|
+
padding-right: 2px;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
.puidocgentemplate-table-column {
|
|
313
|
+
text-align: center;
|
|
314
|
+
padding-left: 2px;
|
|
315
|
+
padding-right: 2px;
|
|
316
|
+
}
|
|
317
|
+
</style>
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-dialog persistent v-model="showDialog" max-width="700px">
|
|
3
|
+
<v-card flat style="border-radius: 6px">
|
|
4
|
+
<v-card-title>
|
|
5
|
+
<div class="puiDialog__title pl-2">{{ $t('puidatatables.select_columns_to_export') }}</div>
|
|
6
|
+
</v-card-title>
|
|
7
|
+
<v-card-text>
|
|
8
|
+
<pui-multi-select
|
|
9
|
+
v-if="showDialog"
|
|
10
|
+
:items="columns"
|
|
11
|
+
:trackItemsToSelect="true"
|
|
12
|
+
:itemsToSelect="visibleColumns"
|
|
13
|
+
itemValue="name"
|
|
14
|
+
itemText="title"
|
|
15
|
+
:textSelected="this.$t('puidatatables.selected_columns')"
|
|
16
|
+
:textAvailable="this.$t('puidatatables.not_selected_columns')"
|
|
17
|
+
:heightList="columnPickerHeight"
|
|
18
|
+
v-model="selectedColumns"
|
|
19
|
+
:flat="true"
|
|
20
|
+
></pui-multi-select>
|
|
21
|
+
<v-layout v-if="showLanguages">
|
|
22
|
+
<v-flex xs12>
|
|
23
|
+
<label :class="{ 'v-label--required': true }">{{ $t('puidatatables.select_language') }}</label>
|
|
24
|
+
</v-flex>
|
|
25
|
+
</v-layout>
|
|
26
|
+
<v-layout v-if="showLanguages">
|
|
27
|
+
<v-flex xs12>
|
|
28
|
+
<v-autocomplete
|
|
29
|
+
:items="languages"
|
|
30
|
+
v-model="langModel.language"
|
|
31
|
+
item-value="isocode"
|
|
32
|
+
item-text="name"
|
|
33
|
+
solo
|
|
34
|
+
text
|
|
35
|
+
required
|
|
36
|
+
:rules="[(value) => !!value || $t('pui9.error.field_required')]"
|
|
37
|
+
:return-object="false"
|
|
38
|
+
/>
|
|
39
|
+
</v-flex>
|
|
40
|
+
</v-layout>
|
|
41
|
+
</v-card-text>
|
|
42
|
+
<v-card-actions class="pl-3 pr-3 pb-2">
|
|
43
|
+
<v-btn text outlined @click="cancelExport()" class="elevation-0">{{ $t('form.cancel') }}</v-btn>
|
|
44
|
+
<v-spacer />
|
|
45
|
+
<v-btn color="primary" @click="doExport()" class="elevation-0">{{ $t('form.apply') }}</v-btn>
|
|
46
|
+
</v-card-actions>
|
|
47
|
+
</v-card>
|
|
48
|
+
</v-dialog>
|
|
49
|
+
</template>
|
|
50
|
+
|
|
51
|
+
<script>
|
|
52
|
+
export default {
|
|
53
|
+
name: 'PuiGridExportDialog',
|
|
54
|
+
props: {
|
|
55
|
+
modelName: {
|
|
56
|
+
type: String,
|
|
57
|
+
required: true
|
|
58
|
+
},
|
|
59
|
+
importExportModelName: {
|
|
60
|
+
type: String,
|
|
61
|
+
required: true
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
data() {
|
|
65
|
+
return {
|
|
66
|
+
exportableColumnsController: '/importexport/getExportableColumns',
|
|
67
|
+
exportController: '/importexport/export',
|
|
68
|
+
showDialog: false,
|
|
69
|
+
showLanguages: false,
|
|
70
|
+
columns: null,
|
|
71
|
+
visibleColumns: null,
|
|
72
|
+
selectedColumns: [],
|
|
73
|
+
languages: [],
|
|
74
|
+
langModel: {
|
|
75
|
+
language: this.$store.getters.getUserLanguage
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
computed: {
|
|
80
|
+
columnPickerHeight() {
|
|
81
|
+
return window.innerHeight > 600 ? 300 : 225;
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
created() {
|
|
85
|
+
this.$puiEvents.$on(`pui-show-exportDialog-${this.importExportModelName}`, () => {
|
|
86
|
+
//this.getExportableColumns();
|
|
87
|
+
this.showDialog = true;
|
|
88
|
+
this.selectedColumns = this.columns;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
this.getLanguages();
|
|
92
|
+
this.getExportableColumns();
|
|
93
|
+
},
|
|
94
|
+
destroyed() {
|
|
95
|
+
this.$puiEvents.$off(`pui-show-exportDialog-${this.importExportModelName}`);
|
|
96
|
+
},
|
|
97
|
+
methods: {
|
|
98
|
+
getLanguages() {
|
|
99
|
+
this.$puiRequests.postRequest('/puilanguage/list', null, (response) => {
|
|
100
|
+
this.languages = response.data.data;
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
getExportableColumns() {
|
|
104
|
+
const params = { model: this.modelName };
|
|
105
|
+
this.$puiRequests.getRequest(
|
|
106
|
+
this.exportableColumnsController,
|
|
107
|
+
params,
|
|
108
|
+
(response) => {
|
|
109
|
+
const currentModel = this.$store.getters.getModelByName(this.modelName);
|
|
110
|
+
const modelColumns = [...currentModel.columns];
|
|
111
|
+
this.columns = response.data;
|
|
112
|
+
this.columns.forEach((column) => {
|
|
113
|
+
if (column.title === 'lang' || column.title === 'langstatus') {
|
|
114
|
+
column.title = this.$t(column.title);
|
|
115
|
+
this.showLanguages = true;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
for (let i = 0; i < modelColumns.length; i++) {
|
|
119
|
+
const modelColumn = modelColumns[i];
|
|
120
|
+
if (column.title === modelColumn.name) {
|
|
121
|
+
column.title = this.$t(modelColumn.title);
|
|
122
|
+
modelColumns.splice(i, 1);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
this.visibleColumns = [...this.columns];
|
|
128
|
+
this.selectedColumns = [...this.columns];
|
|
129
|
+
},
|
|
130
|
+
(error) => {
|
|
131
|
+
console.log(error);
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
},
|
|
135
|
+
cancelExport() {
|
|
136
|
+
this.$puiEvents.$emit(`onPui-action-running-ended-${this.modelName}`);
|
|
137
|
+
this.showDialog = false;
|
|
138
|
+
},
|
|
139
|
+
doExport() {
|
|
140
|
+
this.$store.commit('showPuiLoader', this.$t('puidatatables.downloading'));
|
|
141
|
+
|
|
142
|
+
const params = this.getParameters();
|
|
143
|
+
this.$puiRequests.downloadFileRequest(
|
|
144
|
+
'post',
|
|
145
|
+
this.exportController,
|
|
146
|
+
params,
|
|
147
|
+
(response) => {
|
|
148
|
+
const link = document.createElement('a');
|
|
149
|
+
link.href = window.URL.createObjectURL(new window.Blob([response.data]));
|
|
150
|
+
link.download = this.$puiUtils.getFilenameFromHeaders(response.headers);
|
|
151
|
+
link.click();
|
|
152
|
+
|
|
153
|
+
this.showDialog = false;
|
|
154
|
+
this.$store.commit('hidePuiLoader');
|
|
155
|
+
},
|
|
156
|
+
() => {
|
|
157
|
+
this.showDialog = false;
|
|
158
|
+
this.$store.commit('hidePuiLoader');
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
this.$puiEvents.$emit(`onPui-action-running-ended-${this.modelName}`);
|
|
163
|
+
},
|
|
164
|
+
getParameters() {
|
|
165
|
+
const currentSearch = this.$parent.$parent.$parent.getCurrentSearch();
|
|
166
|
+
let queryText = '';
|
|
167
|
+
let queryFields = [];
|
|
168
|
+
if (currentSearch !== undefined && currentSearch !== null) {
|
|
169
|
+
queryText = currentSearch[0];
|
|
170
|
+
queryFields = currentSearch[1].map((field) => {
|
|
171
|
+
return field.name;
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
const params = {
|
|
175
|
+
model: this.modelName,
|
|
176
|
+
exportColumns: this.selectedColumns,
|
|
177
|
+
filter: this.$parent.$parent.$parent.getCurrentFilter(),
|
|
178
|
+
order: this.$parent.$parent.$parent.getCurrentSorting(),
|
|
179
|
+
queryText: queryText,
|
|
180
|
+
queryFields: queryFields,
|
|
181
|
+
queryLang: this.langModel.language
|
|
182
|
+
};
|
|
183
|
+
return params;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
</script>
|