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,313 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-layout wrap class="pb-1 pt-1 mb-1 puiGridFilterGroup" @mouseover.stop="showGroupBtns = true" @mouseout="showGroupBtns = false">
|
|
3
|
+
<v-flex xs12 v-if="isGroup0">
|
|
4
|
+
<v-toolbar height="48" class="elevation-0 bottomtoolbar pt-1 pb-1">
|
|
5
|
+
<v-btn v-if="disabled === false" class="btnAddGroup elevation-0" @click="addSubGroup()">
|
|
6
|
+
<v-icon small>fa fa-layer-group</v-icon>
|
|
7
|
+
<span>{{ $t('addGroup') }}</span>
|
|
8
|
+
</v-btn>
|
|
9
|
+
<v-spacer></v-spacer>
|
|
10
|
+
</v-toolbar>
|
|
11
|
+
</v-flex>
|
|
12
|
+
<v-flex xs12 v-if="(isGroup0 && groups.length > 1) || !isGroup0">
|
|
13
|
+
<v-layout wrap class="puiGridFilterGroup__groupOperator pt-1 pl-3">
|
|
14
|
+
<v-flex xs4 align-self-center>
|
|
15
|
+
<span>{{ $t('labelGroup') }}</span>
|
|
16
|
+
</v-flex>
|
|
17
|
+
<v-flex xs2>
|
|
18
|
+
<v-select
|
|
19
|
+
:label="$t('or')"
|
|
20
|
+
append-icon="fa fa-angle-down"
|
|
21
|
+
solo
|
|
22
|
+
flat
|
|
23
|
+
hide-details
|
|
24
|
+
:items="groupOperators"
|
|
25
|
+
v-model="groupOp"
|
|
26
|
+
:disabled="disabled"
|
|
27
|
+
></v-select>
|
|
28
|
+
</v-flex>
|
|
29
|
+
</v-layout>
|
|
30
|
+
</v-flex>
|
|
31
|
+
<v-layout v-if="!isGroup0" wrap>
|
|
32
|
+
<v-flex xs12>
|
|
33
|
+
<v-layout v-for="rule in rules" :key="rule.index">
|
|
34
|
+
<v-flex xs11>
|
|
35
|
+
<pui-grid-filter-rule
|
|
36
|
+
:ref="`rule${rule.index}`"
|
|
37
|
+
:ruleIndex="rule.index"
|
|
38
|
+
:columns="columns"
|
|
39
|
+
:fieldProp="rule.field"
|
|
40
|
+
:opProp="rule.op"
|
|
41
|
+
:dataProp="rule.data"
|
|
42
|
+
:caseSensitiveProp="rule.caseSensitiveAndAccents"
|
|
43
|
+
:group="groupName"
|
|
44
|
+
:ruleOperators="groupOperators"
|
|
45
|
+
:disabled="disabled"
|
|
46
|
+
></pui-grid-filter-rule>
|
|
47
|
+
</v-flex>
|
|
48
|
+
<v-flex xs1 v-if="disabled === false">
|
|
49
|
+
<v-list-item>
|
|
50
|
+
<v-icon class="pointer" small @click.native="removeRule(rule.index)">fa fa-trash-alt</v-icon>
|
|
51
|
+
</v-list-item>
|
|
52
|
+
</v-flex>
|
|
53
|
+
</v-layout>
|
|
54
|
+
</v-flex>
|
|
55
|
+
</v-layout>
|
|
56
|
+
<v-layout wrap v-if="groups.length > 0" class="full-width">
|
|
57
|
+
<pui-grid-filter-group
|
|
58
|
+
v-for="(group, i) in groups"
|
|
59
|
+
:key="group.index"
|
|
60
|
+
:ref="`group${group.index}`"
|
|
61
|
+
:groupName="groupName + '-' + group.index"
|
|
62
|
+
:groupOperators="groupOperators"
|
|
63
|
+
:columns="columns"
|
|
64
|
+
:rulesProp="groupsProp ? groupsProp[i].rules : undefined"
|
|
65
|
+
:groupOpProp="groupsProp ? groupsProp[i].groupOp : undefined"
|
|
66
|
+
:groupsProp="groupsProp ? groupsProp[i].groups : undefined"
|
|
67
|
+
:disabled="disabled"
|
|
68
|
+
:showSubgroupBtn="showSubgroupBtn"
|
|
69
|
+
></pui-grid-filter-group>
|
|
70
|
+
</v-layout>
|
|
71
|
+
<v-layout v-if="!isGroup0" wrap>
|
|
72
|
+
<v-flex xs12>
|
|
73
|
+
<v-toolbar height="32" class="elevation-0 puiGridFilterGroup__bottombar">
|
|
74
|
+
<v-btn v-if="disabled === false" class="btnGroup btnAddRule elevation-0 ml-3" @click="addRule()">
|
|
75
|
+
<v-icon small>far fa-plus</v-icon>
|
|
76
|
+
<span>{{ $t('addRule') }}</span>
|
|
77
|
+
</v-btn>
|
|
78
|
+
<v-btn v-if="showSubgroupBtn && disabled === false" class="btnGroup btnAddGroup elevation-0" @click="addSubGroup()">
|
|
79
|
+
<v-icon small>fa fa-layer-group</v-icon>
|
|
80
|
+
<span>{{ $t('addSubGroup') }}</span>
|
|
81
|
+
</v-btn>
|
|
82
|
+
<v-btn v-if="!isFirstGroup && disabled === false" class="btnGroup btnRemGroup elevation-0" @click="removeGroup()">
|
|
83
|
+
<v-icon small>fa fa-trash-alt</v-icon>
|
|
84
|
+
<span>{{ $t('removeGroup') }}</span>
|
|
85
|
+
</v-btn>
|
|
86
|
+
<v-spacer></v-spacer>
|
|
87
|
+
</v-toolbar>
|
|
88
|
+
</v-flex>
|
|
89
|
+
</v-layout>
|
|
90
|
+
</v-layout>
|
|
91
|
+
</template>
|
|
92
|
+
|
|
93
|
+
<script>
|
|
94
|
+
import PuiGridFilterRule from './PuiGridFilterRule';
|
|
95
|
+
|
|
96
|
+
export default {
|
|
97
|
+
name: 'PuiGridFilterGroup',
|
|
98
|
+
components: {
|
|
99
|
+
PuiGridFilterRule
|
|
100
|
+
},
|
|
101
|
+
props: {
|
|
102
|
+
columns: {
|
|
103
|
+
type: Array,
|
|
104
|
+
required: true
|
|
105
|
+
},
|
|
106
|
+
groupName: {
|
|
107
|
+
type: String
|
|
108
|
+
},
|
|
109
|
+
rulesProp: {
|
|
110
|
+
type: Array
|
|
111
|
+
},
|
|
112
|
+
groupOpProp: {
|
|
113
|
+
type: String
|
|
114
|
+
},
|
|
115
|
+
groupsProp: {
|
|
116
|
+
type: Array
|
|
117
|
+
},
|
|
118
|
+
disabled: {
|
|
119
|
+
type: Boolean,
|
|
120
|
+
default: false
|
|
121
|
+
},
|
|
122
|
+
showSubgroupBtn: {
|
|
123
|
+
type: Boolean
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
data() {
|
|
127
|
+
return {
|
|
128
|
+
rules: [],
|
|
129
|
+
groups: [],
|
|
130
|
+
groupOp: 'or',
|
|
131
|
+
showDeleteRule: null,
|
|
132
|
+
showGroupBtns: null,
|
|
133
|
+
groupOperators: [
|
|
134
|
+
{
|
|
135
|
+
text: 'and',
|
|
136
|
+
value: 'and'
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
text: 'or',
|
|
140
|
+
value: 'or'
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
};
|
|
144
|
+
},
|
|
145
|
+
computed: {
|
|
146
|
+
isFirstGroup() {
|
|
147
|
+
if (this.groups.length === 1) {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
151
|
+
},
|
|
152
|
+
isGroup0() {
|
|
153
|
+
return this.groupName === '0';
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
created() {
|
|
157
|
+
this.translateGroupOperators();
|
|
158
|
+
if (this.groupOpProp && this.groupsProp && this.rulesProp) {
|
|
159
|
+
this.groupOp = this.groupOpProp;
|
|
160
|
+
this.groups = this.groupsProp;
|
|
161
|
+
this.rules = this.rulesProp;
|
|
162
|
+
this.groups.forEach((element) => (element.index = this.getUniqueIndex()));
|
|
163
|
+
this.rules.forEach((element) => (element.index = this.getUniqueIndex()));
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
mounted() {
|
|
167
|
+
this.$puiEvents.$on('reset-filtering', this.reset);
|
|
168
|
+
this.$puiEvents.$on(`groupRemoved-${this.groupName}`, this.onGroupRemoved);
|
|
169
|
+
if (!this.groupsProp && this.isGroup0 === true && !this.groupComp) {
|
|
170
|
+
this.addSubGroup();
|
|
171
|
+
} else if (!this.groupsProp && this.groupName === '0-0' && this.rules.length === 0) {
|
|
172
|
+
this.addRule();
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
destroyed() {
|
|
176
|
+
this.$puiEvents.$off('reset-filtering', this.reset);
|
|
177
|
+
this.$puiEvents.$off(`groupRemoved-${this.groupName}`);
|
|
178
|
+
},
|
|
179
|
+
methods: {
|
|
180
|
+
getUniqueIndex() {
|
|
181
|
+
let numberSTR = Math.random().toString().replace('.', Math.random().toString().replace('.', '').substring(0, 10)).substring(0, 20);
|
|
182
|
+
let numberInt = parseInt(numberSTR).toFixed();
|
|
183
|
+
let integer = parseInt(numberInt);
|
|
184
|
+
return integer;
|
|
185
|
+
},
|
|
186
|
+
translateGroupOperators() {
|
|
187
|
+
for (let i = 0, length = this.groupOperators.length; i < length; i++) {
|
|
188
|
+
this.groupOperators[i].text = this.$t(this.groupOperators[i].text);
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
reset() {
|
|
192
|
+
this.rules = [];
|
|
193
|
+
this.groups = [];
|
|
194
|
+
for (var ruleOrGroup in this.$refs) {
|
|
195
|
+
delete this.$refs[ruleOrGroup];
|
|
196
|
+
}
|
|
197
|
+
this.addSubGroup();
|
|
198
|
+
},
|
|
199
|
+
addRule() {
|
|
200
|
+
this.rules.push({ index: this.getUniqueIndex() });
|
|
201
|
+
},
|
|
202
|
+
addSubGroup() {
|
|
203
|
+
this.groups.push({ index: this.getUniqueIndex() });
|
|
204
|
+
},
|
|
205
|
+
removeRule(index) {
|
|
206
|
+
delete this.$refs[`rule${index}`];
|
|
207
|
+
this.rules.splice(
|
|
208
|
+
this.rules.findIndex((rule) => rule.index === index),
|
|
209
|
+
1
|
|
210
|
+
);
|
|
211
|
+
},
|
|
212
|
+
onGroupRemoved(index) {
|
|
213
|
+
delete this.$refs[`group${index}`];
|
|
214
|
+
this.groups.splice(
|
|
215
|
+
this.groups.findIndex((group) => group.index === index),
|
|
216
|
+
1
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
if (this.isGroup0 && this.groupsProp) {
|
|
220
|
+
this.groups = this.groupsProp;
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
removeGroup() {
|
|
224
|
+
//Obtenemos el indice de grupo de sí mismo
|
|
225
|
+
const array = this.groupName.split('-');
|
|
226
|
+
//el indice de grupo es el numero más a la derecha del nombre (separados por -)
|
|
227
|
+
const index = array[array.length - 1];
|
|
228
|
+
//el nombre del padre es el groupName quitandole '-' + index
|
|
229
|
+
const parentGroupName = array.slice(0, -1).join('-') || array[0];
|
|
230
|
+
//publicamos el evento y el grupo padre se encargará de borrar este grupo
|
|
231
|
+
this.$puiEvents.$emit(`groupRemoved-${parentGroupName}`, index);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
</script>
|
|
236
|
+
|
|
237
|
+
<style lang="postcss" scoped>
|
|
238
|
+
.dragger {
|
|
239
|
+
height: 24px !important;
|
|
240
|
+
width: 20px !important;
|
|
241
|
+
min-width: 20px !important;
|
|
242
|
+
padding-left: 3px !important;
|
|
243
|
+
padding-right: 3px !important;
|
|
244
|
+
color: var(--N-100) !important;
|
|
245
|
+
cursor: move !important;
|
|
246
|
+
&:hover {
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
.btnGroup {
|
|
250
|
+
height: 28px !important;
|
|
251
|
+
color: var(--N-500);
|
|
252
|
+
& span {
|
|
253
|
+
padding-left: 6px;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
.puiGridFilterGroup {
|
|
257
|
+
background-color: var(--N-10);
|
|
258
|
+
border-radius: 5px;
|
|
259
|
+
&__groupOperator {
|
|
260
|
+
height: 50px;
|
|
261
|
+
}
|
|
262
|
+
&__bottombar {
|
|
263
|
+
}
|
|
264
|
+
& .bottomtoolbar {
|
|
265
|
+
background-color: transparent !important;
|
|
266
|
+
}
|
|
267
|
+
& .puiGridFilterGroup {
|
|
268
|
+
background-color: var(--N-0);
|
|
269
|
+
margin-left: 11px;
|
|
270
|
+
margin-right: 5px;
|
|
271
|
+
border-width: 1px;
|
|
272
|
+
border-style: solid;
|
|
273
|
+
border-color: var(--N-100);
|
|
274
|
+
& .v-toolbar,
|
|
275
|
+
.v-btn {
|
|
276
|
+
background-color: var(--N-0);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
& .puiGridFilterGroup {
|
|
280
|
+
background-color: var(--N-10);
|
|
281
|
+
margin-left: 11px;
|
|
282
|
+
margin-right: 5px;
|
|
283
|
+
& .v-toolbar,
|
|
284
|
+
.v-btn {
|
|
285
|
+
background-color: var(--N-10);
|
|
286
|
+
}
|
|
287
|
+
& .puiGridFilterGroup {
|
|
288
|
+
background-color: var(--N-0);
|
|
289
|
+
margin-left: 11px;
|
|
290
|
+
margin-right: 5px;
|
|
291
|
+
& .v-toolbar,
|
|
292
|
+
.v-btn {
|
|
293
|
+
background-color: var(--N-0);
|
|
294
|
+
}
|
|
295
|
+
& .puiGridFilterGroup {
|
|
296
|
+
background-color: var(--N-10);
|
|
297
|
+
margin-left: 11px;
|
|
298
|
+
margin-right: 5px;
|
|
299
|
+
& .v-toolbar,
|
|
300
|
+
.v-btn {
|
|
301
|
+
background-color: var(--N-10);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
.puiFilter__group {
|
|
309
|
+
padding-left: 15px;
|
|
310
|
+
background-color: var(--N-10);
|
|
311
|
+
border-radius: 3px;
|
|
312
|
+
}
|
|
313
|
+
</style>
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="btn">
|
|
3
|
+
<label v-if="label && !$store.getters.isMobile">{{ label }}</label>
|
|
4
|
+
<v-btn
|
|
5
|
+
v-if="!$store.getters.isMobile"
|
|
6
|
+
class="pui-toolbar__btn elevation-0"
|
|
7
|
+
:class="compClass"
|
|
8
|
+
@click.native.stop="states.active = !states.active"
|
|
9
|
+
>
|
|
10
|
+
<span>{{ $t('puidatatables.filters') }}</span>
|
|
11
|
+
<span class="ml-2">
|
|
12
|
+
<v-icon v-if="!states.active" small>fa fa-angle-down</v-icon>
|
|
13
|
+
<v-icon v-else small>fa fa-angle-up</v-icon>
|
|
14
|
+
</span>
|
|
15
|
+
</v-btn>
|
|
16
|
+
<v-btn v-else class="pui-toolbar__btn elevation-0" :class="compClass" @click.native.stop="states.active = !states.active">
|
|
17
|
+
<v-icon x-small>fas fa-filter</v-icon>
|
|
18
|
+
</v-btn>
|
|
19
|
+
<label v-if="label && $store.getters.isMobile">{{ label }}</label>
|
|
20
|
+
<pui-grid-filter-list-dialog
|
|
21
|
+
:modelName="modelName"
|
|
22
|
+
:position="panel.position"
|
|
23
|
+
v-show="states.active"
|
|
24
|
+
:visibility="states.active"
|
|
25
|
+
></pui-grid-filter-list-dialog>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script>
|
|
30
|
+
import PuiGridFilterListDialog from './PuiGridFilterListDialog';
|
|
31
|
+
import PuiToolbarBtnMixin from '../../../../mixins/PuiToolbarBtnMixin';
|
|
32
|
+
|
|
33
|
+
export default {
|
|
34
|
+
name: 'PuiGridFilterListBtn',
|
|
35
|
+
mixins: [PuiToolbarBtnMixin],
|
|
36
|
+
components: {
|
|
37
|
+
PuiGridFilterListDialog
|
|
38
|
+
},
|
|
39
|
+
data() {
|
|
40
|
+
return {
|
|
41
|
+
idTool: 'filterlist',
|
|
42
|
+
panel: {
|
|
43
|
+
position: {}
|
|
44
|
+
},
|
|
45
|
+
label: ''
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
props: {
|
|
49
|
+
modelName: {
|
|
50
|
+
type: String,
|
|
51
|
+
required: true
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
mounted() {
|
|
55
|
+
this.$puiEvents.$on(`onPui-apply-storedFilter-${this.modelName}`, (params) => {
|
|
56
|
+
if (params && params.length > 1) {
|
|
57
|
+
// params[0] == filter
|
|
58
|
+
this.label = (params[0] && params[0].label) || '';
|
|
59
|
+
this.prevLabel = this.label;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
this.$puiEvents.$on(`onPui-disapply-storedFilter-${this.modelName}`, () => {
|
|
63
|
+
this.label = '';
|
|
64
|
+
this.prevLabel = '';
|
|
65
|
+
});
|
|
66
|
+
this.$puiEvents.$on(`onPui-toggle-filtering-${this.modelName}`, (params) => {
|
|
67
|
+
if (params && params.length > 1) {
|
|
68
|
+
// params[1] == cheched
|
|
69
|
+
const val = params[1];
|
|
70
|
+
if (val === false) {
|
|
71
|
+
this.prevLabel = this.label;
|
|
72
|
+
this.label = '';
|
|
73
|
+
} else {
|
|
74
|
+
this.label = this.prevLabel;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
destroyed() {
|
|
80
|
+
this.$puiEvents.$off(`onPui-apply-storedFilter-${this.modelName}`);
|
|
81
|
+
this.$puiEvents.$off(`onPui-disapply-storedFilter-${this.modelName}`);
|
|
82
|
+
this.$puiEvents.$off(`onPui-toggle-filtering-${this.modelName}`);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
</script>
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="puiGridFilterListDialog elevation-5" :ref="'dialog'" @click.stop>
|
|
3
|
+
<v-layout wrap class="mb-1">
|
|
4
|
+
<v-tabs centered grow v-model="tabActive" slider-color="primary" ref="tabs">
|
|
5
|
+
<v-tab href="#tab1" ref="tab1">{{ $t('puidatatables.user') }}</v-tab>
|
|
6
|
+
<v-tab href="#tab2" ref="tab2">{{ $t('puidatatables.system') }}</v-tab>
|
|
7
|
+
|
|
8
|
+
<v-tab-item value="tab1" class="mt-2">
|
|
9
|
+
<pui-text-field
|
|
10
|
+
id="searchFilter5"
|
|
11
|
+
class="ma-1 mr-2 ml-2"
|
|
12
|
+
:placeholder="getPlaceholder"
|
|
13
|
+
v-model="search1"
|
|
14
|
+
clearable
|
|
15
|
+
prepend-inner-icon="far fa-search"
|
|
16
|
+
noeditable
|
|
17
|
+
realtime
|
|
18
|
+
></pui-text-field>
|
|
19
|
+
<div>
|
|
20
|
+
<pui-grid-filter-list-item
|
|
21
|
+
v-for="filter in filteredUser"
|
|
22
|
+
:key="filter.id"
|
|
23
|
+
:model="filter"
|
|
24
|
+
typeFilter="user"
|
|
25
|
+
:ref="`user-${filter.id}`"
|
|
26
|
+
></pui-grid-filter-list-item>
|
|
27
|
+
</div>
|
|
28
|
+
</v-tab-item>
|
|
29
|
+
<v-tab-item value="tab2" class="mt-2">
|
|
30
|
+
<pui-text-field
|
|
31
|
+
class="ma-1 mr-2 ml-2"
|
|
32
|
+
:placeholder="getPlaceholder"
|
|
33
|
+
v-model="search2"
|
|
34
|
+
clearable
|
|
35
|
+
prepend-inner-icon="far fa-search"
|
|
36
|
+
noeditable
|
|
37
|
+
realtime
|
|
38
|
+
></pui-text-field>
|
|
39
|
+
<div>
|
|
40
|
+
<pui-grid-filter-list-item
|
|
41
|
+
v-for="filter in filteredSystem"
|
|
42
|
+
:key="filter.id"
|
|
43
|
+
:model="filter"
|
|
44
|
+
typeFilter="system"
|
|
45
|
+
:ref="`system-${filter.id}`"
|
|
46
|
+
></pui-grid-filter-list-item>
|
|
47
|
+
</div>
|
|
48
|
+
</v-tab-item>
|
|
49
|
+
</v-tabs>
|
|
50
|
+
</v-layout>
|
|
51
|
+
</div>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<script>
|
|
55
|
+
import PuiToolbarDialogMixin from '../../../../mixins/PuiToolbarDialogMixin';
|
|
56
|
+
import PuiGridFilterListItem from './PuiGridFilterListItem';
|
|
57
|
+
|
|
58
|
+
export default {
|
|
59
|
+
name: 'PuiGridFilterListDialog',
|
|
60
|
+
components: {
|
|
61
|
+
PuiGridFilterListItem
|
|
62
|
+
},
|
|
63
|
+
mixins: [PuiToolbarDialogMixin],
|
|
64
|
+
props: {
|
|
65
|
+
position: {
|
|
66
|
+
type: Object
|
|
67
|
+
},
|
|
68
|
+
modelName: {
|
|
69
|
+
type: String,
|
|
70
|
+
required: true
|
|
71
|
+
},
|
|
72
|
+
visibility: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
default: true
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
data() {
|
|
78
|
+
return {
|
|
79
|
+
filters: {
|
|
80
|
+
user: [],
|
|
81
|
+
system: []
|
|
82
|
+
},
|
|
83
|
+
filteredUser: null,
|
|
84
|
+
filteredSystem: null,
|
|
85
|
+
search1: '',
|
|
86
|
+
search2: '',
|
|
87
|
+
tabActive: 'tab2',
|
|
88
|
+
userFilterModelName: 'puiusermodelfilter',
|
|
89
|
+
firstLoad: true
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
mounted() {
|
|
93
|
+
if (this.$store.getters.isMobile) {
|
|
94
|
+
this.$refs.dialog.style.right = '0px';
|
|
95
|
+
}
|
|
96
|
+
const self = this;
|
|
97
|
+
this.$puiEvents.$on(`onPui-apply-storedFilter-${this.modelName}`, (params) => {
|
|
98
|
+
// params[0] === filter object selected, can be null
|
|
99
|
+
// params[1] === true or false (checked or not)
|
|
100
|
+
if (params && params.length > 0 && params[0] != null) {
|
|
101
|
+
self.filterId = params[0].id;
|
|
102
|
+
self.isSystemFilter = params[0].isSystemFilter;
|
|
103
|
+
}
|
|
104
|
+
self.filters.user.forEach((fil) => {
|
|
105
|
+
if (fil.id === self.filterId && !self.isSystemFilter) {
|
|
106
|
+
fil.checked = params[1];
|
|
107
|
+
} else {
|
|
108
|
+
fil.checked = false;
|
|
109
|
+
}
|
|
110
|
+
console.log('Filtros de usuario: ', fil.label + ' ' + fil.checked);
|
|
111
|
+
});
|
|
112
|
+
self.filters.system.forEach((fil) => {
|
|
113
|
+
if (fil.id === self.filterId && self.isSystemFilter) {
|
|
114
|
+
fil.checked = params[1];
|
|
115
|
+
} else {
|
|
116
|
+
fil.checked = false;
|
|
117
|
+
}
|
|
118
|
+
console.log('Filtros de sistema: ', fil.label + ' ' + fil.checked);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
self.filteredUser = self.filters.user;
|
|
122
|
+
self.filteredSystem = self.filters.system;
|
|
123
|
+
});
|
|
124
|
+
this.$puiEvents.$on(`onPui-insertRow-dataTable-${this.userFilterModelName}`, (theNewFilter) => {
|
|
125
|
+
//por si hay más de un grid en el componente comprobamos que añadimos en el filterListDialog correcto
|
|
126
|
+
if (theNewFilter.model === self.modelName) {
|
|
127
|
+
self.filters.user.push(theNewFilter);
|
|
128
|
+
self.filters.user.sort((filter1, filter2) => {
|
|
129
|
+
return filter1.label1 > filter2.label;
|
|
130
|
+
});
|
|
131
|
+
self.filteredUser = self.filters.user;
|
|
132
|
+
const modelConfig = self.$store.getters.getModelByName(self.modelName);
|
|
133
|
+
modelConfig.userFilters = self.filters.user;
|
|
134
|
+
modelConfig.currentFilter = theNewFilter;
|
|
135
|
+
this.$puiEvents.$emit(`onPui-apply-storedFilter-${self.modelName}`, [theNewFilter, true]);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
this.$puiEvents.$on(`onPui-deleteRow-dataTable-${this.userFilterModelName}`, (theFilter) => {
|
|
139
|
+
const modelConfig = self.$store.getters.getModelByName(self.modelName);
|
|
140
|
+
self.filters.user.forEach((filter, index) => {
|
|
141
|
+
if (theFilter.id === filter.id) {
|
|
142
|
+
self.filters.user.splice(index, 1);
|
|
143
|
+
self.filteredUser = self.filters.user;
|
|
144
|
+
modelConfig.userFilters = self.filters.user;
|
|
145
|
+
if (modelConfig.currentFilter && modelConfig.currentFilter.id === theFilter.id) {
|
|
146
|
+
modelConfig.currentFilter = null;
|
|
147
|
+
this.$puiEvents.$emit(`onPui-apply-filtering-${self.modelName}`, null);
|
|
148
|
+
this.$puiEvents.$emit(`onPui-disapply-storedFilter-${self.modelName}`);
|
|
149
|
+
}
|
|
150
|
+
//eslint-disable-next-line no-useless-return
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
this.$puiEvents.$on(`onPui-updateRow-dataTable-${this.userFilterModelName}`, (theFilter) => {
|
|
156
|
+
//por si hay más de un grid en el componente comprobamos que editamos en el filterListDialog correcto
|
|
157
|
+
if (theFilter.model === self.modelName) {
|
|
158
|
+
const modelConfig = self.$store.getters.getModelByName(self.modelName);
|
|
159
|
+
self.filters.user.forEach((filter, index) => {
|
|
160
|
+
if (filter.id === theFilter.id) {
|
|
161
|
+
self.filters.user[index] = theFilter;
|
|
162
|
+
modelConfig.userFilters = self.filters.user;
|
|
163
|
+
modelConfig.currentFilter = theFilter;
|
|
164
|
+
this.$puiEvents.$emit(`onPui-apply-storedFilter-${self.modelName}`, [theFilter, true]);
|
|
165
|
+
//eslint-disable-next-line no-useless-return
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
self.filters.user = self.filters.user.map((filter) => {
|
|
170
|
+
return filter;
|
|
171
|
+
});
|
|
172
|
+
self.filteredUser = self.filters.user;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
this.getData();
|
|
177
|
+
this.calculatePosition();
|
|
178
|
+
},
|
|
179
|
+
updated() {
|
|
180
|
+
this.calculatePosition();
|
|
181
|
+
},
|
|
182
|
+
destroyed() {
|
|
183
|
+
this.$puiEvents.$off(`onPui-insertRow-dataTable-${this.userFilterModelName}`);
|
|
184
|
+
this.$puiEvents.$off(`onPui-updateRow-dataTable-${this.userFilterModelName}`);
|
|
185
|
+
this.$puiEvents.$off(`onPui-deleteRow-dataTable-${this.userFilterModelName}`);
|
|
186
|
+
this.$puiEvents.$off(`onPui-apply-storedFilter-${this.modelName}`);
|
|
187
|
+
this.$puiEvents.$off(`onPui-apply-filtering-${this.modelName}`);
|
|
188
|
+
},
|
|
189
|
+
computed: {
|
|
190
|
+
getPlaceholder() {
|
|
191
|
+
return this.$t('puidatatables.searchPlaceholder');
|
|
192
|
+
},
|
|
193
|
+
onPuiModelsLoadedAndSaved() {
|
|
194
|
+
return this.$store.state.modelsLoadedAndSaved;
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
watch: {
|
|
198
|
+
onPuiModelsLoadedAndSaved() {
|
|
199
|
+
if (this.modelConfig === undefined) {
|
|
200
|
+
this.getData();
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
search1(val) {
|
|
204
|
+
if (val && val.length > 0) {
|
|
205
|
+
this.filteredUser = this.filters.user.filter((filter) => {
|
|
206
|
+
return filter.label.toUpperCase().match(val.toUpperCase());
|
|
207
|
+
});
|
|
208
|
+
} else {
|
|
209
|
+
this.filteredUser = this.filters.user;
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
search2(val) {
|
|
213
|
+
if (val && val.length > 0) {
|
|
214
|
+
this.filteredSystem = this.filters.system.filter((filter) => {
|
|
215
|
+
return filter.label.toUpperCase().match(val.toUpperCase());
|
|
216
|
+
});
|
|
217
|
+
} else {
|
|
218
|
+
this.filteredSystem = this.filters.system;
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
visibility(val) {
|
|
222
|
+
// HACK GET STYLE FIRST TAB
|
|
223
|
+
if (val && this.firstLoad) {
|
|
224
|
+
this.firstLoad = false;
|
|
225
|
+
this.$refs.tabs.$emit('change', 'tab1');
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
methods: {
|
|
230
|
+
getData() {
|
|
231
|
+
this.modelConfig = this.$store.getters.getModelByName(this.modelName);
|
|
232
|
+
if (this.modelConfig === undefined) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
this.filteredUser = this.filters.user = this.modelConfig.userFilters;
|
|
236
|
+
this.filteredSystem = this.filters.system = this.modelConfig.modelFilters;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
</script>
|
|
241
|
+
<style lang="postcss" scoped>
|
|
242
|
+
.puiGridFilterListDialog {
|
|
243
|
+
background-color: var(--N-0);
|
|
244
|
+
position: absolute;
|
|
245
|
+
z-index: 8;
|
|
246
|
+
border-radius: 5px;
|
|
247
|
+
width: 260px;
|
|
248
|
+
}
|
|
249
|
+
</style>
|
|
250
|
+
<style lang="postcss">
|
|
251
|
+
.searchFilter .v-input__icon.v-input__icon--clear .v-icon {
|
|
252
|
+
margin-top: 12px !important;
|
|
253
|
+
}
|
|
254
|
+
</style>
|