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,434 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="pui-dialog elevation-5" ref="dialog" @click.stop>
|
|
3
|
+
<v-layout wrap>
|
|
4
|
+
<v-flex xs-12>
|
|
5
|
+
<v-card flat raised>
|
|
6
|
+
<v-card-text class="ma-0 pt-2 pl-2 pr-2">
|
|
7
|
+
<!-- slot1, TODO MAKE SLOTS IN FILTER AND SORTING DIALOGS-->
|
|
8
|
+
<!-- HEADER -->
|
|
9
|
+
<v-layout :ref="'header'" wrap>
|
|
10
|
+
<v-toolbar class="elevation-0 pui-dialog__bar" height="50">
|
|
11
|
+
<v-toolbar-title class="pui-dialog__title pui-dialog__title--margin pui-dialog__margin">{{
|
|
12
|
+
getTitle
|
|
13
|
+
}}</v-toolbar-title>
|
|
14
|
+
<v-btn
|
|
15
|
+
v-if="showSqlBtn"
|
|
16
|
+
class="pui-dialog__toolbarBtn pui-dialog__toolbarBtn--text elevation-0"
|
|
17
|
+
@click="goSqlFilter()"
|
|
18
|
+
:class="compSqlClass"
|
|
19
|
+
>SQL</v-btn
|
|
20
|
+
>
|
|
21
|
+
<v-spacer></v-spacer>
|
|
22
|
+
<v-btn
|
|
23
|
+
v-show="!saving && disabled === false && saveDisabled === false"
|
|
24
|
+
class="pui-dialog__toolbarBtn elevation-0"
|
|
25
|
+
@click="goSaveMode()"
|
|
26
|
+
>
|
|
27
|
+
<v-icon small>fa fa-save</v-icon>
|
|
28
|
+
</v-btn>
|
|
29
|
+
<v-btn v-if="saving" text class="pui-dialog__toolbarBtn elevation-0 mr-2" @click="cancelSave()">
|
|
30
|
+
<v-icon>far fa-times</v-icon>
|
|
31
|
+
</v-btn>
|
|
32
|
+
</v-toolbar>
|
|
33
|
+
</v-layout>
|
|
34
|
+
<div class="pb-3" v-show="saving === true" ref="form">
|
|
35
|
+
<v-flex xs12 class="pl-3">
|
|
36
|
+
<v-list-item-action-text class="puiToolbar__text">{{ $t('puidatatables.nameFilter') }}</v-list-item-action-text>
|
|
37
|
+
</v-flex>
|
|
38
|
+
<v-flex xs12>
|
|
39
|
+
<v-list-item>
|
|
40
|
+
<v-text-field
|
|
41
|
+
v-model="model.label"
|
|
42
|
+
single-line
|
|
43
|
+
:rules="[filterNameRequired]"
|
|
44
|
+
:error="filterNameRequiredError"
|
|
45
|
+
ref="filterName"
|
|
46
|
+
></v-text-field>
|
|
47
|
+
</v-list-item>
|
|
48
|
+
</v-flex>
|
|
49
|
+
</div>
|
|
50
|
+
<div v-show="!showSql" class="pui-dialog__ruleContainer ml-2 mr-2" @scroll="handleScroll">
|
|
51
|
+
<pui-grid-filter-group
|
|
52
|
+
:ref="'group0'"
|
|
53
|
+
:columns="columns"
|
|
54
|
+
:groupName="'0'"
|
|
55
|
+
:rulesProp="filterToBuild ? filterToBuild.rules : undefined"
|
|
56
|
+
:groupOpProp="filterToBuild ? filterToBuild.groupOp : undefined"
|
|
57
|
+
:groupsProp="filterToBuild ? filterToBuild.groups : undefined"
|
|
58
|
+
:disabled="disabled"
|
|
59
|
+
:showSubgroupBtn="showSubgroupBtn"
|
|
60
|
+
></pui-grid-filter-group>
|
|
61
|
+
</div>
|
|
62
|
+
<div v-show="showSql" class="pui-dialog__sqlContainer ml-2 mr-2 mt-2">
|
|
63
|
+
<v-textarea filled name="input-7-4" label v-model="sql" class="elevation-0" height="200" no-resize></v-textarea>
|
|
64
|
+
</div>
|
|
65
|
+
<!-- slot1-->
|
|
66
|
+
</v-card-text>
|
|
67
|
+
<!-- saving mode-->
|
|
68
|
+
<v-card-actions v-if="saving === true" class="pl-1 pr-1 pb-1" :ref="'btnBar'">
|
|
69
|
+
<v-btn text @click="cancelSave()" class="elevation-0">{{ $t('form.cancel') }}</v-btn>
|
|
70
|
+
<v-spacer></v-spacer>
|
|
71
|
+
<v-btn color="primary" @click="checkFilterNameBeforeSave()" class="elevation-0">{{ $t('form.save') }}</v-btn>
|
|
72
|
+
</v-card-actions>
|
|
73
|
+
<!--reseting mode-->
|
|
74
|
+
<v-card-actions v-else-if="resetting === true" class="pl-4 pr-1 pb-1" :ref="'btnBar'">
|
|
75
|
+
<div class="pr-2">{{ $t('puidatatables.resetFilterQuestion') }}</div>
|
|
76
|
+
<v-btn text @click="resetting = false" class="elevation-0">{{ $t('form.cancel') }}</v-btn>
|
|
77
|
+
<v-btn color="red" dark @click="reset();publishFiltering()" class="elevation-0">{{ $t('puidatatables.reset') }}</v-btn>
|
|
78
|
+
</v-card-actions>
|
|
79
|
+
<!-- normal mode-->
|
|
80
|
+
<v-card-actions v-else class="pr-1 pl-1 pb-1" :ref="'btnBar'">
|
|
81
|
+
<v-btn text outlined @click="resetting = true" class="elevation-0">{{ $t('puidatatables.reset') }}</v-btn>
|
|
82
|
+
<v-spacer></v-spacer>
|
|
83
|
+
<v-btn color="primary" @click="publishFiltering()" class="elevation-0">{{ $t('form.apply') }}</v-btn>
|
|
84
|
+
</v-card-actions>
|
|
85
|
+
</v-card>
|
|
86
|
+
</v-flex>
|
|
87
|
+
</v-layout>
|
|
88
|
+
<pui-modal-dialog
|
|
89
|
+
v-if="dialogs.saveFilterAlert"
|
|
90
|
+
:cancelText="$t('form.cancel')"
|
|
91
|
+
:okText="$t('form.ok')"
|
|
92
|
+
:titleText="`${$t('puidatatables.saveFilter')}: ${model.label}`"
|
|
93
|
+
:messageText="$t('puidatatables.overwriteFilterQuestion')"
|
|
94
|
+
:dialogName="`saveFilterAlert-${this.modelName}`"
|
|
95
|
+
></pui-modal-dialog>
|
|
96
|
+
</div>
|
|
97
|
+
</template>
|
|
98
|
+
|
|
99
|
+
<script>
|
|
100
|
+
import PuiGridFilterGroup from './PuiGridFilterGroup';
|
|
101
|
+
import PuiGridFormMethodsMixin from '../../../../mixins/PuiGridFormMethodsMixin';
|
|
102
|
+
import PuiToolbarDialogMixin from '../../../../mixins/PuiToolbarDialogMixin';
|
|
103
|
+
|
|
104
|
+
export default {
|
|
105
|
+
name: 'PuiGridFilterDialog',
|
|
106
|
+
mixins: [PuiGridFormMethodsMixin, PuiToolbarDialogMixin],
|
|
107
|
+
components: {
|
|
108
|
+
PuiGridFilterGroup
|
|
109
|
+
},
|
|
110
|
+
props: {
|
|
111
|
+
columns: {
|
|
112
|
+
type: Array,
|
|
113
|
+
default: () => [],
|
|
114
|
+
required: true
|
|
115
|
+
},
|
|
116
|
+
position: {
|
|
117
|
+
type: Object
|
|
118
|
+
},
|
|
119
|
+
modelName: {
|
|
120
|
+
//the name of the model of the grid
|
|
121
|
+
type: String,
|
|
122
|
+
required: true
|
|
123
|
+
},
|
|
124
|
+
//for the view mode
|
|
125
|
+
disabled: {
|
|
126
|
+
type: Boolean,
|
|
127
|
+
default: false
|
|
128
|
+
},
|
|
129
|
+
saveDisabled: {
|
|
130
|
+
type: Boolean,
|
|
131
|
+
default: false
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
data() {
|
|
135
|
+
return {
|
|
136
|
+
showSql: false,
|
|
137
|
+
showFilterGroup: true,
|
|
138
|
+
sql: '',
|
|
139
|
+
width: 600,
|
|
140
|
+
showByIndex: null,
|
|
141
|
+
saving: false,
|
|
142
|
+
resetting: false,
|
|
143
|
+
modelDependencyName: 'puiusermodelfilter',
|
|
144
|
+
method: 'create',
|
|
145
|
+
isModal: false,
|
|
146
|
+
createGroup0: true,
|
|
147
|
+
dialogs: {
|
|
148
|
+
saveFilterAlert: false
|
|
149
|
+
},
|
|
150
|
+
filterNameRequired: (value) => !!value || this.$t('pui9.error.field_required'),
|
|
151
|
+
filterNameRequiredError: false,
|
|
152
|
+
showSqlBtn: false,
|
|
153
|
+
showSubgroupBtn: true
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
mounted() {
|
|
157
|
+
this.calculatePosition();
|
|
158
|
+
},
|
|
159
|
+
created() {
|
|
160
|
+
const theModel = this.$store.getters.getModelByName(this.modelName);
|
|
161
|
+
const currentFilter = theModel !== undefined ? theModel.currentFilter : theModel;
|
|
162
|
+
if (currentFilter !== undefined && currentFilter !== null && currentFilter.checked) {
|
|
163
|
+
this.currentFilter = JSON.parse(JSON.stringify(currentFilter.filter));
|
|
164
|
+
this.model = JSON.parse(JSON.stringify(currentFilter));
|
|
165
|
+
if (this.model.id && !currentFilter.isSystemFilter) {
|
|
166
|
+
this.method = 'update';
|
|
167
|
+
}
|
|
168
|
+
theModel.hasFilterActive &&
|
|
169
|
+
theModel.noStoredFilterActive === true &&
|
|
170
|
+
this.$puiEvents.$emit(`onPui-apply-filtering-${this.modelName}`, this.model.filter);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
this.getPuiVariables();
|
|
174
|
+
this.subscribeToModalDialogsEvents();
|
|
175
|
+
},
|
|
176
|
+
destroyed() {
|
|
177
|
+
this.isModal === false && this.$puiEvents.$off(`onPui-closed-gridFilter-${this.modelName}`);
|
|
178
|
+
this.unsubscribeToModalDialogEvent(`pui-modalDialog-saveFilterAlert-${this.modelName}`);
|
|
179
|
+
},
|
|
180
|
+
beforeDestroy() {
|
|
181
|
+
this.destroying = true;
|
|
182
|
+
},
|
|
183
|
+
updated() {
|
|
184
|
+
this.calculatePosition();
|
|
185
|
+
},
|
|
186
|
+
computed: {
|
|
187
|
+
compSqlClass() {
|
|
188
|
+
return {
|
|
189
|
+
'pui-dialog__toolbarBtn--text--selected': this.showSql
|
|
190
|
+
};
|
|
191
|
+
},
|
|
192
|
+
getTitle() {
|
|
193
|
+
if (this.model && this.model.id !== undefined && this.model.id !== null) {
|
|
194
|
+
return this.$t('puidatatables.editFilter');
|
|
195
|
+
} else if (this.saving === true) {
|
|
196
|
+
return this.$t('puidatatables.saveFilter');
|
|
197
|
+
}
|
|
198
|
+
return this.$t('puidatatables.filter');
|
|
199
|
+
},
|
|
200
|
+
filterToBuild() {
|
|
201
|
+
return this.currentFilter;
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
methods: {
|
|
205
|
+
/* overwrites the getData of the formMethodsMixins in order to not make a get Request to the puiusermodelfilter controller
|
|
206
|
+
because it has not get?pk service the grid configuration provides the filters and the filter get passed as a property in this component */
|
|
207
|
+
getData() {
|
|
208
|
+
//empty, but don't delete it
|
|
209
|
+
},
|
|
210
|
+
goSqlFilter() {
|
|
211
|
+
this.showSql = !this.showSql;
|
|
212
|
+
},
|
|
213
|
+
goSaveMode() {
|
|
214
|
+
this.saving = true;
|
|
215
|
+
this.$nextTick(() => this.$refs.filterName.$el.focus());
|
|
216
|
+
this.$refs.form.validate = () => {
|
|
217
|
+
const formValid = this.model.filter && this.model.label;
|
|
218
|
+
if (!formValid) {
|
|
219
|
+
this.filterNameRequiredError = true;
|
|
220
|
+
}
|
|
221
|
+
return formValid;
|
|
222
|
+
};
|
|
223
|
+
this.model.model = this.modelName;
|
|
224
|
+
this.model.usr = this.$store.getters.getUser;
|
|
225
|
+
this.model.filter = JSON.stringify(this.retrieveGroupsData());
|
|
226
|
+
this.previousModelLabel = this.model.label;
|
|
227
|
+
},
|
|
228
|
+
cancelSave() {
|
|
229
|
+
this.saving = false;
|
|
230
|
+
this.isModal === true && this.$puiEvents.$emit(`onPui-close-filtering-modalDialog-${this.modelName}`);
|
|
231
|
+
},
|
|
232
|
+
beforeSave() {
|
|
233
|
+
this.model.filter = JSON.stringify(this.retrieveGroupsData());
|
|
234
|
+
},
|
|
235
|
+
handleScroll(event) {
|
|
236
|
+
const el = event.srcElement;
|
|
237
|
+
const classPrefix = 'pui-dialog';
|
|
238
|
+
if (el.scrollTop === 0) {
|
|
239
|
+
this.$refs.header.classList.remove(`${classPrefix}__header--scrolling`);
|
|
240
|
+
return;
|
|
241
|
+
} else if (el.scrollTop + el.clientHeight === el.scrollHeight) {
|
|
242
|
+
this.$refs.btnBar.classList.remove(`${classPrefix}__btnBar--scrolling`);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
this.$refs.header.classList.add(`${classPrefix}__header--scrolling`);
|
|
246
|
+
this.$refs.btnBar.classList.add(`${classPrefix}__btnBar--scrolling`);
|
|
247
|
+
},
|
|
248
|
+
retrieveGroupsData() {
|
|
249
|
+
//
|
|
250
|
+
const isRule = function (name) {
|
|
251
|
+
return name.startsWith('rule');
|
|
252
|
+
};
|
|
253
|
+
let validFilter = true;
|
|
254
|
+
let almenosUnaRegla = false;
|
|
255
|
+
//funcion recursiva que recorre los subgrupos hasta el final mientras queden
|
|
256
|
+
const processGroup = (groupComponent, groupFilterObject) => {
|
|
257
|
+
for (var ruleOrGroup in groupComponent.$refs) {
|
|
258
|
+
if (isRule(ruleOrGroup) === true) {
|
|
259
|
+
almenosUnaRegla = true;
|
|
260
|
+
const ruleComponent = groupComponent.$refs[ruleOrGroup][0];
|
|
261
|
+
const rule = {
|
|
262
|
+
field: ruleComponent.field,
|
|
263
|
+
op: ruleComponent.op,
|
|
264
|
+
data: ruleComponent.data,
|
|
265
|
+
caseSensitiveAndAccents: ruleComponent.caseSensitive
|
|
266
|
+
};
|
|
267
|
+
if (!rule.field || !rule.op || (!rule.data && rule.op !== 'nn' && rule.op !== 'nu')) {
|
|
268
|
+
!this.destroying && this.$puiNotify.warning(this.$t('puidatatables.not-valid-rule-error'));
|
|
269
|
+
validFilter = false;
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (rule.op === 'in' || rule.op === 'ni') {
|
|
273
|
+
rule.data = rule.data.split(',');
|
|
274
|
+
}
|
|
275
|
+
groupFilterObject.rules.push(rule);
|
|
276
|
+
} else {
|
|
277
|
+
//isGroup
|
|
278
|
+
const subgroupComponent = groupComponent.$refs[ruleOrGroup][0];
|
|
279
|
+
if (subgroupComponent instanceof Object) {
|
|
280
|
+
const group = {
|
|
281
|
+
groupOp: subgroupComponent.groupOp,
|
|
282
|
+
rules: [],
|
|
283
|
+
groups: []
|
|
284
|
+
};
|
|
285
|
+
groupFilterObject.groups.push(group);
|
|
286
|
+
processGroup(subgroupComponent, group);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
const filter = {
|
|
293
|
+
rules: [],
|
|
294
|
+
groups: [],
|
|
295
|
+
groupOp: this.$refs.group0.groupOp
|
|
296
|
+
};
|
|
297
|
+
//empezamos por el grupo 0
|
|
298
|
+
processGroup(this.$refs.group0, filter);
|
|
299
|
+
if (almenosUnaRegla === false) {
|
|
300
|
+
this.$puiNotify.warning(this.$t('puidatatables.no-rules-error'));
|
|
301
|
+
return null;
|
|
302
|
+
} else if (validFilter === true) {
|
|
303
|
+
return filter;
|
|
304
|
+
}
|
|
305
|
+
return null;
|
|
306
|
+
},
|
|
307
|
+
publishFiltering() {
|
|
308
|
+
this.model.filter = this.retrieveGroupsData();
|
|
309
|
+
const theModel = this.$store.getters.getModelByName(this.modelName);
|
|
310
|
+
theModel.noStoredFilterActive = true;
|
|
311
|
+
if (!this.model.filter) {
|
|
312
|
+
theModel.noStoredFilterActive = false;
|
|
313
|
+
}
|
|
314
|
+
this.$puiEvents.$emit(`onPui-apply-filtering-${this.modelName}`, this.model.filter);
|
|
315
|
+
this.$puiEvents.$emit(`onPui-disapply-storedFilter-${this.modelName}`);
|
|
316
|
+
|
|
317
|
+
if (this.model.isSystemFilter) {
|
|
318
|
+
this.model.id = this.model.label = null;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (!this.model.filter) {
|
|
322
|
+
theModel.currentFilter = null;
|
|
323
|
+
} else {
|
|
324
|
+
theModel.currentFilter = JSON.parse(JSON.stringify(this.model));
|
|
325
|
+
theModel.currentFilter.id = theModel.currentFilter.label = null;
|
|
326
|
+
theModel.currentFilter.checked = true;
|
|
327
|
+
}
|
|
328
|
+
theModel.userFilters.forEach((filter) => {
|
|
329
|
+
filter.checked = false;
|
|
330
|
+
});
|
|
331
|
+
theModel.modelFilters.forEach((filter) => {
|
|
332
|
+
filter.checked = false;
|
|
333
|
+
});
|
|
334
|
+
},
|
|
335
|
+
afterSave() {
|
|
336
|
+
if (this.isModal === false) {
|
|
337
|
+
this.saving = false;
|
|
338
|
+
if (this.model.id) {
|
|
339
|
+
this.method = 'update';
|
|
340
|
+
}
|
|
341
|
+
} else {
|
|
342
|
+
this.$puiEvents.$emit(`onPui-close-filtering-modalDialog-${this.modelName}`);
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
reset() {
|
|
346
|
+
this.$puiEvents.$emit('reset-filtering');
|
|
347
|
+
this.resetting = false;
|
|
348
|
+
this.sql = '';
|
|
349
|
+
},
|
|
350
|
+
checkFilterNameBeforeSave() {
|
|
351
|
+
if (this.method === 'create') {
|
|
352
|
+
const modelConfig = this.$store.getters.getModelByName(this.modelName);
|
|
353
|
+
for (let i = 0, userFiltersLength = modelConfig.userFilters.length; i < userFiltersLength; i++) {
|
|
354
|
+
const filter = modelConfig.userFilters[i];
|
|
355
|
+
if (filter.label === this.model.label) {
|
|
356
|
+
this.dialogs.saveFilterAlert = true;
|
|
357
|
+
this.model.id = filter.id;
|
|
358
|
+
this.model.filter = filter.filter;
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
} else {
|
|
363
|
+
if (this.previousModelLabel && this.previousModelLabel !== this.model.label) {
|
|
364
|
+
this.method = 'create';
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
this.save();
|
|
368
|
+
},
|
|
369
|
+
getPuiVariables() {
|
|
370
|
+
this.showSqlBtn = this.$store.state.global.gridfilterShowSqlBtn;
|
|
371
|
+
this.showSubgroupBtn = this.$store.state.global.gridfilterShowSubgroupBtn;
|
|
372
|
+
|
|
373
|
+
if (this.showSqlBtn === undefined || !this.showSubgroupBtn === undefined) {
|
|
374
|
+
const data = {
|
|
375
|
+
model: 'puivariable',
|
|
376
|
+
filter: {
|
|
377
|
+
groups: [],
|
|
378
|
+
groupOp: 'or',
|
|
379
|
+
rules: [
|
|
380
|
+
{ field: 'variable', op: 'eq', data: 'GRIDFILTER_SHOW_SQL_BTN' },
|
|
381
|
+
{ field: 'variable', op: 'eq', data: 'GRIDFILTER_SHOW_SUBGROUP_BTN' }
|
|
382
|
+
]
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
this.$puiRequests.postRequest(
|
|
387
|
+
'/puisearch',
|
|
388
|
+
data,
|
|
389
|
+
(response) => {
|
|
390
|
+
this.updateShowSqlBtnVar(false);
|
|
391
|
+
this.updateShowSubgroupBtnVar(true);
|
|
392
|
+
if (response.data && response.data.data && Array.isArray(response.data.data)) {
|
|
393
|
+
for (let i = 0, dataLength = response.data.data.length; i < dataLength; i++) {
|
|
394
|
+
const puivariable = response.data.data[i];
|
|
395
|
+
if (puivariable.variable === 'GRIDFILTER_SHOW_SQL_BTN') {
|
|
396
|
+
this.updateShowSqlBtnVar(puivariable.value && puivariable.value === 'true');
|
|
397
|
+
} else if (puivariable.variable === 'GRIDFILTER_SHOW_SUBGROUP_BTN') {
|
|
398
|
+
this.updateShowSubgroupBtnVar(puivariable.value && puivariable.value === 'true');
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
() => {
|
|
404
|
+
this.updateShowSqlBtnVar(false);
|
|
405
|
+
this.updateShowSubgroupBtnVar(true);
|
|
406
|
+
}
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
updateShowSqlBtnVar(newValue) {
|
|
411
|
+
this.showSqlBtn = newValue;
|
|
412
|
+
this.$store.state.global.gridfilterShowSqlBtn = this.showSqlBtn;
|
|
413
|
+
},
|
|
414
|
+
updateShowSubgroupBtnVar(newValue) {
|
|
415
|
+
this.showSubgroupBtn = newValue;
|
|
416
|
+
this.$store.state.global.gridfilterShowSubgroupBtn = this.showSubgroupBtn;
|
|
417
|
+
},
|
|
418
|
+
subscribeToModalDialogsEvents() {
|
|
419
|
+
this.$puiEvents.$on(`pui-modalDialog-saveFilterAlert-${this.modelName}-ok`, () => {
|
|
420
|
+
this.dialogs.saveFilterAlert = false;
|
|
421
|
+
this.method = 'update';
|
|
422
|
+
this.save();
|
|
423
|
+
});
|
|
424
|
+
this.$puiEvents.$on(`pui-modalDialog-saveFilterAlert-${this.modelName}-cancel`, () => {
|
|
425
|
+
this.dialogs.saveFilterAlert = false;
|
|
426
|
+
});
|
|
427
|
+
},
|
|
428
|
+
unsubscribeToModalDialogEvent(topicPrefix) {
|
|
429
|
+
this.$puiEvents.$off(`${topicPrefix}-ok`);
|
|
430
|
+
this.$puiEvents.$off(`${topicPrefix}-cancel`);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
</script>
|