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,421 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<pui-modal-dialog
|
|
4
|
+
v-if="dialogs.prepareImport.show"
|
|
5
|
+
:titleText="dialogs.prepareImport.titleText"
|
|
6
|
+
messageText
|
|
7
|
+
:okText="dialogs.prepareImport.okText"
|
|
8
|
+
:cancelText="dialogs.prepareImport.cancelText"
|
|
9
|
+
:disableOk="dialogs.prepareImport.disableOk"
|
|
10
|
+
:widthDialog="dialogs.prepareImport.width"
|
|
11
|
+
:dialogName="dialogs.prepareImport.name"
|
|
12
|
+
:ref="dialogs.prepareImport.name"
|
|
13
|
+
>
|
|
14
|
+
<template slot="message">
|
|
15
|
+
<v-layout wrap>
|
|
16
|
+
<v-flex xs12 md8 xl8>
|
|
17
|
+
<pui-text-field
|
|
18
|
+
:label="$t('puidatatables.filename')"
|
|
19
|
+
v-model="dialogs.prepareImport.filename"
|
|
20
|
+
toplabel
|
|
21
|
+
required
|
|
22
|
+
disabled
|
|
23
|
+
></pui-text-field>
|
|
24
|
+
<input type="file" v-show="false" ref="document" accept=".csv" @change="onFilePicked" />
|
|
25
|
+
</v-flex>
|
|
26
|
+
<v-flex xs12 md2 xl2>
|
|
27
|
+
<v-btn color="primary" @click="pickFile" style="margin-top: 20px">{{ $t('puidatatables.selectfile') }}</v-btn>
|
|
28
|
+
</v-flex>
|
|
29
|
+
</v-layout>
|
|
30
|
+
</template>
|
|
31
|
+
</pui-modal-dialog>
|
|
32
|
+
<pui-modal-dialog
|
|
33
|
+
v-if="dialogs.import.show"
|
|
34
|
+
:titleText="dialogs.import.titleText"
|
|
35
|
+
messageText
|
|
36
|
+
:okText="dialogs.import.okText"
|
|
37
|
+
:cancelText="dialogs.import.cancelText"
|
|
38
|
+
:disableOk="dialogs.import.disableOk"
|
|
39
|
+
:widthDialog="dialogs.import.width"
|
|
40
|
+
:dialogName="dialogs.import.name"
|
|
41
|
+
:ref="dialogs.import.name"
|
|
42
|
+
>
|
|
43
|
+
<template slot="message">
|
|
44
|
+
<v-data-table
|
|
45
|
+
v-if="dialogs.import.dataSetted"
|
|
46
|
+
:headers="dialogs.import.headers"
|
|
47
|
+
:items="dataFilteredByStatus"
|
|
48
|
+
fixed-header
|
|
49
|
+
:height="dialogs.import.height"
|
|
50
|
+
>
|
|
51
|
+
<template v-slot:item="{ item }">
|
|
52
|
+
<tr :class="getRowClass(item)">
|
|
53
|
+
<td v-for="(prop, index) in getItemValidProps(item)" :key="index">
|
|
54
|
+
<div v-html="prop" />
|
|
55
|
+
</td>
|
|
56
|
+
</tr>
|
|
57
|
+
</template>
|
|
58
|
+
</v-data-table>
|
|
59
|
+
<pui-form-loading style="height: 500px" v-else></pui-form-loading>
|
|
60
|
+
<v-layout wrap>
|
|
61
|
+
<v-chip class="ma-2" :class="isActive('ALL') ? 'active-chip' : ''" @click.native="showInDatatable('ALL')">
|
|
62
|
+
<v-avatar left class="import_total" :style="getAvatarStyle('totalRecords')">
|
|
63
|
+
{{ dialogs.prepareImport.data.totalRecords }}
|
|
64
|
+
</v-avatar>
|
|
65
|
+
{{ $t('puidatatables.total_records') }}
|
|
66
|
+
</v-chip>
|
|
67
|
+
<v-chip class="ma-2" :class="isActive('NEW') ? 'active-chip' : ''" @click.native="showInDatatable('NEW')">
|
|
68
|
+
<v-avatar left class="import_new" :style="getAvatarStyle('newRecords')">
|
|
69
|
+
{{ dialogs.prepareImport.data.newRecords }}
|
|
70
|
+
</v-avatar>
|
|
71
|
+
{{ $t('puidatatables.new_records') }}
|
|
72
|
+
</v-chip>
|
|
73
|
+
<v-chip class="ma-2" :class="isActive('MODIFIED') ? 'active-chip' : ''" @click.native="showInDatatable('MODIFIED')">
|
|
74
|
+
<v-avatar left class="import_modified" :style="getAvatarStyle('modifiedRecords')">
|
|
75
|
+
{{ dialogs.prepareImport.data.modifiedRecords }}
|
|
76
|
+
</v-avatar>
|
|
77
|
+
{{ $t('puidatatables.modified_records') }}
|
|
78
|
+
</v-chip>
|
|
79
|
+
<v-chip class="ma-2" :class="isActive('UNMODIFIED') ? 'active-chip' : ''" @click.native="showInDatatable('UNMODIFIED')">
|
|
80
|
+
<v-avatar left :style="getAvatarStyle('unmodifiedRecords')">
|
|
81
|
+
{{ dialogs.prepareImport.data.unmodifiedRecords }}
|
|
82
|
+
</v-avatar>
|
|
83
|
+
{{ $t('puidatatables.unmodified_records') }}
|
|
84
|
+
</v-chip>
|
|
85
|
+
<v-chip class="ma-2" :class="isActive('NEW_ERROR') ? 'active-chip' : ''" @click.native="showInDatatable('NEW_ERROR')">
|
|
86
|
+
<v-avatar left class="import_new_error" :style="getAvatarStyle('newWithErrorsRecords')">
|
|
87
|
+
{{ dialogs.prepareImport.data.newWithErrorsRecords }}
|
|
88
|
+
</v-avatar>
|
|
89
|
+
{{ $t('puidatatables.new_error_records') }}
|
|
90
|
+
</v-chip>
|
|
91
|
+
<v-chip class="ma-2" :class="isActive('ERROR') ? 'active-chip' : ''" @click.native="showInDatatable('ERROR')">
|
|
92
|
+
<v-avatar left class="import_error" :style="getAvatarStyle('errorRecords')">
|
|
93
|
+
{{ dialogs.prepareImport.data.errorRecords }}
|
|
94
|
+
</v-avatar>
|
|
95
|
+
{{ $t('puidatatables.error_records') }}
|
|
96
|
+
</v-chip>
|
|
97
|
+
</v-layout>
|
|
98
|
+
</template>
|
|
99
|
+
</pui-modal-dialog>
|
|
100
|
+
<pui-modal-dialog
|
|
101
|
+
v-if="dialogs.beforeImport.show"
|
|
102
|
+
:titleText="dialogs.beforeImport.titleText"
|
|
103
|
+
:messageText="dialogs.beforeImport.messageText"
|
|
104
|
+
:okText="dialogs.beforeImport.okText"
|
|
105
|
+
:cancelText="dialogs.beforeImport.cancelText"
|
|
106
|
+
:dialogName="dialogs.beforeImport.name"
|
|
107
|
+
:ref="dialogs.beforeImport.name"
|
|
108
|
+
></pui-modal-dialog>
|
|
109
|
+
</div>
|
|
110
|
+
</template>
|
|
111
|
+
|
|
112
|
+
<script>
|
|
113
|
+
export default {
|
|
114
|
+
name: 'PuiGridImportDialog',
|
|
115
|
+
props: {
|
|
116
|
+
modelName: {
|
|
117
|
+
type: String,
|
|
118
|
+
required: true
|
|
119
|
+
},
|
|
120
|
+
importExportModelName: {
|
|
121
|
+
type: String,
|
|
122
|
+
required: true
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
data() {
|
|
126
|
+
return {
|
|
127
|
+
dialogs: {
|
|
128
|
+
prepareImport: {
|
|
129
|
+
name: 'importDialog',
|
|
130
|
+
urlController: '/importexport/prepareImport',
|
|
131
|
+
show: false,
|
|
132
|
+
titleText: this.$t('puidatatables.prepare_import_title'),
|
|
133
|
+
messageText: '',
|
|
134
|
+
okText: this.$t('puidatatables.import_btn'),
|
|
135
|
+
cancelText: this.$t('form.cancel'),
|
|
136
|
+
disableOk: true,
|
|
137
|
+
width: 650,
|
|
138
|
+
filename: null,
|
|
139
|
+
data: null
|
|
140
|
+
},
|
|
141
|
+
import: {
|
|
142
|
+
name: 'checkImportDialog',
|
|
143
|
+
performImportUrlController: '/importexport/performImport',
|
|
144
|
+
cancelImportUrlController: '/importexport/cancelImport',
|
|
145
|
+
show: false,
|
|
146
|
+
titleText: this.$t('puidatatables.import_title'),
|
|
147
|
+
messageText: '',
|
|
148
|
+
okText: this.$t('form.ok'),
|
|
149
|
+
cancelText: this.$t('form.cancel'),
|
|
150
|
+
disableOk: true,
|
|
151
|
+
width: window.innerWidth * 0.9,
|
|
152
|
+
height: '60vh',
|
|
153
|
+
dataSetted: false,
|
|
154
|
+
headers: [],
|
|
155
|
+
data: [],
|
|
156
|
+
dataFiltered: [],
|
|
157
|
+
statusToFilter: 'ALL'
|
|
158
|
+
},
|
|
159
|
+
beforeImport: {
|
|
160
|
+
name: 'beforeImportDialog',
|
|
161
|
+
show: false,
|
|
162
|
+
titleText: this.$t('puidatatables.before_import_title'),
|
|
163
|
+
okText: this.$t('form.ok'),
|
|
164
|
+
cancelText: this.$t('form.cancel'),
|
|
165
|
+
messageText: null
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
},
|
|
170
|
+
created() {
|
|
171
|
+
this.$puiEvents.$on(`pui-show-${this.dialogs.prepareImport.name}-${this.importExportModelName}`, () => {
|
|
172
|
+
this.dialogs.prepareImport.show = true;
|
|
173
|
+
});
|
|
174
|
+
this.$puiEvents.$on(`pui-modalDialog-${this.dialogs.prepareImport.name}-ok`, () => {
|
|
175
|
+
this.prepareImport();
|
|
176
|
+
this.dialogs.prepareImport.show = false;
|
|
177
|
+
});
|
|
178
|
+
this.$puiEvents.$on(`pui-modalDialog-${this.dialogs.prepareImport.name}-cancel`, () => {
|
|
179
|
+
this.dialogs.prepareImport.show = false;
|
|
180
|
+
this.$puiEvents.$emit(`onPui-action-running-ended-${this.modelName}`);
|
|
181
|
+
});
|
|
182
|
+
this.$puiEvents.$on(`pui-modalDialog-${this.dialogs.import.name}-ok`, () => {
|
|
183
|
+
const params = {
|
|
184
|
+
new: this.dialogs.prepareImport.data.newRecords,
|
|
185
|
+
modified: this.dialogs.prepareImport.data.modifiedRecords
|
|
186
|
+
};
|
|
187
|
+
this.dialogs.beforeImport.messageText = this.$t('puidatatables.before_import_message', params);
|
|
188
|
+
this.dialogs.beforeImport.show = true;
|
|
189
|
+
});
|
|
190
|
+
this.$puiEvents.$on(`pui-modalDialog-${this.dialogs.import.name}-cancel`, () => {
|
|
191
|
+
this.doImport(this.dialogs.import.cancelImportUrlController);
|
|
192
|
+
});
|
|
193
|
+
this.$puiEvents.$on(`pui-modalDialog-${this.dialogs.beforeImport.name}-ok`, () => {
|
|
194
|
+
this.doImport(this.dialogs.import.performImportUrlController);
|
|
195
|
+
});
|
|
196
|
+
this.$puiEvents.$on(`pui-modalDialog-${this.dialogs.beforeImport.name}-cancel`, () => {
|
|
197
|
+
this.doImport(this.dialogs.import.cancelImportUrlController);
|
|
198
|
+
});
|
|
199
|
+
},
|
|
200
|
+
destroyed() {
|
|
201
|
+
this.$puiEvents.$off(`pui-show-${this.dialogs.prepareImport.name}-${this.importExportModelName}`);
|
|
202
|
+
this.$puiEvents.$off(`pui-modalDialog-${this.dialogs.prepareImport.name}-ok`);
|
|
203
|
+
this.$puiEvents.$off(`pui-modalDialog-${this.dialogs.prepareImport.name}-cancel`);
|
|
204
|
+
this.$puiEvents.$off(`pui-modalDialog-${this.dialogs.import.name}-ok`);
|
|
205
|
+
this.$puiEvents.$off(`pui-modalDialog-${this.dialogs.import.name}-cancel`);
|
|
206
|
+
this.$puiEvents.$off(`pui-modalDialog-${this.dialogs.beforeImport.name}-ok`);
|
|
207
|
+
this.$puiEvents.$off(`pui-modalDialog-${this.dialogs.beforeImport.name}-cancel`);
|
|
208
|
+
},
|
|
209
|
+
computed: {
|
|
210
|
+
dataFilteredByStatus() {
|
|
211
|
+
const dateTimeRegex = new RegExp('(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2}).(\\d{3})Z');
|
|
212
|
+
const dateFormat = this.$store.getters.dateFormat;
|
|
213
|
+
const timeFormat = this.$store.getters.timeFormat;
|
|
214
|
+
|
|
215
|
+
let registriesToShow = this.dialogs.import.data.filter(
|
|
216
|
+
(row) => this.dialogs.import.statusToFilter === 'ALL' || row.record_status === this.dialogs.import.statusToFilter
|
|
217
|
+
);
|
|
218
|
+
registriesToShow = registriesToShow.map((row) => {
|
|
219
|
+
const recordStatus = row.record_status;
|
|
220
|
+
for (const property in row) {
|
|
221
|
+
let newValue = row[property];
|
|
222
|
+
let oldValue = row[`${property}_oldValue`];
|
|
223
|
+
let status = row[`${property}_status`];
|
|
224
|
+
|
|
225
|
+
if (dateTimeRegex.test(newValue)) {
|
|
226
|
+
row[property] = this.$dateTimeUtils.getLocalFormattedDate(newValue, `${dateFormat} ${timeFormat}`);
|
|
227
|
+
}
|
|
228
|
+
if (dateTimeRegex.test(oldValue)) {
|
|
229
|
+
row[`${property}_oldValue`] = this.$dateTimeUtils.getLocalFormattedDate(oldValue, `${dateFormat} ${timeFormat}`);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (recordStatus === 'ERROR' && status === 'MODIFIED') {
|
|
233
|
+
row[property] = `<strike>${oldValue || ''}</strike><br>${newValue || ''}`;
|
|
234
|
+
} else if (status === 'ERROR' || status === 'MODIFIED') {
|
|
235
|
+
row[property] = `<b><strike>${oldValue || ''}</strike><br>${newValue || ''}</b>`;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return row;
|
|
239
|
+
});
|
|
240
|
+
return registriesToShow;
|
|
241
|
+
},
|
|
242
|
+
data() {
|
|
243
|
+
return this.dialogs.prepareImport.data;
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
methods: {
|
|
247
|
+
getAvatarStyle(indexRecords) {
|
|
248
|
+
return `width: ${this.dialogs.prepareImport.data[indexRecords].toString().length * 12}px !important; border-radius: 10px;`;
|
|
249
|
+
},
|
|
250
|
+
isActive(status) {
|
|
251
|
+
return this.dialogs.import.dataSetted && this.dialogs.import.statusToFilter === status;
|
|
252
|
+
},
|
|
253
|
+
pickFile() {
|
|
254
|
+
this.$refs.document.click();
|
|
255
|
+
},
|
|
256
|
+
onFilePicked(e) {
|
|
257
|
+
const files = e.target.files;
|
|
258
|
+
if (files[0] !== undefined) {
|
|
259
|
+
const file = files[0];
|
|
260
|
+
if (file.name.lastIndexOf('.') <= 0 || !file.name.endsWith('.csv')) {
|
|
261
|
+
this.$puiNotify.error(this.$t('puidatatables.fileextension_notallowed'));
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
this.dialogs.prepareImport.filename = file.name;
|
|
266
|
+
const fr = new window.FileReader();
|
|
267
|
+
fr.addEventListener('load', () => {
|
|
268
|
+
this.selectedFile = file; // this is the file that can be sent to server...
|
|
269
|
+
});
|
|
270
|
+
fr.readAsDataURL(file);
|
|
271
|
+
this.dialogs.prepareImport.disableOk = false;
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
resetFilePicked() {
|
|
275
|
+
this.dialogs.prepareImport.filename = null;
|
|
276
|
+
this.selectedFile = null;
|
|
277
|
+
},
|
|
278
|
+
prepareImport() {
|
|
279
|
+
const formData = new window.FormData();
|
|
280
|
+
formData.append('csv', this.selectedFile, this.selectedFile.name);
|
|
281
|
+
const params = { model: this.modelName };
|
|
282
|
+
this.$store.commit('showPuiLoader', this.$t('puidatatables.uploading'));
|
|
283
|
+
this.$puiRequests.uploadFileRequest(
|
|
284
|
+
this.dialogs.prepareImport.urlController,
|
|
285
|
+
formData,
|
|
286
|
+
(response) => {
|
|
287
|
+
this.$store.commit('hidePuiLoader');
|
|
288
|
+
if (response.data) {
|
|
289
|
+
this.dialogs.prepareImport.data = response.data;
|
|
290
|
+
this.afterPrepareImport();
|
|
291
|
+
this.dialogs.import.show = true;
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
(error) => {
|
|
295
|
+
this.$store.commit('hidePuiLoader');
|
|
296
|
+
this.$store.dispatch('puiRequestShowServerError', { error });
|
|
297
|
+
this.dialogs.prepareImport.show = false;
|
|
298
|
+
this.$puiEvents.$emit(`onPui-action-running-ended-${this.modelName}`);
|
|
299
|
+
},
|
|
300
|
+
params
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
this.resetFilePicked();
|
|
304
|
+
},
|
|
305
|
+
afterPrepareImport() {
|
|
306
|
+
this.dialogs.import.headers = [];
|
|
307
|
+
this.dialogs.import.data = [];
|
|
308
|
+
|
|
309
|
+
this.dialogs.prepareImport.data.columns.forEach((colObj, index) => {
|
|
310
|
+
const title = this.dialogs.prepareImport.data.columnTitles[index];
|
|
311
|
+
this.dialogs.import.headers.push({
|
|
312
|
+
text: title,
|
|
313
|
+
value: colObj
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
for (const pk in this.dialogs.prepareImport.data.records) {
|
|
317
|
+
if (Object.prototype.hasOwnProperty.call(this.dialogs.prepareImport.data.records, pk)) {
|
|
318
|
+
const record = this.dialogs.prepareImport.data.records[pk];
|
|
319
|
+
const item = { record_status: record.status };
|
|
320
|
+
|
|
321
|
+
this.dialogs.prepareImport.data.columns.forEach((colObj) => {
|
|
322
|
+
const attribute = record.attributes[colObj];
|
|
323
|
+
item[colObj] = attribute.value;
|
|
324
|
+
item[`${colObj}_oldValue`] = attribute.oldValue;
|
|
325
|
+
item[`${colObj}_status`] = attribute.status;
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
this.dialogs.import.data.push(item);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
this.dialogs.import.dataFiltered = [...this.dialogs.import.data];
|
|
332
|
+
|
|
333
|
+
this.dialogs.import.disableOk =
|
|
334
|
+
this.dialogs.prepareImport.data.errorRecords > 0 ||
|
|
335
|
+
this.dialogs.prepareImport.data.newWithErrorsRecords > 0 ||
|
|
336
|
+
(this.dialogs.prepareImport.data.newRecords === 0 && this.dialogs.prepareImport.data.modifiedRecords === 0);
|
|
337
|
+
this.dialogs.import.dataSetted = true;
|
|
338
|
+
},
|
|
339
|
+
doImport(importUrlController) {
|
|
340
|
+
this.$store.commit('showPuiLoader', this.$t('puidatatables.uploading'));
|
|
341
|
+
|
|
342
|
+
const params = { id: this.dialogs.prepareImport.data.id };
|
|
343
|
+
this.$puiRequests.getRequest(
|
|
344
|
+
importUrlController,
|
|
345
|
+
params,
|
|
346
|
+
() => {
|
|
347
|
+
if (importUrlController === this.dialogs.import.performImportUrlController) {
|
|
348
|
+
this.$puiNotify.success(this.$t('puidatatables.import_success'));
|
|
349
|
+
}
|
|
350
|
+
this.dialogs.import.show = false;
|
|
351
|
+
this.dialogs.beforeImport.show = false;
|
|
352
|
+
this.$store.commit('hidePuiLoader');
|
|
353
|
+
this.$puiEvents.$emit(`onPui-action-running-ended-${this.modelName}`);
|
|
354
|
+
},
|
|
355
|
+
(error) => {
|
|
356
|
+
this.$store.dispatch('puiRequestShowServerError', { error });
|
|
357
|
+
this.dialogs.import.show = false;
|
|
358
|
+
this.dialogs.beforeImport.show = false;
|
|
359
|
+
this.$store.commit('hidePuiLoader');
|
|
360
|
+
this.$puiEvents.$emit(`onPui-action-running-ended-${this.modelName}`);
|
|
361
|
+
}
|
|
362
|
+
);
|
|
363
|
+
},
|
|
364
|
+
showInDatatable(newStatus) {
|
|
365
|
+
if (this.dialogs.import.dataSetted) {
|
|
366
|
+
this.dialogs.import.dataSetted = false;
|
|
367
|
+
this.dialogs.import.statusToFilter = this.dialogs.import.statusToFilter === newStatus ? 'ALL' : newStatus;
|
|
368
|
+
setTimeout(() => {
|
|
369
|
+
this.dialogs.import.dataSetted = true;
|
|
370
|
+
}, 10);
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
getRowClass(item) {
|
|
374
|
+
if (item.record_status === 'NEW') {
|
|
375
|
+
return 'import_new';
|
|
376
|
+
} else if (item.record_status === 'NEW_ERROR') {
|
|
377
|
+
return 'import_new_error';
|
|
378
|
+
} else if (item.record_status === 'ERROR') {
|
|
379
|
+
return 'import_error';
|
|
380
|
+
} else if (item.record_status === 'MODIFIED') {
|
|
381
|
+
return 'import_modified';
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
getItemValidProps(item) {
|
|
385
|
+
const newItem = {};
|
|
386
|
+
for (let property in item) {
|
|
387
|
+
if (!property.includes('_oldValue') && !property.includes('_status')) {
|
|
388
|
+
newItem[property] = item[property];
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return newItem;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
</script>
|
|
396
|
+
|
|
397
|
+
<style>
|
|
398
|
+
.import_total {
|
|
399
|
+
background-color: rgb(185, 185, 185) !important;
|
|
400
|
+
border-color: rgb(185, 185, 185);
|
|
401
|
+
}
|
|
402
|
+
.import_new {
|
|
403
|
+
background-color: lightblue !important;
|
|
404
|
+
border-color: lightblue;
|
|
405
|
+
}
|
|
406
|
+
.import_new_error {
|
|
407
|
+
background-color: lightsalmon !important;
|
|
408
|
+
border-color: lightsalmon;
|
|
409
|
+
}
|
|
410
|
+
.import_modified {
|
|
411
|
+
background-color: lightgreen !important;
|
|
412
|
+
border-color: lightgreen;
|
|
413
|
+
}
|
|
414
|
+
.import_error {
|
|
415
|
+
background-color: lightcoral !important;
|
|
416
|
+
border-color: lightcoral;
|
|
417
|
+
}
|
|
418
|
+
.active-chip {
|
|
419
|
+
font-weight: bold;
|
|
420
|
+
}
|
|
421
|
+
</style>
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="pui-toolbar__multiBtn" :class="compClass" style="margin-right: 10px">
|
|
3
|
+
<div ref="btn">
|
|
4
|
+
<v-btn
|
|
5
|
+
class="elevation-0 pui-toolbar__btn pui-toolbar__superMiniBtn"
|
|
6
|
+
@click.native.stop="states.active = !states.active"
|
|
7
|
+
:class="compClass"
|
|
8
|
+
>
|
|
9
|
+
<v-icon class="pr-3" small>fa fa-file-export</v-icon>
|
|
10
|
+
<v-icon v-if="!states.active" small>fa fa-angle-down</v-icon>
|
|
11
|
+
<v-icon v-else small>fa fa-angle-up</v-icon>
|
|
12
|
+
</v-btn>
|
|
13
|
+
</div>
|
|
14
|
+
<div v-show="states.active" class="pui-dialog--export elevation-5 pl-0 pr-0" :ref="'dialog'" @click.stop>
|
|
15
|
+
<v-layout wrap class="mb-1">
|
|
16
|
+
<v-list>
|
|
17
|
+
<v-list-item
|
|
18
|
+
v-for="format in formats"
|
|
19
|
+
:key="format.extension"
|
|
20
|
+
@click="exportData(format)"
|
|
21
|
+
tabindex="0"
|
|
22
|
+
@keydown.native.enter="exportData(format)"
|
|
23
|
+
>
|
|
24
|
+
<v-list-item-action>
|
|
25
|
+
<v-icon style="font-size: 16px">{{ `fa fa-${format.icon}` }}</v-icon>
|
|
26
|
+
</v-list-item-action>
|
|
27
|
+
|
|
28
|
+
<v-list-item-content>
|
|
29
|
+
<v-list-item-title v-text="`${$t('puidatatables.export_to')} ${format.name}`"></v-list-item-title>
|
|
30
|
+
</v-list-item-content>
|
|
31
|
+
</v-list-item>
|
|
32
|
+
</v-list>
|
|
33
|
+
</v-layout>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</template>
|
|
37
|
+
|
|
38
|
+
<script>
|
|
39
|
+
import PuiToolbarBtnMixin from '../../../../mixins/PuiToolbarBtnMixin';
|
|
40
|
+
|
|
41
|
+
export default {
|
|
42
|
+
name: 'PuiGridExportBtn',
|
|
43
|
+
mixins: [PuiToolbarBtnMixin],
|
|
44
|
+
props: {
|
|
45
|
+
modelName: {
|
|
46
|
+
type: String
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
data() {
|
|
50
|
+
return {
|
|
51
|
+
idTool: 'export',
|
|
52
|
+
panel: {
|
|
53
|
+
position: {}
|
|
54
|
+
},
|
|
55
|
+
formats: {
|
|
56
|
+
pdf: {
|
|
57
|
+
name: 'PDF',
|
|
58
|
+
type: 'direct',
|
|
59
|
+
extension: '.pdf',
|
|
60
|
+
icon: 'file-pdf'
|
|
61
|
+
},
|
|
62
|
+
csv: {
|
|
63
|
+
name: 'CSV',
|
|
64
|
+
type: 'direct',
|
|
65
|
+
extension: '.csv',
|
|
66
|
+
icon: 'file-csv'
|
|
67
|
+
},
|
|
68
|
+
excel: {
|
|
69
|
+
name: 'Excel',
|
|
70
|
+
type: 'direct',
|
|
71
|
+
extension: '.xls',
|
|
72
|
+
icon: 'file-excel'
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
mounted() {
|
|
78
|
+
this.calculateDialogPosition();
|
|
79
|
+
},
|
|
80
|
+
methods: {
|
|
81
|
+
exportData(format) {
|
|
82
|
+
this.$store.state.global.puiloader.message = this.$t('puidatatables.downloading');
|
|
83
|
+
this.$store.state.global.puiloader.show = true;
|
|
84
|
+
|
|
85
|
+
const currentConfiguration = this.$store.getters.getCurrentGridConfiguration(this.modelName);
|
|
86
|
+
const currentColumns = currentConfiguration.configuration.columns
|
|
87
|
+
.filter((column) => {
|
|
88
|
+
return column.visible === undefined || column.visible === true || column.visibility === 'visible';
|
|
89
|
+
})
|
|
90
|
+
.map((column, index) => {
|
|
91
|
+
let dateformat = this.$store.getters.javaDateFormat;
|
|
92
|
+
if (
|
|
93
|
+
!(
|
|
94
|
+
this.$parent.$parent.modelColumnDefs &&
|
|
95
|
+
this.$parent.$parent.modelColumnDefs[column.name] &&
|
|
96
|
+
this.$parent.$parent.modelColumnDefs[column.name].withoutHours
|
|
97
|
+
)
|
|
98
|
+
) {
|
|
99
|
+
dateformat += ' ' + this.$store.getters.timeFormat;
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
order: index,
|
|
103
|
+
title: this.$t(column.title),
|
|
104
|
+
name: column.name,
|
|
105
|
+
dateformat: dateformat
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
const currentFilter = this.$parent.$parent.getCurrentFilter();
|
|
109
|
+
const currentOrder = this.$parent.$parent.getCurrentSorting();
|
|
110
|
+
const currentSearch = this.$parent.$parent.getCurrentSearch();
|
|
111
|
+
let queryText = '';
|
|
112
|
+
let queryFields = [];
|
|
113
|
+
if (currentSearch !== undefined && currentSearch !== null) {
|
|
114
|
+
queryText = currentSearch[0];
|
|
115
|
+
queryFields = currentSearch[1].map((field) => {
|
|
116
|
+
return field.name;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
this.$puiRequests.downloadFileRequest(
|
|
121
|
+
'post',
|
|
122
|
+
`/${this.modelName}/export`,
|
|
123
|
+
{
|
|
124
|
+
model: this.modelName,
|
|
125
|
+
exportTitle: this.$t('menu.' + this.modelName),
|
|
126
|
+
exportType: format.name.toLowerCase(),
|
|
127
|
+
exportColumns: currentColumns,
|
|
128
|
+
filter: currentFilter,
|
|
129
|
+
order: currentOrder,
|
|
130
|
+
queryText: queryText,
|
|
131
|
+
queryFields: queryFields,
|
|
132
|
+
queryFlexible: false,
|
|
133
|
+
queryLang: this.$store.getters.getUserLanguage
|
|
134
|
+
},
|
|
135
|
+
(response) => {
|
|
136
|
+
if (response.data && response.headers) {
|
|
137
|
+
const link = document.createElement('a');
|
|
138
|
+
link.href = window.URL.createObjectURL(new window.Blob([response.data]));
|
|
139
|
+
link.download = this.$puiUtils.getFilenameFromHeaders(response.headers);
|
|
140
|
+
link.click();
|
|
141
|
+
} else {
|
|
142
|
+
console.log('PuiGridExportBtn - No response data');
|
|
143
|
+
this.$puiNotify.error(this.$t('pui9.error.puigridexportbtn'));
|
|
144
|
+
}
|
|
145
|
+
this.$store.state.global.puiloader.message = null;
|
|
146
|
+
this.$store.state.global.puiloader.show = false;
|
|
147
|
+
},
|
|
148
|
+
(error) => {
|
|
149
|
+
console.log(error);
|
|
150
|
+
this.$puiNotify.error(this.$t('pui9.error.puigridexportbtn'));
|
|
151
|
+
this.$store.state.global.puiloader.message = null;
|
|
152
|
+
this.$store.state.global.puiloader.show = false;
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
</script>
|
|
159
|
+
|
|
160
|
+
<style lang="postcss">
|
|
161
|
+
.pui-dialog--export {
|
|
162
|
+
border-radius: 5px;
|
|
163
|
+
line-height: 22px;
|
|
164
|
+
position: absolute;
|
|
165
|
+
z-index: 999;
|
|
166
|
+
background: white !important;
|
|
167
|
+
& .v-list__tile {
|
|
168
|
+
height: 35px !important;
|
|
169
|
+
font-size: 0.75rem;
|
|
170
|
+
}
|
|
171
|
+
& .v-list__tile__action {
|
|
172
|
+
min-width: 30px !important;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
</style>
|