@mapomodule/uikit 1.0.0-alpha.2 → 1.0.0-alpha.20
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 +370 -0
- package/components/Detail/Detail.vue +281 -126
- package/components/Detail/DetailField.vue +68 -29
- package/components/Detail/DetailLangSwitch.vue +1 -1
- package/components/Detail/defaults.js +33 -25
- package/components/DropArea.vue +3 -3
- package/components/List/List.vue +120 -42
- package/components/List/ListActions.vue +56 -17
- package/components/List/ListFilters.vue +158 -113
- package/components/List/ListHead.vue +30 -12
- package/components/List/ListQuickEdit.vue +207 -55
- package/components/List/ListTable.vue +292 -77
- package/components/Login.vue +14 -5
- package/components/MediaManager/MediaEditor.vue +253 -107
- package/components/MediaManager/MediaFolders.vue +134 -43
- package/components/MediaManager/MediaGallery.vue +56 -52
- package/components/MediaManager/MediaManager.vue +127 -83
- package/components/MediaManager/MediaManagerDialog.vue +19 -22
- package/components/MediaManager/MediaPreview.vue +180 -0
- package/components/MediaManager/MediaUploader.vue +35 -32
- package/components/SnackBar.vue +3 -4
- package/components/ThemeToggle.vue +13 -0
- package/components/fields/DateField.vue +9 -3
- package/components/fields/FileField.vue +125 -0
- package/components/fields/FksField.vue +88 -0
- package/components/fields/MediaField.vue +36 -6
- package/components/fields/MediaM2mField.vue +8 -3
- package/components/fields/Repeater.vue +338 -0
- package/components/fields/SeoPreview.vue +89 -0
- package/components/fields/{TinyMce → wygEditor}/defaults.js +7 -5
- package/components/fields/{TinyMce → wygEditor}/utils/events.js +0 -0
- package/components/fields/{TinyMce → wygEditor}/utils/mapomedia.plugin.js +7 -6
- package/components/fields/{TinyMce → wygEditor}/utils/script.injector.js +0 -0
- package/components/fields/wygEditor/wygEditor.vue +256 -0
- package/components/layout/Sidebar/Sidebar.vue +35 -32
- package/components/layout/Sidebar/SidebarFooter.vue +42 -46
- package/components/layout/Sidebar/SidebarList.vue +13 -14
- package/components/layout/Sidebar/SidebarListItem.vue +99 -38
- package/components/layout/Sidebar/SidebarProfile.vue +42 -0
- package/components/layout/Topbar/Topbar.vue +3 -35
- package/components/layout/routebuilder.js +3 -3
- package/defaults.js +2 -2
- package/layouts/default.vue +20 -18
- package/layouts/empty.vue +10 -0
- package/package.json +5 -4
- package/pages/index.vue +1 -2
- package/components/fields/M2mField.vue +0 -95
- package/components/fields/TinyMce/TinyMce.vue +0 -177
- package/layouts/error.vue +0 -45
|
@@ -1,36 +1,103 @@
|
|
|
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
|
-
|
|
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">
|
|
15
33
|
<v-row>
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
:
|
|
19
|
-
|
|
20
|
-
:
|
|
34
|
+
<div
|
|
35
|
+
class="col-12"
|
|
36
|
+
:class="field.class"
|
|
37
|
+
v-for="(field, index) in computedFields"
|
|
38
|
+
:key="index"
|
|
21
39
|
>
|
|
22
|
-
<v-
|
|
23
|
-
v-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
40
|
+
<v-card v-if="field.group" class="my-2">
|
|
41
|
+
<v-card-title>
|
|
42
|
+
<v-icon left> {{ field.group.icon }} </v-icon>
|
|
43
|
+
<span>{{ field.group.name }}</span>
|
|
44
|
+
</v-card-title>
|
|
45
|
+
<div class="container">
|
|
46
|
+
<div class="row">
|
|
47
|
+
<div
|
|
48
|
+
v-for="(fields, fieldsI) in field.fields"
|
|
49
|
+
:key="fieldsI"
|
|
50
|
+
class="col-12"
|
|
51
|
+
:class="fields.class"
|
|
52
|
+
>
|
|
53
|
+
<!-- This is a dynamic slot. You can use it to override a field component. For example use `qedit.fields.title` to override the component of the field with value `title`. -->
|
|
54
|
+
<slot
|
|
55
|
+
:name="fields.slotName"
|
|
56
|
+
v-bind="{
|
|
57
|
+
conf: fields,
|
|
58
|
+
...slotBindings,
|
|
59
|
+
}"
|
|
60
|
+
>
|
|
61
|
+
<!-- A [`DetailField`](/components/detail/DetailField/) configured by a [`FieldConfiguration`](#fieldconfiguration). -->
|
|
62
|
+
<DetailField
|
|
63
|
+
v-model="model"
|
|
64
|
+
:langs="langs"
|
|
65
|
+
:currentLang="currentLang"
|
|
66
|
+
:conf="fields"
|
|
67
|
+
:errors="errors"
|
|
68
|
+
/>
|
|
69
|
+
</slot>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
</v-card>
|
|
74
|
+
<slot
|
|
75
|
+
v-else
|
|
76
|
+
:name="field.slotName"
|
|
77
|
+
v-bind="{
|
|
78
|
+
conf: field,
|
|
79
|
+
...slotBindings,
|
|
80
|
+
}"
|
|
81
|
+
>
|
|
82
|
+
<DetailField
|
|
83
|
+
v-model="model"
|
|
84
|
+
:langs="langs"
|
|
85
|
+
:currentLang="currentLang"
|
|
86
|
+
:conf="field"
|
|
87
|
+
:errors="errors"
|
|
88
|
+
/>
|
|
89
|
+
</slot>
|
|
90
|
+
</div>
|
|
27
91
|
</v-row>
|
|
28
92
|
</slot>
|
|
93
|
+
<!-- Use this to add content under the main body. -->
|
|
94
|
+
<slot name="body.bottom" v-bind="slotBindings"></slot>
|
|
29
95
|
</v-form>
|
|
30
96
|
</v-container>
|
|
31
97
|
</v-card-text>
|
|
32
98
|
<v-card-actions>
|
|
33
|
-
<
|
|
99
|
+
<v-messages v-if="nonFieldErrors.length" v-model="nonFieldErrors" color="error"></v-messages>
|
|
100
|
+
<slot name="actions" v-bind="slotBindings">
|
|
34
101
|
<v-spacer></v-spacer>
|
|
35
102
|
<v-btn text @click="close()"> Cancel </v-btn>
|
|
36
103
|
<v-btn text @click="save"> Save </v-btn>
|
|
@@ -41,7 +108,7 @@
|
|
|
41
108
|
</div>
|
|
42
109
|
</template>
|
|
43
110
|
<script>
|
|
44
|
-
import {
|
|
111
|
+
import { diffObjs, deepClone } from "@mapomodule/utils/helpers/objHelpers";
|
|
45
112
|
/**
|
|
46
113
|
* This components renders a dialog that let the user quick edit (or add) an element of the list.
|
|
47
114
|
* The dialog provides several fields that will edit a payload that will be sent to the server. <br>
|
|
@@ -53,9 +120,11 @@ export default {
|
|
|
53
120
|
return {
|
|
54
121
|
dialog: false,
|
|
55
122
|
attrs: { ...this.$attrs },
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
123
|
+
modelBkp: null,
|
|
124
|
+
model: null,
|
|
125
|
+
isNew: false,
|
|
126
|
+
currentLang: null,
|
|
127
|
+
errors: null,
|
|
59
128
|
on: {
|
|
60
129
|
click: (event) => {
|
|
61
130
|
event.preventDefault();
|
|
@@ -70,14 +139,16 @@ export default {
|
|
|
70
139
|
value: {
|
|
71
140
|
type: Boolean,
|
|
72
141
|
},
|
|
73
|
-
|
|
74
|
-
type: String,
|
|
75
|
-
default: "",
|
|
76
|
-
},
|
|
142
|
+
// The main configuration that determines the arrangement of the fields in the detail layout.
|
|
77
143
|
editFields: {
|
|
78
144
|
type: Array,
|
|
79
145
|
default: () => [],
|
|
80
146
|
},
|
|
147
|
+
// A list of languages into which the payload needs to be translated.
|
|
148
|
+
languages: {
|
|
149
|
+
type: Array,
|
|
150
|
+
default: () => [],
|
|
151
|
+
},
|
|
81
152
|
lookup: {
|
|
82
153
|
type: String,
|
|
83
154
|
default: "id",
|
|
@@ -86,6 +157,12 @@ export default {
|
|
|
86
157
|
type: Object,
|
|
87
158
|
required: true,
|
|
88
159
|
},
|
|
160
|
+
dialogProps: {
|
|
161
|
+
type: Object,
|
|
162
|
+
required: false,
|
|
163
|
+
default: () => ({ width: 600, scrollable: true })
|
|
164
|
+
},
|
|
165
|
+
offline: Boolean,
|
|
89
166
|
},
|
|
90
167
|
watch: {
|
|
91
168
|
value(val) {
|
|
@@ -98,37 +175,43 @@ export default {
|
|
|
98
175
|
this.close();
|
|
99
176
|
}
|
|
100
177
|
},
|
|
178
|
+
currentLang() {
|
|
179
|
+
this.initLang();
|
|
180
|
+
},
|
|
101
181
|
},
|
|
102
182
|
computed: {
|
|
103
|
-
formTitle() {
|
|
104
|
-
return `${this.newItem ? "Quick add" : "Quick edit"} ${this.editTitle}`;
|
|
105
|
-
},
|
|
106
183
|
computedFields() {
|
|
107
|
-
return this.editFields
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return { attrs: { label: field.toUpperCase() }, value: field };
|
|
118
|
-
} else {
|
|
119
|
-
throw `editFields must me string or objects, error at index ${i}!`;
|
|
120
|
-
}
|
|
121
|
-
});
|
|
184
|
+
return this.mapConf(this.editFields || []);
|
|
185
|
+
},
|
|
186
|
+
langs() {
|
|
187
|
+
return this.model?.lang_info?.site_languages.map((l) => l.id) || this.languages || [];
|
|
188
|
+
},
|
|
189
|
+
loading() {
|
|
190
|
+
return this.isNew ? false : !Object.keys(this.model || {}).length;
|
|
191
|
+
},
|
|
192
|
+
nonFieldErrors(){
|
|
193
|
+
return this.errors?.non_field_errors || []
|
|
122
194
|
},
|
|
123
|
-
|
|
124
|
-
return
|
|
195
|
+
slotBindings() {
|
|
196
|
+
return {
|
|
197
|
+
model: this.model,
|
|
198
|
+
currentLang: this.currentLang,
|
|
199
|
+
crud: this.crud,
|
|
200
|
+
isNew: this.isNew,
|
|
201
|
+
langs: this.langs,
|
|
202
|
+
loading: this.loading,
|
|
203
|
+
form: this.$refs.form,
|
|
204
|
+
save: this.save,
|
|
205
|
+
close: this.close,
|
|
206
|
+
};
|
|
125
207
|
},
|
|
126
208
|
},
|
|
127
209
|
methods: {
|
|
128
|
-
open(item) {
|
|
129
|
-
this.
|
|
130
|
-
this.
|
|
131
|
-
this.
|
|
210
|
+
async open(item) {
|
|
211
|
+
this.isNew = !item;
|
|
212
|
+
this.modelBkp = await this.fetchItem(item);
|
|
213
|
+
this.model = deepClone(this.modelBkp);
|
|
214
|
+
this.initLang();
|
|
132
215
|
this.dialog = true;
|
|
133
216
|
this.$refs.form?.resetValidation();
|
|
134
217
|
return new Promise((resolve, reject) => {
|
|
@@ -138,21 +221,90 @@ export default {
|
|
|
138
221
|
},
|
|
139
222
|
async save() {
|
|
140
223
|
if (this.$refs.form?.validate()) {
|
|
141
|
-
return await (this.
|
|
224
|
+
return await (this.isNew ? this.apiCreate() : this.apiEdit());
|
|
142
225
|
}
|
|
143
226
|
},
|
|
144
227
|
close(res) {
|
|
228
|
+
this.errors = null;
|
|
229
|
+
this.currentLang = null;
|
|
145
230
|
this.$refs.form?.resetValidation();
|
|
146
231
|
this.resolve && this.resolve(res);
|
|
147
232
|
this.dialog = false;
|
|
148
233
|
},
|
|
234
|
+
parseConf(field, i) {
|
|
235
|
+
const conf = typeof field === "string" ? { value: field } : field;
|
|
236
|
+
conf.value = conf.value || "";
|
|
237
|
+
conf.value = conf.value.replace(
|
|
238
|
+
new RegExp(`^translations\.(${this.langs.join("|")})\.?`),
|
|
239
|
+
""
|
|
240
|
+
);
|
|
241
|
+
conf.slotName = `fields.${conf.value || i}`;
|
|
242
|
+
if (this.currentLang && !field.synci18n) {
|
|
243
|
+
const base = `translations.${this.currentLang}`;
|
|
244
|
+
conf.value = (conf.value && `${base}.${conf.value}`) || base;
|
|
245
|
+
}
|
|
246
|
+
return conf;
|
|
247
|
+
},
|
|
248
|
+
mapConf(fields) {
|
|
249
|
+
const icon = "mdi-cube-outline";
|
|
250
|
+
const parseGroup = (group) =>
|
|
251
|
+
typeof group === "string"
|
|
252
|
+
? { name: group, icon }
|
|
253
|
+
: { ...group, icon: group.icon !== undefined ? group.icon : icon };
|
|
254
|
+
return fields.map((f, i) =>
|
|
255
|
+
f.group
|
|
256
|
+
? { group: parseGroup(f.group), fields: this.mapConf(f.fields) }
|
|
257
|
+
: this.parseConf(f, i)
|
|
258
|
+
);
|
|
259
|
+
},
|
|
260
|
+
initLang(lang = this.currentLang) {
|
|
261
|
+
if (lang && !this.model.translations) {
|
|
262
|
+
this.model.translations = {};
|
|
263
|
+
}
|
|
264
|
+
if (lang && !this.model.translations[lang]) {
|
|
265
|
+
this.model.translations[lang] = {};
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
async fetchItem(item) {
|
|
269
|
+
if (!this.offline && item && item[this.lookup]) {
|
|
270
|
+
return await this.crud.detail(item[this.lookup]);
|
|
271
|
+
} else {
|
|
272
|
+
return item;
|
|
273
|
+
}
|
|
274
|
+
},
|
|
149
275
|
apiEdit() {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
276
|
+
if (!this.offline) {
|
|
277
|
+
return this.crud
|
|
278
|
+
.partialUpdate(
|
|
279
|
+
this.modelBkp[this.lookup],
|
|
280
|
+
// diffObjs(this.modelBkp, this.model) disabled since it creates some errors in translations
|
|
281
|
+
this.model
|
|
282
|
+
)
|
|
283
|
+
.then((res) => this.close(res))
|
|
284
|
+
.catch(this.handleError);
|
|
285
|
+
} else {
|
|
286
|
+
this.close(this.model);
|
|
287
|
+
}
|
|
153
288
|
},
|
|
154
289
|
apiCreate() {
|
|
155
|
-
|
|
290
|
+
if (!this.offline) {
|
|
291
|
+
return this.crud
|
|
292
|
+
.create(this.model)
|
|
293
|
+
.then((res) => this.close(res))
|
|
294
|
+
.catch(this.handleError);
|
|
295
|
+
} else {
|
|
296
|
+
return this.close(this.model);
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
handleError(error) {
|
|
300
|
+
const badRequest = error.response.status == 400;
|
|
301
|
+
this.errors = (badRequest && error.response.data) || null;
|
|
302
|
+
this.$mapo.$snack.open({
|
|
303
|
+
message: badRequest
|
|
304
|
+
? "Bad input, correct wrong fields."
|
|
305
|
+
: error.response?.data?.detail || "Something whent bad, please try again later...",
|
|
306
|
+
color: "error",
|
|
307
|
+
});
|
|
156
308
|
},
|
|
157
309
|
},
|
|
158
310
|
};
|