@mapomodule/uikit 1.0.0-alpha.4 → 1.0.0-alpha.41
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 +749 -0
- package/components/ConfirmDialog.vue +12 -16
- package/components/Detail/Detail.vue +406 -272
- package/components/Detail/DetailLangSwitch.vue +7 -2
- package/components/DropArea.vue +63 -56
- package/components/Form/Form.vue +218 -0
- package/components/Form/FormField.vue +213 -0
- package/components/Form/FormGroup.vue +146 -0
- package/components/Form/FormTabs.vue +188 -0
- package/components/Form/defaults.js +91 -0
- package/components/Form/fields/ColorField.vue +79 -0
- package/components/{fields → Form/fields}/DateField.vue +20 -11
- package/components/Form/fields/EnhancedMediaField.vue +224 -0
- package/components/Form/fields/FileField.vue +125 -0
- package/components/Form/fields/FksField.vue +88 -0
- package/components/Form/fields/MediaField.vue +159 -0
- package/components/Form/fields/MediaM2mField.vue +149 -0
- package/components/Form/fields/Repeater.vue +593 -0
- package/components/Form/fields/SeoPreview.vue +89 -0
- package/components/Form/fields/wygEditor/defaults.js +25 -0
- package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/events.js +0 -0
- package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/mapomedia.plugin.js +7 -6
- package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/script.injector.js +0 -0
- package/components/Form/fields/wygEditor/wygEditor.vue +285 -0
- package/components/LangSwitcher.vue +44 -0
- package/components/List/List.vue +119 -42
- package/components/List/ListActions.vue +60 -21
- package/components/List/ListFilters.vue +166 -114
- package/components/List/ListHead.vue +30 -12
- package/components/List/ListQuickEdit.vue +130 -61
- package/components/List/ListTable.vue +292 -80
- package/components/Login.vue +17 -7
- package/components/LogoutButton.vue +43 -28
- package/components/MediaManager/MediaBreadcrumbs.vue +45 -0
- package/components/MediaManager/MediaEditor.vue +330 -122
- package/components/MediaManager/MediaFolders.vue +169 -116
- package/components/MediaManager/MediaGallery.vue +151 -146
- package/components/MediaManager/MediaManager.vue +117 -159
- package/components/MediaManager/MediaManagerDialog.vue +36 -31
- package/components/MediaManager/MediaPreview.vue +203 -0
- package/components/MediaManager/MediaUploader.vue +55 -43
- package/components/SnackBar.vue +5 -7
- package/components/ThemeToggle.vue +13 -0
- package/components/layout/Sidebar/Sidebar.vue +61 -30
- package/components/layout/Sidebar/SidebarList.vue +19 -15
- package/components/layout/Sidebar/SidebarListItem.vue +122 -38
- package/components/layout/Sidebar/SidebarProfile.vue +42 -0
- package/components/layout/Sidebar/SidebarTitle.vue +45 -0
- package/components/layout/Topbar/Topbar.vue +11 -42
- package/components/layout/routebuilder.js +3 -3
- package/defaults/i18n.js +37 -0
- package/defaults/vuetify.js +34 -0
- package/layouts/default.vue +33 -18
- package/layouts/empty.vue +10 -0
- package/module.js +7 -5
- package/package.json +6 -4
- package/pages/index.vue +19 -18
- package/static/{favicon.ico → mapo/favicon.ico} +0 -0
- package/static/mapo/tinymce-skins/mapo-dark/content.inline.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-dark/content.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-dark/content.mobile.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-dark/skin.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-dark/skin.mobile.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-light/content.inline.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-light/content.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-light/content.mobile.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-light/skin.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-light/skin.mobile.min.css +7 -0
- package/translations/en-US.js +135 -0
- package/translations/it-IT.js +137 -0
- package/components/Detail/DetailField.vue +0 -129
- package/components/Detail/defaults.js +0 -50
- package/components/fields/M2mField.vue +0 -95
- package/components/fields/MediaField.vue +0 -195
- package/components/fields/MediaM2mField.vue +0 -238
- package/components/fields/TinyMce/TinyMce.vue +0 -177
- package/components/fields/TinyMce/defaults.js +0 -55
- package/components/layout/Sidebar/SidebarFooter.vue +0 -75
- package/defaults.js +0 -29
- package/layouts/error.vue +0 -45
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div v-if="isActive" class="d-flex flex-row align-center fill-height">
|
|
3
3
|
<v-select
|
|
4
|
-
label="
|
|
4
|
+
:label="$t('mapo.listActions.groupActions')"
|
|
5
5
|
v-bind="$attrs"
|
|
6
6
|
v-model="action"
|
|
7
|
-
:items="
|
|
7
|
+
:items="filteredActions"
|
|
8
|
+
:item-disabled="isDisabled"
|
|
8
9
|
item-text="label"
|
|
9
10
|
item-value="handler"
|
|
10
11
|
outlined
|
|
11
12
|
dense
|
|
12
13
|
hide-details
|
|
13
14
|
clearable
|
|
15
|
+
no-data-text="No actions available"
|
|
16
|
+
class="rounded-0"
|
|
14
17
|
></v-select>
|
|
15
18
|
<v-btn
|
|
16
19
|
class="rounded-0 elevation-0 ml-2"
|
|
@@ -18,7 +21,7 @@
|
|
|
18
21
|
color="primary"
|
|
19
22
|
:disabled="!action"
|
|
20
23
|
@click="handleAction"
|
|
21
|
-
>
|
|
24
|
+
>{{ $t("mapo.apply") }}</v-btn
|
|
22
25
|
>
|
|
23
26
|
</div>
|
|
24
27
|
</template>
|
|
@@ -48,45 +51,76 @@ export default {
|
|
|
48
51
|
default() {
|
|
49
52
|
return [
|
|
50
53
|
{
|
|
51
|
-
label: "
|
|
54
|
+
label: this.$t("mapo.listActions.permanentDelete"),
|
|
52
55
|
handler: function ({ selection, lookup, crud }) {
|
|
53
|
-
return Promise.all(
|
|
54
|
-
selection.map((i) => crud.delete(i[lookup]))
|
|
55
|
-
);
|
|
56
|
+
return Promise.all(selection.map((i) => crud && crud.delete(i[lookup])));
|
|
56
57
|
},
|
|
58
|
+
permissions: "delete"
|
|
57
59
|
},
|
|
58
60
|
];
|
|
59
61
|
},
|
|
60
62
|
},
|
|
61
63
|
// ❌ This is an internal prop. Sorry..
|
|
62
64
|
selection: {
|
|
63
|
-
// -
|
|
64
|
-
type: Array,
|
|
65
|
-
// -
|
|
65
|
+
// -
|
|
66
|
+
type: [Array, String],
|
|
67
|
+
// -
|
|
66
68
|
default: () => [],
|
|
67
69
|
},
|
|
68
70
|
// ❌ This is an internal prop. Sorry..
|
|
71
|
+
selectionQuery: {
|
|
72
|
+
// -
|
|
73
|
+
type: URLSearchParams,
|
|
74
|
+
// -
|
|
75
|
+
default: () => new URLSearchParams(),
|
|
76
|
+
},
|
|
77
|
+
// ❌ This is an internal prop. Sorry..
|
|
69
78
|
crud: {
|
|
70
|
-
// -
|
|
79
|
+
// -
|
|
71
80
|
type: Object,
|
|
72
81
|
required: true,
|
|
73
82
|
},
|
|
74
83
|
},
|
|
75
|
-
computed:{
|
|
76
|
-
isActive(){
|
|
77
|
-
return this.$attrs[
|
|
84
|
+
computed: {
|
|
85
|
+
isActive() {
|
|
86
|
+
return this.$attrs["show-select"] !== undefined;
|
|
87
|
+
},
|
|
88
|
+
filteredActions() {
|
|
89
|
+
return this.actions.filter((action) => {
|
|
90
|
+
return (this.selection != "all" && (action.handleMultiple ?? true)) || (this.selection == "all" && (action.handleAll ?? false));
|
|
91
|
+
});
|
|
78
92
|
}
|
|
79
93
|
},
|
|
80
94
|
methods: {
|
|
95
|
+
isDisabled(action){
|
|
96
|
+
const p = typeof action.permissions == "string" ? [action.permissions] : action.permissions || []
|
|
97
|
+
if (p.length){
|
|
98
|
+
return !p.every(a => this.userCan(a))
|
|
99
|
+
}
|
|
100
|
+
return false
|
|
101
|
+
},
|
|
102
|
+
userCan(action) {
|
|
103
|
+
if (this.$mapo.$auth.routeMiddlewares.includes("permissions")){
|
|
104
|
+
return this.$mapo.$auth.user.permissions.includes(action)
|
|
105
|
+
}
|
|
106
|
+
return true
|
|
107
|
+
},
|
|
81
108
|
handleAction() {
|
|
82
|
-
if (!this.selection.length) {
|
|
109
|
+
if (!this.selectAll && !this.selection.length) {
|
|
83
110
|
return this.$mapo.$snack.open({
|
|
84
|
-
message: "
|
|
111
|
+
message: this.$t("mapo.listActions.selectionRequired"),
|
|
85
112
|
color: "error",
|
|
86
113
|
});
|
|
87
114
|
}
|
|
88
|
-
const ctx = {
|
|
89
|
-
|
|
115
|
+
const ctx = {
|
|
116
|
+
selection: this.selection,
|
|
117
|
+
selectionQuery: this.selectionQuery,
|
|
118
|
+
lookup: this.lookup,
|
|
119
|
+
crud: this.crud,
|
|
120
|
+
};
|
|
121
|
+
return this.action
|
|
122
|
+
? this.action(ctx).then((res) => this.$emit("actionCompleted", res))
|
|
123
|
+
: () => {};
|
|
90
124
|
},
|
|
91
125
|
},
|
|
92
126
|
};
|
|
@@ -96,13 +130,17 @@ export default {
|
|
|
96
130
|
## Action config
|
|
97
131
|
|
|
98
132
|
|
|
99
|
-
The actions prop is a list of `Action` objects
|
|
133
|
+
The actions prop is a list of `Action` objects containing these keys:
|
|
100
134
|
|
|
101
135
|
- **"label"** `String` ==> The name of the action that will be renered inside the select button.
|
|
136
|
+
- **"handleMultiple"** `Boolean` ==> Make the action callable on multiple items. Default: `true`.
|
|
137
|
+
- **"handleAll"** `Boolean` ==> Make the action callable on all items. Default: `false`.
|
|
102
138
|
- **"handler"** `Function` ==> The callback function that will be executed once the user confirms the action.
|
|
139
|
+
- **"permissions"** `String | Array` ==> The list of permissions needed by the user to perform action in a page with permission middleware
|
|
103
140
|
|
|
104
141
|
The handler function will be called with a ctx containing:
|
|
105
|
-
- **"selection"** `Array<Object
|
|
142
|
+
- **"selection"** `Array<Object>` or `String` ==> `"all"` if all items are selected else the list of selected objects.
|
|
143
|
+
- **"selectionQuery"** `URLSearchParams` ==> GET parameters for the current list of objects.
|
|
106
144
|
- **"lookup"** `String` ==> The lookup prop.
|
|
107
145
|
- **"crud"** [`Crud`](/core/#api.crud) ==> The inherited crud from [List](../List/) component.
|
|
108
146
|
|
|
@@ -119,7 +157,8 @@ const actions = [
|
|
|
119
157
|
selection.map((i) => crud.delete(i[lookup]))
|
|
120
158
|
);
|
|
121
159
|
},
|
|
160
|
+
permissions: "delete"
|
|
122
161
|
}
|
|
123
162
|
]
|
|
124
163
|
```
|
|
125
|
-
</docs>
|
|
164
|
+
</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
|
-
filter <v-icon>mdi-filter-variant</v-icon>
|
|
8
|
+
{{ $t("mapo.listFilters.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
|
+
>{{ $t("mapo.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
|
}
|
|
@@ -155,13 +158,20 @@ export default {
|
|
|
155
158
|
type: Array,
|
|
156
159
|
default: () => [],
|
|
157
160
|
},
|
|
161
|
+
// This is the v-model of the component. It contains the active filters.
|
|
162
|
+
value: {
|
|
163
|
+
// [`Array<Filter>`](#filter-config)
|
|
164
|
+
type: Array,
|
|
165
|
+
default: () => [],
|
|
166
|
+
},
|
|
158
167
|
},
|
|
159
168
|
methods: {
|
|
160
169
|
addDateFilter(filter) {
|
|
161
170
|
const { dates } = filter;
|
|
171
|
+
dates.sort((a,b) => Date.parse(a) - Date.parse(b));
|
|
162
172
|
if (dates && dates.length > 1) {
|
|
163
173
|
this.addFilter(filter, {
|
|
164
|
-
text: dates.join(" ~ "),
|
|
174
|
+
text: dates.map(date => new Date(date).toLocaleDateString()).join(" ~ "),
|
|
165
175
|
value: dates.join(","),
|
|
166
176
|
});
|
|
167
177
|
} else if (!dates || !dates.length) {
|
|
@@ -245,7 +255,6 @@ export default {
|
|
|
245
255
|
if (index !== -1) {
|
|
246
256
|
let filter = this.compFilters[index];
|
|
247
257
|
if (filter.datepicker) {
|
|
248
|
-
filter = { ...filter };
|
|
249
258
|
filter.dates = [...this.$route.query[k].split(",")];
|
|
250
259
|
this.addDateFilter(filter);
|
|
251
260
|
} else {
|
|
@@ -257,6 +266,32 @@ export default {
|
|
|
257
266
|
}
|
|
258
267
|
});
|
|
259
268
|
},
|
|
269
|
+
loadFilters() {
|
|
270
|
+
this.compFilters = this.filters.map(filter => ({...filter, dates: filter.datepicker ? [] : undefined}));
|
|
271
|
+
this.applyDefaultChoices()
|
|
272
|
+
},
|
|
273
|
+
applyDefaultChoices(){
|
|
274
|
+
this.compFilters.forEach(filter=>{
|
|
275
|
+
if (filter.defaultChoice){
|
|
276
|
+
if (filter.datepicker) {
|
|
277
|
+
filter.dates = [...filter.defaultChoice.split(",")];
|
|
278
|
+
this.addDateFilter(filter);
|
|
279
|
+
} else {
|
|
280
|
+
filter.choices.forEach((c) => {
|
|
281
|
+
filter.defaultChoice.split(",").includes(c.value + "") &&
|
|
282
|
+
this.addFilter(filter, c);
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
})
|
|
287
|
+
},
|
|
288
|
+
cleanActiveFilters(){
|
|
289
|
+
this.compFilters.forEach(filter => {
|
|
290
|
+
if (!this.activeFilters.find((f) => f.value == filter.value)) {
|
|
291
|
+
this.removeFilter(filter)
|
|
292
|
+
}
|
|
293
|
+
})
|
|
294
|
+
}
|
|
260
295
|
},
|
|
261
296
|
watch: {
|
|
262
297
|
activeFilters: {
|
|
@@ -267,9 +302,25 @@ export default {
|
|
|
267
302
|
this.setQparams(val);
|
|
268
303
|
}, 200),
|
|
269
304
|
},
|
|
305
|
+
value: {
|
|
306
|
+
deep: true,
|
|
307
|
+
handler(val){
|
|
308
|
+
if (JSON.stringify(val) !== JSON.stringify(this.activeFilters)){
|
|
309
|
+
this.activeFilters = val
|
|
310
|
+
this.cleanActiveFilters()
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
filters: {
|
|
315
|
+
deep: true,
|
|
316
|
+
handler(val) {
|
|
317
|
+
this.loadFilters();
|
|
318
|
+
this.restoreFromQparams();
|
|
319
|
+
}
|
|
320
|
+
}
|
|
270
321
|
},
|
|
271
|
-
|
|
272
|
-
this.
|
|
322
|
+
created() {
|
|
323
|
+
this.loadFilters();
|
|
273
324
|
this.restoreFromQparams();
|
|
274
325
|
},
|
|
275
326
|
};
|
|
@@ -278,10 +329,11 @@ export default {
|
|
|
278
329
|
<docs>
|
|
279
330
|
## Filter config
|
|
280
331
|
|
|
281
|
-
The filters prop is a list of `Filter` objects made of several keys:
|
|
332
|
+
The filters prop is a list of `Filter` objects made of several keys:
|
|
282
333
|
|
|
283
334
|
- **"text"** `String` ==> The name of the filter that will be renered inside the filter menu.
|
|
284
335
|
- **"value"** `String` ==> The dotted path of the value we need to filter on.
|
|
336
|
+
- **"defaultChoice"** `String` ==> A choice value that is applied on the startup of the component. This lets you start the list with some filter already applied.
|
|
285
337
|
- **"choices"** `Array<Choice>` ==> The list of choices rendered inside the filter. The text is the label, the value is the string we use as a filter.
|
|
286
338
|
- **"datepicker"** `Boolean` ==> This is a boolean that determines if the filter has a datepicker layout.
|
|
287
339
|
- **"multiple"** `Boolean` ==> This is a boolean that determines if the filter is exclusive or inclusive. In other words, if by selecting a choice it is added to the previous one or if it replaces it.
|
|
@@ -317,4 +369,4 @@ const filters = [
|
|
|
317
369
|
},
|
|
318
370
|
]
|
|
319
371
|
```
|
|
320
|
-
</docs>
|
|
372
|
+
</docs>
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="list__head">
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
v-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
<h1 class="list__head__title display-1">{{ title }}</h1>
|
|
4
|
+
<div class="list__head__button">
|
|
5
|
+
<v-btn
|
|
6
|
+
v-if="addItem && canAdd"
|
|
7
|
+
class="rounded-0 elevation-0"
|
|
8
|
+
color="primary"
|
|
9
|
+
:to="{ path: `${$route.path}/new` }"
|
|
10
|
+
>{{ $t("mapo.listHead.addNew") }}   <v-icon>mdi-plus</v-icon></v-btn
|
|
11
|
+
>
|
|
12
|
+
</div>
|
|
11
13
|
</div>
|
|
12
14
|
</template>
|
|
13
15
|
|
|
@@ -18,10 +20,18 @@
|
|
|
18
20
|
&__head {
|
|
19
21
|
display: flex;
|
|
20
22
|
align-items: center;
|
|
21
|
-
justify-content:
|
|
22
|
-
|
|
23
|
+
justify-content: space-between;
|
|
24
|
+
flex-wrap: wrap;
|
|
25
|
+
margin-bottom: 2rem;
|
|
23
26
|
&__title {
|
|
24
27
|
margin-right: 2rem;
|
|
28
|
+
margin-bottom: 1rem;
|
|
29
|
+
}
|
|
30
|
+
&__button {
|
|
31
|
+
display: flex;
|
|
32
|
+
flex: 1;
|
|
33
|
+
justify-content: flex-end;
|
|
34
|
+
margin-bottom: 1rem;
|
|
25
35
|
}
|
|
26
36
|
}
|
|
27
37
|
}
|
|
@@ -40,10 +50,18 @@ export default {
|
|
|
40
50
|
// The route name.
|
|
41
51
|
default() {
|
|
42
52
|
return this.$route.name;
|
|
43
|
-
}
|
|
53
|
+
}
|
|
44
54
|
},
|
|
45
55
|
// This is a boolean that determines the visibility of "new item" button. If set to true will provide the user a link to a detail page for new content creation.
|
|
46
|
-
addItem: Boolean
|
|
56
|
+
addItem: Boolean
|
|
47
57
|
},
|
|
58
|
+
computed: {
|
|
59
|
+
canAdd() {
|
|
60
|
+
if (this.$mapo.$auth.routeMiddlewares.includes("permissions")){
|
|
61
|
+
return this.$mapo.$auth.user.permissions.includes("add")
|
|
62
|
+
}
|
|
63
|
+
return true
|
|
64
|
+
},
|
|
65
|
+
}
|
|
48
66
|
};
|
|
49
67
|
</script>
|