@mapomodule/uikit 1.0.0-alpha.2 → 1.0.0-alpha.7
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/CHANGELOG.md +115 -0
- package/components/Detail/Detail.vue +156 -95
- package/components/Detail/DetailField.vue +14 -11
- package/components/Detail/defaults.js +6 -1
- package/components/DropArea.vue +1 -1
- package/components/List/List.vue +100 -40
- package/components/List/ListActions.vue +38 -17
- package/components/List/ListFilters.vue +127 -113
- package/components/List/ListHead.vue +23 -13
- package/components/List/ListQuickEdit.vue +14 -5
- package/components/List/ListTable.vue +218 -76
- package/components/MediaManager/MediaEditor.vue +247 -107
- package/components/MediaManager/MediaFolders.vue +122 -38
- package/components/MediaManager/MediaGallery.vue +56 -52
- package/components/MediaManager/MediaManager.vue +114 -74
- package/components/MediaManager/MediaManagerDialog.vue +19 -22
- package/components/MediaManager/MediaPreview.vue +180 -0
- package/components/MediaManager/MediaUploader.vue +35 -32
- package/components/fields/MediaField.vue +12 -2
- package/components/fields/SeoPreview.vue +89 -0
- package/components/fields/TinyMce/TinyMce.vue +29 -10
- package/components/fields/TinyMce/defaults.js +1 -1
- package/components/layout/Sidebar/Sidebar.vue +46 -24
- package/components/layout/Sidebar/SidebarFooter.vue +41 -46
- package/components/layout/Sidebar/SidebarList.vue +12 -14
- package/components/layout/Sidebar/SidebarListItem.vue +65 -38
- package/components/layout/Topbar/Topbar.vue +3 -36
- package/components/layout/routebuilder.js +1 -1
- package/layouts/default.vue +3 -14
- package/package.json +2 -2
- package/pages/index.vue +1 -2
package/components/List/List.vue
CHANGED
|
@@ -3,16 +3,17 @@
|
|
|
3
3
|
<ListHead v-bind="$attrs" />
|
|
4
4
|
|
|
5
5
|
<div>
|
|
6
|
-
<v-row class="mb-
|
|
6
|
+
<v-row class="mb-1">
|
|
7
7
|
<v-col cols="12" md="4">
|
|
8
8
|
<ListActions
|
|
9
9
|
v-bind="$attrs"
|
|
10
10
|
:crud="crud"
|
|
11
|
-
:selection="selection"
|
|
11
|
+
:selection="allSelected ? 'all' : selection"
|
|
12
|
+
:selectionQuery="selectionQuery"
|
|
12
13
|
@actionCompleted="refresh"
|
|
13
14
|
/>
|
|
14
15
|
</v-col>
|
|
15
|
-
<v-col cols="12" md="8">
|
|
16
|
+
<v-col cols="12" md="8" class="d-flex flex-nowrap justify-end align-center">
|
|
16
17
|
<ListFilters v-bind="$attrs" v-model="filters">
|
|
17
18
|
<template v-for="(_, slot) in $slots" :slot="slot">
|
|
18
19
|
<!-- @vuese-ignore -->
|
|
@@ -25,9 +26,26 @@
|
|
|
25
26
|
</ListFilters>
|
|
26
27
|
</v-col>
|
|
27
28
|
</v-row>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
<div class="d-flex justify-end">
|
|
30
|
+
<!-- Overrides counter for selected items. -->
|
|
31
|
+
<slot name="item-counter" v-bind="{ selection, canSelectAll, allSelected, toggleSelectAll }">
|
|
32
|
+
<div v-if="selection" class="caption mr-1 mb-1">
|
|
33
|
+
<b v-if="allSelected">All items selected</b>
|
|
34
|
+
<span v-else-if="selection.length">
|
|
35
|
+
{{ selection.length }} items selected
|
|
36
|
+
<v-btn
|
|
37
|
+
v-if="selection != 'all' && canSelectAll"
|
|
38
|
+
@click="toggleSelectAll"
|
|
39
|
+
outlined
|
|
40
|
+
tile
|
|
41
|
+
x-small
|
|
42
|
+
class="ml-1 d-inline-flex"
|
|
43
|
+
>Select all</v-btn
|
|
44
|
+
>
|
|
45
|
+
</span>
|
|
46
|
+
</div>
|
|
47
|
+
</slot>
|
|
48
|
+
</div>
|
|
31
49
|
</div>
|
|
32
50
|
<div>
|
|
33
51
|
<ListTable
|
|
@@ -54,7 +72,7 @@
|
|
|
54
72
|
* The purpose of this component is to provide you with a very quick way to create a page that can show a list of resources retrieved from the server.
|
|
55
73
|
* A use case example could be "build a page that lists all the products of an ecommerce". <br><br>
|
|
56
74
|
* This component is a wrapper and is made up of several parts.
|
|
57
|
-
* The props and slots of this component are passed to its childs.
|
|
75
|
+
* The props and slots of this component are passed to its childs.
|
|
58
76
|
* For detailed explanations see [Transparent Wrapping](#transparent-wrapping). <br> <h4>Index:</h4> [[toc]]
|
|
59
77
|
*/
|
|
60
78
|
export default {
|
|
@@ -63,25 +81,31 @@ export default {
|
|
|
63
81
|
return {
|
|
64
82
|
tabActiveStatus: 1,
|
|
65
83
|
selection: [],
|
|
84
|
+
allSelected: false,
|
|
66
85
|
filters: []
|
|
67
86
|
};
|
|
68
87
|
},
|
|
69
88
|
props: {
|
|
70
89
|
// The url of the endpoint that provides the data to display. From this url a complete crud (See [this.$mapo.$api.crud](/core/#$api.crud)) will be created.
|
|
71
90
|
endpoint: {
|
|
72
|
-
type: String
|
|
73
|
-
required: true,
|
|
91
|
+
type: String
|
|
74
92
|
},
|
|
93
|
+
// Add option to select all items in all pages
|
|
94
|
+
canSelectAll: Boolean,
|
|
75
95
|
},
|
|
76
96
|
computed: {
|
|
77
97
|
crud() {
|
|
78
98
|
return this.$mapo.$api.crud(this.endpoint);
|
|
79
99
|
},
|
|
100
|
+
selectionQuery() {
|
|
101
|
+
return this.$refs?.dtable?.getHttpParams();
|
|
102
|
+
}
|
|
80
103
|
},
|
|
81
104
|
watch: {
|
|
82
105
|
selection(val) {
|
|
106
|
+
this.allSelected = val == 'all';
|
|
83
107
|
// Fires when you select some row of the table.
|
|
84
|
-
// @arg Emit the list of the selected rows.
|
|
108
|
+
// @arg Emit "all" if all items are selected, else the list of the selected rows.
|
|
85
109
|
this.$emit("selectionChange", val);
|
|
86
110
|
},
|
|
87
111
|
},
|
|
@@ -89,6 +113,9 @@ export default {
|
|
|
89
113
|
refresh() {
|
|
90
114
|
return this.$refs.dtable.getDataFromApi();
|
|
91
115
|
},
|
|
116
|
+
toggleSelectAll() {
|
|
117
|
+
return this.$refs?.dtable?.toggleSelectAll();
|
|
118
|
+
}
|
|
92
119
|
},
|
|
93
120
|
mounted() {},
|
|
94
121
|
};
|
|
@@ -113,10 +140,7 @@ Each component within it inherits its props and slots.
|
|
|
113
140
|
For the list of available prop refer to the documentation of each single part.
|
|
114
141
|
|
|
115
142
|
### Slots
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
Each part can be reached with a namespace.
|
|
119
|
-
|
|
143
|
+
Other slots related to sub-components can be reached through these namespaces:
|
|
120
144
|
- `"filter"` is the namespace of [`ListFilters`](../ListFilters/#slots) slots.
|
|
121
145
|
- `"dtable"` is the namespace of [`ListTable`](../ListTable/#slots) slots.
|
|
122
146
|
- `"qedit"` is the namespace of [`ListQuickEdit`](../ListQuickEdit/#slots) slots.
|
|
@@ -133,18 +157,25 @@ This is an interactive example. You can play with it but remember that all http
|
|
|
133
157
|
|
|
134
158
|
::: demo
|
|
135
159
|
<template>
|
|
136
|
-
<v-app
|
|
137
|
-
|
|
160
|
+
<v-app>
|
|
161
|
+
<List
|
|
138
162
|
show-select
|
|
163
|
+
title="Sweets archive:"
|
|
164
|
+
lookup="name"
|
|
139
165
|
:headers="headers"
|
|
140
166
|
:editFields="editFields"
|
|
141
|
-
:filters="availableFilters"
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
167
|
+
:filters="availableFilters"
|
|
168
|
+
multi-sort
|
|
169
|
+
can-select-all
|
|
170
|
+
searchable
|
|
171
|
+
:data.sync="desserts"
|
|
172
|
+
:actions="[]"
|
|
173
|
+
>
|
|
174
|
+
</List>
|
|
175
|
+
<br>
|
|
176
|
+
<h3> Data: </h3>
|
|
177
|
+
<pre>{{ desserts }}</pre>
|
|
178
|
+
</v-app>
|
|
148
179
|
</template>
|
|
149
180
|
|
|
150
181
|
<script>
|
|
@@ -153,37 +184,66 @@ export default {
|
|
|
153
184
|
return {
|
|
154
185
|
headers: [
|
|
155
186
|
{
|
|
156
|
-
text: "
|
|
187
|
+
text: "Dessert (100g serving)",
|
|
157
188
|
align: "start",
|
|
158
189
|
sortable: false,
|
|
159
|
-
value: "
|
|
190
|
+
value: "name",
|
|
160
191
|
},
|
|
161
|
-
{ text: "
|
|
162
|
-
{ text: "
|
|
192
|
+
{ text: "Protein (g)", value: "protein" },
|
|
193
|
+
{ text: "Gluten-Free", value: "glutenfree" },
|
|
163
194
|
{ text: "Actions", value: "actions", sortable: false },
|
|
164
195
|
],
|
|
165
196
|
editFields: [
|
|
166
|
-
{ attrs: { rules:[v => !!v ||
|
|
167
|
-
{
|
|
168
|
-
{ attrs: { rules:[v => !!v || 'Identifier is required'] }, value: "identifier" },
|
|
197
|
+
{ attrs: { rules: [(v) => !!v || "Name is required"] }, value: "name" },
|
|
198
|
+
{ value: "protein" }
|
|
169
199
|
],
|
|
170
200
|
availableFilters: [
|
|
171
201
|
{
|
|
172
|
-
text: "
|
|
173
|
-
value: "
|
|
202
|
+
text: "Gluten Free",
|
|
203
|
+
value: "glutenfree",
|
|
174
204
|
choices: [
|
|
175
|
-
{ text: "
|
|
176
|
-
{ text: "
|
|
177
|
-
{ text: "Trash", value: "TRS" },
|
|
205
|
+
{ text: "Yes", value: true },
|
|
206
|
+
{ text: "No", value: false },
|
|
178
207
|
],
|
|
179
208
|
},
|
|
209
|
+
],
|
|
210
|
+
desserts: [
|
|
180
211
|
{
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
212
|
+
name: "Frozen Yogurt",
|
|
213
|
+
protein: 4.0,
|
|
214
|
+
glutenfree: true,
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
name: "Ice cream sandwich",
|
|
218
|
+
protein: 4.3,
|
|
219
|
+
glutenfree: false,
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
name: "Eclair",
|
|
223
|
+
protein: 6.0,
|
|
224
|
+
glutenfree: false,
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
name: "Jelly bean",
|
|
228
|
+
protein: 0.0,
|
|
229
|
+
glutenfree: true,
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
name: "Lollipop",
|
|
233
|
+
protein: 0,
|
|
234
|
+
glutenfree: true,
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: "KitKat",
|
|
238
|
+
protein: 7,
|
|
239
|
+
glutenfree: false,
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: "KitKat2",
|
|
243
|
+
protein: 77,
|
|
244
|
+
glutenfree: false,
|
|
184
245
|
},
|
|
185
246
|
],
|
|
186
|
-
|
|
187
247
|
};
|
|
188
248
|
},
|
|
189
249
|
};
|
|
@@ -191,4 +251,4 @@ export default {
|
|
|
191
251
|
:::
|
|
192
252
|
|
|
193
253
|
|
|
194
|
-
</docs>
|
|
254
|
+
</docs>
|
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
label="Group Actions"
|
|
5
5
|
v-bind="$attrs"
|
|
6
6
|
v-model="action"
|
|
7
|
-
:items="
|
|
7
|
+
:items="filteredActions"
|
|
8
8
|
item-text="label"
|
|
9
9
|
item-value="handler"
|
|
10
10
|
outlined
|
|
11
11
|
dense
|
|
12
12
|
hide-details
|
|
13
13
|
clearable
|
|
14
|
+
no-data-text="No actions available"
|
|
14
15
|
></v-select>
|
|
15
16
|
<v-btn
|
|
16
17
|
class="rounded-0 elevation-0 ml-2"
|
|
@@ -50,9 +51,7 @@ export default {
|
|
|
50
51
|
{
|
|
51
52
|
label: "Permanent delete",
|
|
52
53
|
handler: function ({ selection, lookup, crud }) {
|
|
53
|
-
return Promise.all(
|
|
54
|
-
selection.map((i) => crud.delete(i[lookup]))
|
|
55
|
-
);
|
|
54
|
+
return Promise.all(selection.map((i) => crud && crud.delete(i[lookup])));
|
|
56
55
|
},
|
|
57
56
|
},
|
|
58
57
|
];
|
|
@@ -60,33 +59,52 @@ export default {
|
|
|
60
59
|
},
|
|
61
60
|
// ❌ This is an internal prop. Sorry..
|
|
62
61
|
selection: {
|
|
63
|
-
// -
|
|
64
|
-
type: Array,
|
|
65
|
-
// -
|
|
62
|
+
// -
|
|
63
|
+
type: [Array, String],
|
|
64
|
+
// -
|
|
66
65
|
default: () => [],
|
|
67
66
|
},
|
|
68
67
|
// ❌ This is an internal prop. Sorry..
|
|
68
|
+
selectionQuery: {
|
|
69
|
+
// -
|
|
70
|
+
type: URLSearchParams,
|
|
71
|
+
// -
|
|
72
|
+
default: () => new URLSearchParams(),
|
|
73
|
+
},
|
|
74
|
+
// ❌ This is an internal prop. Sorry..
|
|
69
75
|
crud: {
|
|
70
|
-
// -
|
|
76
|
+
// -
|
|
71
77
|
type: Object,
|
|
72
78
|
required: true,
|
|
73
79
|
},
|
|
74
80
|
},
|
|
75
|
-
computed:{
|
|
76
|
-
isActive(){
|
|
77
|
-
return this.$attrs[
|
|
81
|
+
computed: {
|
|
82
|
+
isActive() {
|
|
83
|
+
return this.$attrs["show-select"] !== undefined;
|
|
84
|
+
},
|
|
85
|
+
filteredActions() {
|
|
86
|
+
return this.actions.filter((action) => {
|
|
87
|
+
return (this.selection != "all" && (action.handleMultiple ?? true)) || (this.selection == "all" && (action.handleAll ?? false));
|
|
88
|
+
});
|
|
78
89
|
}
|
|
79
90
|
},
|
|
80
91
|
methods: {
|
|
81
92
|
handleAction() {
|
|
82
|
-
if (!this.selection.length) {
|
|
93
|
+
if (!this.selectAll && !this.selection.length) {
|
|
83
94
|
return this.$mapo.$snack.open({
|
|
84
95
|
message: "You need to select at least one item.",
|
|
85
96
|
color: "error",
|
|
86
97
|
});
|
|
87
98
|
}
|
|
88
|
-
const ctx = {
|
|
89
|
-
|
|
99
|
+
const ctx = {
|
|
100
|
+
selection: this.selection,
|
|
101
|
+
selectionQuery: this.selectionQuery,
|
|
102
|
+
lookup: this.lookup,
|
|
103
|
+
crud: this.crud,
|
|
104
|
+
};
|
|
105
|
+
return this.action
|
|
106
|
+
? this.action(ctx).then((res) => this.$emit("actionCompleted", res))
|
|
107
|
+
: () => {};
|
|
90
108
|
},
|
|
91
109
|
},
|
|
92
110
|
};
|
|
@@ -96,13 +114,16 @@ export default {
|
|
|
96
114
|
## Action config
|
|
97
115
|
|
|
98
116
|
|
|
99
|
-
The actions prop is a list of `Action` objects
|
|
117
|
+
The actions prop is a list of `Action` objects containing these keys:
|
|
100
118
|
|
|
101
119
|
- **"label"** `String` ==> The name of the action that will be renered inside the select button.
|
|
120
|
+
- **"handleMultiple"** `Boolean` ==> Make the action callable on multiple items. Default: `true`.
|
|
121
|
+
- **"handleAll"** `Boolean` ==> Make the action callable on all items. Default: `false`.
|
|
102
122
|
- **"handler"** `Function` ==> The callback function that will be executed once the user confirms the action.
|
|
103
123
|
|
|
104
124
|
The handler function will be called with a ctx containing:
|
|
105
|
-
- **"selection"** `Array<Object
|
|
125
|
+
- **"selection"** `Array<Object>` or `String` ==> `"all"` if all items are selected else the list of selected objects.
|
|
126
|
+
- **"selectionQuery"** `URLSearchParams` ==> GET parameters for the current list of objects.
|
|
106
127
|
- **"lookup"** `String` ==> The lookup prop.
|
|
107
128
|
- **"crud"** [`Crud`](/core/#api.crud) ==> The inherited crud from [List](../List/) component.
|
|
108
129
|
|
|
@@ -122,4 +143,4 @@ const actions = [
|
|
|
122
143
|
}
|
|
123
144
|
]
|
|
124
145
|
```
|
|
125
|
-
</docs>
|
|
146
|
+
</docs>
|
|
@@ -1,68 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div v-if="compFilters.length">
|
|
3
|
-
<v-
|
|
4
|
-
<
|
|
5
|
-
<v-
|
|
6
|
-
<v-
|
|
2
|
+
<div v-if="compFilters.length" class="main">
|
|
3
|
+
<v-row class="flex-sm-row-reverse">
|
|
4
|
+
<v-col cols="12" sm="3" class="d-flex justify-end align-center">
|
|
5
|
+
<v-menu offset-y min-width="250px" max-width="400px" nudge-top="-5px" tile :close-on-content-click="false" v-bind="{ ...$attrs, value: null }" >
|
|
6
|
+
<template v-slot:activator="{ on }">
|
|
7
7
|
<v-btn v-bind="$attrs" v-on="on" text>
|
|
8
8
|
filter <v-icon>mdi-filter-variant</v-icon>
|
|
9
9
|
</v-btn>
|
|
10
|
-
</
|
|
11
|
-
<v-col v-if="activeFilters.length" cols="12" sm="9">
|
|
12
|
-
<v-slide-group v-bind="$attrs" show-arrows>
|
|
13
|
-
<v-chip
|
|
14
|
-
v-bind="$attrs"
|
|
15
|
-
class="ma-1"
|
|
16
|
-
close
|
|
17
|
-
label
|
|
18
|
-
@click:close="removeFilter(filter)"
|
|
19
|
-
v-for="(filter, i) in activeFilters"
|
|
20
|
-
:key="i"
|
|
21
|
-
>
|
|
22
|
-
<span>
|
|
23
|
-
<small>
|
|
24
|
-
<b>{{ filter.text.toUpperCase() }}: </b>
|
|
25
|
-
{{ formatActiveChoices(filter.active).toUpperCase() }}
|
|
26
|
-
</small>
|
|
27
|
-
</span>
|
|
28
|
-
</v-chip>
|
|
29
|
-
</v-slide-group>
|
|
30
|
-
</v-col>
|
|
31
|
-
</v-row>
|
|
32
|
-
</template>
|
|
10
|
+
</template>
|
|
33
11
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
<slot
|
|
38
|
-
:name="`filter.${filter.value}`"
|
|
39
|
-
v-bind="{
|
|
40
|
-
filter,
|
|
41
|
-
addFilter,
|
|
42
|
-
removeFilterChoice,
|
|
43
|
-
toggleChoice,
|
|
44
|
-
activeFilters,
|
|
45
|
-
}"
|
|
46
|
-
>
|
|
47
|
-
<v-list-group>
|
|
48
|
-
<v-list-item-title slot="activator">
|
|
49
|
-
<!-- This is a dynamic slot. You can use it to override filters title. -->
|
|
50
|
-
<slot
|
|
51
|
-
:name="`filter.${filter.value}.title`"
|
|
52
|
-
v-bind="{
|
|
53
|
-
filter,
|
|
54
|
-
addFilter,
|
|
55
|
-
removeFilterChoice,
|
|
56
|
-
toggleChoice,
|
|
57
|
-
activeFilters,
|
|
58
|
-
}"
|
|
59
|
-
>
|
|
60
|
-
{{ filter.text }}
|
|
61
|
-
</slot>
|
|
62
|
-
</v-list-item-title>
|
|
63
|
-
<!-- This is a dynamic slot. You can use it to override filters content.-->
|
|
12
|
+
<v-list class="pa-0">
|
|
13
|
+
<div v-for="(filter, index) in compFilters" :key="index">
|
|
14
|
+
<!-- This is a dynamic slot. You can use it to override filters. <br> For example use `filter.status` to completely override the rendering of the filter with `"status"` as value. -->
|
|
64
15
|
<slot
|
|
65
|
-
:name="`filter.${filter.value}
|
|
16
|
+
:name="`filter.${filter.value}`"
|
|
66
17
|
v-bind="{
|
|
67
18
|
filter,
|
|
68
19
|
addFilter,
|
|
@@ -71,63 +22,115 @@
|
|
|
71
22
|
activeFilters,
|
|
72
23
|
}"
|
|
73
24
|
>
|
|
74
|
-
<
|
|
75
|
-
<v-
|
|
76
|
-
|
|
77
|
-
class="rounded-0"
|
|
78
|
-
v-model="filter.dates"
|
|
79
|
-
range
|
|
80
|
-
full-width
|
|
81
|
-
no-title
|
|
82
|
-
color="primary"
|
|
83
|
-
>
|
|
84
|
-
</v-date-picker>
|
|
85
|
-
<v-btn
|
|
86
|
-
class="datapicker-clear-btn elevation-0"
|
|
87
|
-
@click="removeFilter(filter)"
|
|
88
|
-
small
|
|
89
|
-
tile
|
|
90
|
-
>clear</v-btn
|
|
91
|
-
>
|
|
92
|
-
</div>
|
|
93
|
-
<v-list v-else class="overflow-y-auto pa-0" max-height="200" dense>
|
|
94
|
-
<v-list-item
|
|
95
|
-
v-for="(choice, i) in filter.choices"
|
|
96
|
-
:key="i"
|
|
97
|
-
class="v-list-item--link"
|
|
98
|
-
active-class="primary--text"
|
|
99
|
-
:input-value="isChoiceActive(filter, choice)"
|
|
100
|
-
@click.native.stop="toggleChoice(filter, choice)"
|
|
101
|
-
>
|
|
102
|
-
<!-- This is a dynamic slot. You can use it to override filters icon. -->
|
|
25
|
+
<v-list-group>
|
|
26
|
+
<v-list-item-title slot="activator">
|
|
27
|
+
<!-- This is a dynamic slot. You can use it to override filters title. -->
|
|
103
28
|
<slot
|
|
104
|
-
:name="`filter.${filter.value}.
|
|
105
|
-
v-bind="{
|
|
29
|
+
:name="`filter.${filter.value}.title`"
|
|
30
|
+
v-bind="{
|
|
31
|
+
filter,
|
|
32
|
+
addFilter,
|
|
33
|
+
removeFilterChoice,
|
|
34
|
+
toggleChoice,
|
|
35
|
+
activeFilters,
|
|
36
|
+
}"
|
|
106
37
|
>
|
|
107
|
-
|
|
108
|
-
<v-icon
|
|
109
|
-
v-text="choice.icon || 'mdi-circle-small'"
|
|
110
|
-
></v-icon>
|
|
111
|
-
</v-list-item-icon>
|
|
38
|
+
{{ filter.text }}
|
|
112
39
|
</slot>
|
|
40
|
+
</v-list-item-title>
|
|
41
|
+
<!-- This is a dynamic slot. You can use it to override filters content.-->
|
|
42
|
+
<slot
|
|
43
|
+
:name="`filter.${filter.value}.content`"
|
|
44
|
+
v-bind="{
|
|
45
|
+
filter,
|
|
46
|
+
addFilter,
|
|
47
|
+
removeFilterChoice,
|
|
48
|
+
toggleChoice,
|
|
49
|
+
activeFilters,
|
|
50
|
+
}"
|
|
51
|
+
>
|
|
52
|
+
<div v-if="filter.datepicker" class="d-flex flex-column align-end justify-center pb-2">
|
|
53
|
+
<v-date-picker
|
|
54
|
+
@input="addDateFilter(filter)"
|
|
55
|
+
class="rounded-0"
|
|
56
|
+
v-model="filter.dates"
|
|
57
|
+
range
|
|
58
|
+
full-width
|
|
59
|
+
no-title
|
|
60
|
+
color="primary"
|
|
61
|
+
>
|
|
62
|
+
</v-date-picker>
|
|
63
|
+
<v-btn
|
|
64
|
+
class="datapicker-clear-btn elevation-0"
|
|
65
|
+
@click="removeFilter(filter)"
|
|
66
|
+
small
|
|
67
|
+
tile
|
|
68
|
+
>clear</v-btn
|
|
69
|
+
>
|
|
70
|
+
</div>
|
|
71
|
+
<v-list v-else class="overflow-y-auto pa-0" max-height="200" dense>
|
|
72
|
+
<v-list-item
|
|
73
|
+
v-for="(choice, i) in filter.choices"
|
|
74
|
+
:key="i"
|
|
75
|
+
class="v-list-item--link"
|
|
76
|
+
active-class="primary--text"
|
|
77
|
+
:input-value="isChoiceActive(filter, choice)"
|
|
78
|
+
@click.native.stop="toggleChoice(filter, choice)"
|
|
79
|
+
>
|
|
80
|
+
<!-- This is a dynamic slot. You can use it to override filters icon. -->
|
|
81
|
+
<slot
|
|
82
|
+
:name="`filter.${filter.value}.icon`"
|
|
83
|
+
v-bind="{ filter, choice }"
|
|
84
|
+
>
|
|
85
|
+
<v-list-item-icon>
|
|
86
|
+
<v-icon
|
|
87
|
+
v-text="choice.icon || 'mdi-circle-small'"
|
|
88
|
+
></v-icon>
|
|
89
|
+
</v-list-item-icon>
|
|
90
|
+
</slot>
|
|
113
91
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
92
|
+
<v-list-item-content>
|
|
93
|
+
<v-list-item-title
|
|
94
|
+
v-text="choice.text"
|
|
95
|
+
></v-list-item-title>
|
|
96
|
+
</v-list-item-content>
|
|
97
|
+
</v-list-item>
|
|
98
|
+
</v-list>
|
|
99
|
+
</slot>
|
|
100
|
+
</v-list-group>
|
|
121
101
|
</slot>
|
|
122
|
-
</
|
|
123
|
-
</
|
|
124
|
-
</
|
|
125
|
-
</v-
|
|
126
|
-
|
|
102
|
+
</div>
|
|
103
|
+
</v-list>
|
|
104
|
+
</v-menu>
|
|
105
|
+
</v-col>
|
|
106
|
+
<v-col v-if="activeFilters.length" cols="12" sm="9">
|
|
107
|
+
<v-slide-group v-bind="$attrs" show-arrows>
|
|
108
|
+
<v-chip
|
|
109
|
+
v-bind="$attrs"
|
|
110
|
+
class="ma-1"
|
|
111
|
+
close
|
|
112
|
+
label
|
|
113
|
+
@click:close="removeFilter(filter)"
|
|
114
|
+
v-for="(filter, i) in activeFilters"
|
|
115
|
+
:key="i"
|
|
116
|
+
>
|
|
117
|
+
<span>
|
|
118
|
+
<small>
|
|
119
|
+
<b>{{ filter.text.toUpperCase() }}: </b>
|
|
120
|
+
{{ formatActiveChoices(filter.active).toUpperCase() }}
|
|
121
|
+
</small>
|
|
122
|
+
</span>
|
|
123
|
+
</v-chip>
|
|
124
|
+
</v-slide-group>
|
|
125
|
+
</v-col>
|
|
126
|
+
</v-row>
|
|
127
127
|
</div>
|
|
128
128
|
</template>
|
|
129
129
|
|
|
130
130
|
<style lang="scss" scoped>
|
|
131
|
+
.main{
|
|
132
|
+
width: 100%;
|
|
133
|
+
}
|
|
131
134
|
.datapicker-clear-btn {
|
|
132
135
|
margin: -20px 15px 0 0 ;
|
|
133
136
|
}
|
|
@@ -159,9 +162,10 @@ export default {
|
|
|
159
162
|
methods: {
|
|
160
163
|
addDateFilter(filter) {
|
|
161
164
|
const { dates } = filter;
|
|
165
|
+
dates.sort((a,b) => Date.parse(a) - Date.parse(b));
|
|
162
166
|
if (dates && dates.length > 1) {
|
|
163
167
|
this.addFilter(filter, {
|
|
164
|
-
text: dates.join(" ~ "),
|
|
168
|
+
text: dates.map(date => new Date(date).toLocaleDateString()).join(" ~ "),
|
|
165
169
|
value: dates.join(","),
|
|
166
170
|
});
|
|
167
171
|
} else if (!dates || !dates.length) {
|
|
@@ -245,7 +249,6 @@ export default {
|
|
|
245
249
|
if (index !== -1) {
|
|
246
250
|
let filter = this.compFilters[index];
|
|
247
251
|
if (filter.datepicker) {
|
|
248
|
-
filter = { ...filter };
|
|
249
252
|
filter.dates = [...this.$route.query[k].split(",")];
|
|
250
253
|
this.addDateFilter(filter);
|
|
251
254
|
} else {
|
|
@@ -257,6 +260,17 @@ export default {
|
|
|
257
260
|
}
|
|
258
261
|
});
|
|
259
262
|
},
|
|
263
|
+
loadFilters() {
|
|
264
|
+
this.compFilters = this.filters.map(filter => {
|
|
265
|
+
if (filter.datepicker) {
|
|
266
|
+
return {
|
|
267
|
+
...filter,
|
|
268
|
+
dates: [],
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
return filter;
|
|
272
|
+
});
|
|
273
|
+
}
|
|
260
274
|
},
|
|
261
275
|
watch: {
|
|
262
276
|
activeFilters: {
|
|
@@ -268,8 +282,8 @@ export default {
|
|
|
268
282
|
}, 200),
|
|
269
283
|
},
|
|
270
284
|
},
|
|
271
|
-
|
|
272
|
-
this.
|
|
285
|
+
created() {
|
|
286
|
+
this.loadFilters();
|
|
273
287
|
this.restoreFromQparams();
|
|
274
288
|
},
|
|
275
289
|
};
|
|
@@ -278,7 +292,7 @@ export default {
|
|
|
278
292
|
<docs>
|
|
279
293
|
## Filter config
|
|
280
294
|
|
|
281
|
-
The filters prop is a list of `Filter` objects made of several keys:
|
|
295
|
+
The filters prop is a list of `Filter` objects made of several keys:
|
|
282
296
|
|
|
283
297
|
- **"text"** `String` ==> The name of the filter that will be renered inside the filter menu.
|
|
284
298
|
- **"value"** `String` ==> The dotted path of the value we need to filter on.
|
|
@@ -317,4 +331,4 @@ const filters = [
|
|
|
317
331
|
},
|
|
318
332
|
]
|
|
319
333
|
```
|
|
320
|
-
</docs>
|
|
334
|
+
</docs>
|