@mapomodule/uikit 1.0.0-alpha.4 → 1.0.0-alpha.40
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 +730 -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 +42 -28
- package/components/MediaManager/MediaBreadcrumbs.vue +45 -0
- package/components/MediaManager/MediaEditor.vue +282 -121
- 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 +111 -39
- 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 +134 -0
- package/translations/it-IT.js +136 -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,39 +1,64 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
3
|
<slot v-bind="{ on, attrs }" name="activator"></slot>
|
|
4
|
-
<v-dialog v-model="dialog"
|
|
4
|
+
<v-dialog v-model="dialog" v-bind="dialogProps">
|
|
5
5
|
<v-card v-bind="$attrs">
|
|
6
|
-
<v-card-title>
|
|
7
|
-
<
|
|
8
|
-
<
|
|
6
|
+
<v-card-title class="pa-0 mb-3">
|
|
7
|
+
<div style="max-width: calc(100% - 40px)">
|
|
8
|
+
<slot name="lang" v-bind="slotBindings">
|
|
9
|
+
<!-- [`DetailLangSwitch`](/components/detail/DetailLangSwitch/) -->
|
|
10
|
+
<DetailLangSwitch
|
|
11
|
+
v-if="langs.length > 1"
|
|
12
|
+
v-model="currentLang"
|
|
13
|
+
:langs="langs"
|
|
14
|
+
:errors="errors"
|
|
15
|
+
/></slot>
|
|
16
|
+
</div>
|
|
17
|
+
<v-spacer></v-spacer>
|
|
18
|
+
<slot name="title" v-bind="slotBindings">
|
|
19
|
+
<v-hover v-slot="{ hover }">
|
|
20
|
+
<v-icon @click="hover && close()" class="mr-4" :class="{'mt-4': !langs.length}">{{
|
|
21
|
+
hover ? "mdi-close" : isNew ? "mdi-plus-circle-outline" : "mdi-pencil-outline"
|
|
22
|
+
}}</v-icon>
|
|
23
|
+
</v-hover>
|
|
9
24
|
</slot>
|
|
10
25
|
</v-card-title>
|
|
11
|
-
<v-card-text>
|
|
26
|
+
<v-card-text class="pa-0 px-2">
|
|
12
27
|
<v-container>
|
|
13
|
-
<v-form v-if="
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
<v-form v-if="model" ref="form">
|
|
29
|
+
<!-- Use this to add content on top of body. -->
|
|
30
|
+
<slot name="body.top" v-bind="slotBindings"></slot>
|
|
31
|
+
|
|
32
|
+
<slot name="body" v-bind="slotBindings">
|
|
33
|
+
<Form
|
|
34
|
+
v-model="model"
|
|
35
|
+
:currentLang="currentLang"
|
|
36
|
+
:languages="langs"
|
|
37
|
+
:errors="errors"
|
|
38
|
+
:fields="editFields"
|
|
39
|
+
:modeSlotBindings="slotBindings"
|
|
40
|
+
>
|
|
41
|
+
<template v-for="(_, slot) in $slots" :slot="slot">
|
|
42
|
+
<!-- @vuese-ignore -->
|
|
43
|
+
<slot :name="slot"></slot>
|
|
44
|
+
</template>
|
|
45
|
+
<template v-for="(_, slot) in $scopedSlots" v-slot:[slot]="props">
|
|
46
|
+
<!-- @vuese-ignore -->
|
|
47
|
+
<slot :name="slot" v-bind="props" />
|
|
48
|
+
</template>
|
|
49
|
+
</Form>
|
|
28
50
|
</slot>
|
|
51
|
+
<!-- Use this to add content under the main body. -->
|
|
52
|
+
<slot name="body.bottom" v-bind="slotBindings"></slot>
|
|
29
53
|
</v-form>
|
|
30
54
|
</v-container>
|
|
31
55
|
</v-card-text>
|
|
32
56
|
<v-card-actions>
|
|
33
|
-
<
|
|
57
|
+
<v-messages v-if="nonFieldErrors.length" v-model="nonFieldErrors" color="error"></v-messages>
|
|
58
|
+
<slot name="actions" v-bind="slotBindings">
|
|
34
59
|
<v-spacer></v-spacer>
|
|
35
|
-
<v-btn text @click="close()">
|
|
36
|
-
<v-btn text @click="save">
|
|
60
|
+
<v-btn text @click="close()">{{ $t("mapo.cancel") }}</v-btn>
|
|
61
|
+
<v-btn text @click="save">{{ $t("mapo.save") }}</v-btn>
|
|
37
62
|
</slot>
|
|
38
63
|
</v-card-actions>
|
|
39
64
|
</v-card>
|
|
@@ -41,7 +66,7 @@
|
|
|
41
66
|
</div>
|
|
42
67
|
</template>
|
|
43
68
|
<script>
|
|
44
|
-
import {
|
|
69
|
+
import { diffObjs, deepClone } from "@mapomodule/utils/helpers/objHelpers";
|
|
45
70
|
/**
|
|
46
71
|
* This components renders a dialog that let the user quick edit (or add) an element of the list.
|
|
47
72
|
* The dialog provides several fields that will edit a payload that will be sent to the server. <br>
|
|
@@ -53,9 +78,11 @@ export default {
|
|
|
53
78
|
return {
|
|
54
79
|
dialog: false,
|
|
55
80
|
attrs: { ...this.$attrs },
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
81
|
+
modelBkp: null,
|
|
82
|
+
model: null,
|
|
83
|
+
isNew: false,
|
|
84
|
+
currentLang: null,
|
|
85
|
+
errors: null,
|
|
59
86
|
on: {
|
|
60
87
|
click: (event) => {
|
|
61
88
|
event.preventDefault();
|
|
@@ -70,14 +97,16 @@ export default {
|
|
|
70
97
|
value: {
|
|
71
98
|
type: Boolean,
|
|
72
99
|
},
|
|
73
|
-
|
|
74
|
-
type: String,
|
|
75
|
-
default: "",
|
|
76
|
-
},
|
|
100
|
+
// The main configuration that determines the arrangement of the fields in the detail layout.
|
|
77
101
|
editFields: {
|
|
78
102
|
type: Array,
|
|
79
103
|
default: () => [],
|
|
80
104
|
},
|
|
105
|
+
// A list of languages into which the payload needs to be translated.
|
|
106
|
+
languages: {
|
|
107
|
+
type: Array,
|
|
108
|
+
default() { return this.$mapo.$options?.content?.languages || []; },
|
|
109
|
+
},
|
|
81
110
|
lookup: {
|
|
82
111
|
type: String,
|
|
83
112
|
default: "id",
|
|
@@ -86,6 +115,12 @@ export default {
|
|
|
86
115
|
type: Object,
|
|
87
116
|
required: true,
|
|
88
117
|
},
|
|
118
|
+
dialogProps: {
|
|
119
|
+
type: Object,
|
|
120
|
+
required: false,
|
|
121
|
+
default: () => ({ width: 600, scrollable: true })
|
|
122
|
+
},
|
|
123
|
+
offline: Boolean,
|
|
89
124
|
},
|
|
90
125
|
watch: {
|
|
91
126
|
value(val) {
|
|
@@ -100,35 +135,34 @@ export default {
|
|
|
100
135
|
},
|
|
101
136
|
},
|
|
102
137
|
computed: {
|
|
103
|
-
|
|
104
|
-
return
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
return this.
|
|
108
|
-
if (typeof field == "object") {
|
|
109
|
-
return {
|
|
110
|
-
...field,
|
|
111
|
-
attrs: {
|
|
112
|
-
...field.attrs,
|
|
113
|
-
label: (field.attrs || {}).label || field.value.toUpperCase(),
|
|
114
|
-
},
|
|
115
|
-
};
|
|
116
|
-
} else if (typeof field == "string") {
|
|
117
|
-
return { attrs: { label: field.toUpperCase() }, value: field };
|
|
118
|
-
} else {
|
|
119
|
-
throw `editFields must me string or objects, error at index ${i}!`;
|
|
120
|
-
}
|
|
121
|
-
});
|
|
138
|
+
langs() {
|
|
139
|
+
return this.model?.lang_info?.site_languages.map((l) => l.id) || this.languages || [];
|
|
140
|
+
},
|
|
141
|
+
loading() {
|
|
142
|
+
return this.isNew ? false : !Object.keys(this.model || {}).length;
|
|
122
143
|
},
|
|
123
|
-
|
|
124
|
-
return this.
|
|
144
|
+
nonFieldErrors(){
|
|
145
|
+
return this.errors?.non_field_errors || []
|
|
146
|
+
},
|
|
147
|
+
slotBindings() {
|
|
148
|
+
return {
|
|
149
|
+
model: this.model,
|
|
150
|
+
currentLang: this.currentLang,
|
|
151
|
+
crud: this.crud,
|
|
152
|
+
isNew: this.isNew,
|
|
153
|
+
langs: this.langs,
|
|
154
|
+
loading: this.loading,
|
|
155
|
+
form: this.$refs.form,
|
|
156
|
+
save: this.save,
|
|
157
|
+
close: this.close,
|
|
158
|
+
};
|
|
125
159
|
},
|
|
126
160
|
},
|
|
127
161
|
methods: {
|
|
128
|
-
open(item) {
|
|
129
|
-
this.
|
|
130
|
-
this.
|
|
131
|
-
this.
|
|
162
|
+
async open(item) {
|
|
163
|
+
this.isNew = !item;
|
|
164
|
+
this.modelBkp = await this.fetchItem(item);
|
|
165
|
+
this.model = deepClone(this.modelBkp);
|
|
132
166
|
this.dialog = true;
|
|
133
167
|
this.$refs.form?.resetValidation();
|
|
134
168
|
return new Promise((resolve, reject) => {
|
|
@@ -138,21 +172,56 @@ export default {
|
|
|
138
172
|
},
|
|
139
173
|
async save() {
|
|
140
174
|
if (this.$refs.form?.validate()) {
|
|
141
|
-
return await (this.
|
|
175
|
+
return await (this.isNew ? this.apiCreate() : this.apiEdit());
|
|
142
176
|
}
|
|
143
177
|
},
|
|
144
178
|
close(res) {
|
|
179
|
+
this.errors = null;
|
|
180
|
+
this.currentLang = null;
|
|
145
181
|
this.$refs.form?.resetValidation();
|
|
146
182
|
this.resolve && this.resolve(res);
|
|
147
183
|
this.dialog = false;
|
|
148
184
|
},
|
|
185
|
+
async fetchItem(item) {
|
|
186
|
+
if (!this.offline && item && item[this.lookup]) {
|
|
187
|
+
return await this.crud.detail(item[this.lookup]);
|
|
188
|
+
} else {
|
|
189
|
+
return item;
|
|
190
|
+
}
|
|
191
|
+
},
|
|
149
192
|
apiEdit() {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
193
|
+
if (!this.offline) {
|
|
194
|
+
return this.crud
|
|
195
|
+
.partialUpdate(
|
|
196
|
+
this.modelBkp[this.lookup],
|
|
197
|
+
// diffObjs(this.modelBkp, this.model) disabled since it creates some errors in translations
|
|
198
|
+
this.model
|
|
199
|
+
)
|
|
200
|
+
.then((res) => this.close(res))
|
|
201
|
+
.catch(this.handleError);
|
|
202
|
+
} else {
|
|
203
|
+
this.close(this.model);
|
|
204
|
+
}
|
|
153
205
|
},
|
|
154
206
|
apiCreate() {
|
|
155
|
-
|
|
207
|
+
if (!this.offline) {
|
|
208
|
+
return this.crud
|
|
209
|
+
.create(this.model)
|
|
210
|
+
.then((res) => this.close(res))
|
|
211
|
+
.catch(this.handleError);
|
|
212
|
+
} else {
|
|
213
|
+
return this.close(this.model);
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
handleError(error) {
|
|
217
|
+
const badRequest = error.response.status == 400;
|
|
218
|
+
this.errors = (badRequest && error.response.data) || null;
|
|
219
|
+
this.$mapo.$snack.open({
|
|
220
|
+
message: badRequest
|
|
221
|
+
? this.$t("mapo.listQuickEdit.badInput")
|
|
222
|
+
: error.response?.data?.detail || this.$t("mapo.genericError"),
|
|
223
|
+
color: "error",
|
|
224
|
+
});
|
|
156
225
|
},
|
|
157
226
|
},
|
|
158
227
|
};
|