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