@mapomodule/uikit 1.0.0-alpha.1 → 1.0.0-alpha.10
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 +193 -0
- package/LICENSE.md +20 -0
- package/components/Detail/Detail.vue +193 -107
- package/components/Detail/DetailField.vue +42 -29
- 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/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 +1 -1
- package/components/fields/{TinyMce → wygEditor}/utils/events.js +0 -0
- package/components/fields/{TinyMce → wygEditor}/utils/mapomedia.plugin.js +0 -0
- package/components/fields/{TinyMce → wygEditor}/utils/script.injector.js +0 -0
- package/components/fields/{TinyMce/TinyMce.vue → wygEditor/wygEditor.vue} +40 -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/layouts/default.vue +3 -14
- package/package.json +3 -3
- package/pages/index.vue +15 -78
- package/components/fields/M2mField.vue +0 -95
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<div>
|
|
3
3
|
<!-- Use this to override the title of the detail component. -->
|
|
4
4
|
<slot name="title" v-bind="slotBindings">
|
|
5
5
|
<!-- `<h1> "Create | Edit" + modelName </h1>` -->
|
|
6
|
-
<v-row class="mb-
|
|
7
|
-
<h1>{{ isNew ? "Create" : "Edit" }} {{ modelName }}</h1>
|
|
6
|
+
<v-row class="mb-5">
|
|
7
|
+
<v-col col="12"><h1 class="display-1">{{ isNew ? "Create" : "Edit" }} {{ modelName }}</h1></v-col>
|
|
8
8
|
</v-row>
|
|
9
9
|
</slot>
|
|
10
10
|
<v-form ref="form">
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
<slot name="body.lang" v-bind="slotBindings">
|
|
17
17
|
<!-- [`DetailLangSwitch`](/components/detail/DetailLangSwitch/) -->
|
|
18
18
|
<DetailLangSwitch
|
|
19
|
-
v-if="langs && langs.length"
|
|
19
|
+
v-if="langs && langs.length > 1"
|
|
20
20
|
class="mb-4"
|
|
21
21
|
v-model="currentLang"
|
|
22
22
|
:langs="langs"
|
|
@@ -26,47 +26,57 @@
|
|
|
26
26
|
<slot name="body.top.underlang" v-bind="slotBindings"></slot>
|
|
27
27
|
<!-- Use this to override the content of the main body. -->
|
|
28
28
|
<slot name="body" v-bind="slotBindings">
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
<v-card-text>
|
|
37
|
-
<div
|
|
38
|
-
v-for="(fields, fieldsI) in field.fields"
|
|
39
|
-
:key="fieldsI"
|
|
40
|
-
class="mb-4"
|
|
41
|
-
>
|
|
42
|
-
<!-- This is a dynamic slot. You can use it to override a field component. For example use `fields.title` to override the component of the field with value `title`. -->
|
|
43
|
-
<slot
|
|
44
|
-
:name="fields.slotName"
|
|
45
|
-
v-bind="{
|
|
46
|
-
conf: fields,
|
|
47
|
-
...slotBindings,
|
|
48
|
-
}"
|
|
49
|
-
>
|
|
50
|
-
<!-- A [`DetailField`](/components/detail/DetailField/) configured by a [`FieldConfiguration`](#fieldconfiguration). -->
|
|
51
|
-
<DetailField
|
|
52
|
-
v-model="model"
|
|
53
|
-
:conf="fields"
|
|
54
|
-
:errors="errors"
|
|
55
|
-
/>
|
|
56
|
-
</slot>
|
|
57
|
-
</div>
|
|
58
|
-
</v-card-text>
|
|
59
|
-
</v-card>
|
|
60
|
-
<slot
|
|
61
|
-
v-else
|
|
62
|
-
:name="field.slotName"
|
|
63
|
-
v-bind="{
|
|
64
|
-
conf: field,
|
|
65
|
-
...slotBindings,
|
|
66
|
-
}"
|
|
29
|
+
<div class="row">
|
|
30
|
+
<!-- The result of the [`DetailConfiguration`](#detailconfiguration) contained in the main body. -->
|
|
31
|
+
<div
|
|
32
|
+
class="col-12"
|
|
33
|
+
:class="field.class"
|
|
34
|
+
v-for="(field, index) in mainFields"
|
|
35
|
+
:key="index"
|
|
67
36
|
>
|
|
68
|
-
<
|
|
69
|
-
|
|
37
|
+
<v-card v-if="field.group" class="my-2 rounded-0">
|
|
38
|
+
<v-card-title>
|
|
39
|
+
<v-icon left> {{ field.group.icon }} </v-icon>
|
|
40
|
+
<span>{{ field.group.name }}</span>
|
|
41
|
+
</v-card-title>
|
|
42
|
+
<div class="container">
|
|
43
|
+
<div class="row">
|
|
44
|
+
<div
|
|
45
|
+
v-for="(fields, fieldsI) in field.fields"
|
|
46
|
+
:key="fieldsI"
|
|
47
|
+
class="col-12"
|
|
48
|
+
:class="fields.class"
|
|
49
|
+
>
|
|
50
|
+
<!-- This is a dynamic slot. You can use it to override a field component. For example use `fields.title` to override the component of the field with value `title`. -->
|
|
51
|
+
<slot
|
|
52
|
+
:name="fields.slotName"
|
|
53
|
+
v-bind="{
|
|
54
|
+
conf: fields,
|
|
55
|
+
...slotBindings,
|
|
56
|
+
}"
|
|
57
|
+
>
|
|
58
|
+
<!-- A [`DetailField`](/components/detail/DetailField/) configured by a [`FieldConfiguration`](#fieldconfiguration). -->
|
|
59
|
+
<DetailField
|
|
60
|
+
v-model="model"
|
|
61
|
+
:conf="fields"
|
|
62
|
+
:errors="errors"
|
|
63
|
+
/>
|
|
64
|
+
</slot>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
</v-card>
|
|
69
|
+
<slot
|
|
70
|
+
v-else
|
|
71
|
+
:name="field.slotName"
|
|
72
|
+
v-bind="{
|
|
73
|
+
conf: field,
|
|
74
|
+
...slotBindings,
|
|
75
|
+
}"
|
|
76
|
+
>
|
|
77
|
+
<DetailField v-model="model" :conf="field" :errors="errors" />
|
|
78
|
+
</slot>
|
|
79
|
+
</div>
|
|
70
80
|
</div>
|
|
71
81
|
</slot>
|
|
72
82
|
<!-- Use this to add content under the main body. -->
|
|
@@ -83,14 +93,14 @@
|
|
|
83
93
|
<!-- Use this to override the Save button. -->
|
|
84
94
|
<slot name="button.save" v-bind="slotBindings">
|
|
85
95
|
<!-- The Save button. -->
|
|
86
|
-
<v-btn class="mb-2" tile block @click="saveItem(true)">{{
|
|
96
|
+
<v-btn :disabled="isReadonly" class="mb-2" tile block @click="saveItem(true)">{{
|
|
87
97
|
isNew ? "Create" : "Save"
|
|
88
98
|
}}</v-btn>
|
|
89
99
|
</slot>
|
|
90
100
|
<!-- Use this to override the Save and continue button. -->
|
|
91
101
|
<slot name="button.savecontinue" v-bind="slotBindings">
|
|
92
102
|
<!-- The Save and continue button. -->
|
|
93
|
-
<v-btn class="mb-2" tile block @click="saveItem(false)"
|
|
103
|
+
<v-btn :disabled="isReadonly" class="mb-2" tile block @click="saveItem(false)"
|
|
94
104
|
>{{ isNew ? "Create" : "Save" }} and continue</v-btn
|
|
95
105
|
>
|
|
96
106
|
</slot>
|
|
@@ -110,6 +120,7 @@
|
|
|
110
120
|
color="error"
|
|
111
121
|
tile
|
|
112
122
|
block
|
|
123
|
+
:disabled="!canDelete"
|
|
113
124
|
@click="deleteItem"
|
|
114
125
|
>Delete</v-btn
|
|
115
126
|
>
|
|
@@ -118,45 +129,55 @@
|
|
|
118
129
|
</slot>
|
|
119
130
|
<!-- Use this to add content on the top of the sidebar fields (or under sidebar buttons). -->
|
|
120
131
|
<slot name="side.top" v-bind="slotBindings"></slot>
|
|
121
|
-
<div
|
|
122
|
-
<
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
<v-card-text>
|
|
128
|
-
<div
|
|
129
|
-
v-for="(fields, fieldsI) in field.fields"
|
|
130
|
-
:key="fieldsI"
|
|
131
|
-
class="mb-4"
|
|
132
|
-
>
|
|
133
|
-
<!-- @vuese-ignore -->
|
|
134
|
-
<slot
|
|
135
|
-
:name="fields.slotName"
|
|
136
|
-
v-bind="{
|
|
137
|
-
conf: fields,
|
|
138
|
-
...slotBindings,
|
|
139
|
-
}"
|
|
140
|
-
>
|
|
141
|
-
<DetailField
|
|
142
|
-
v-model="model"
|
|
143
|
-
:conf="fields"
|
|
144
|
-
:errors="errors"
|
|
145
|
-
/>
|
|
146
|
-
</slot>
|
|
147
|
-
</div>
|
|
148
|
-
</v-card-text>
|
|
149
|
-
</v-card>
|
|
150
|
-
<slot
|
|
151
|
-
v-else
|
|
152
|
-
:name="field.slotName"
|
|
153
|
-
v-bind="{
|
|
154
|
-
conf: field,
|
|
155
|
-
...slotBindings,
|
|
156
|
-
}"
|
|
132
|
+
<div class="row">
|
|
133
|
+
<div
|
|
134
|
+
class="col-12"
|
|
135
|
+
:class="field.class"
|
|
136
|
+
v-for="(field, index) in sideFields"
|
|
137
|
+
:key="index"
|
|
157
138
|
>
|
|
158
|
-
<
|
|
159
|
-
|
|
139
|
+
<v-card v-if="field.group" class="rounded-0 mb-4">
|
|
140
|
+
<v-card-title>
|
|
141
|
+
<v-icon left> {{ field.group.icon }} </v-icon>
|
|
142
|
+
<span>{{ field.group.name }}</span>
|
|
143
|
+
</v-card-title>
|
|
144
|
+
<div class="container">
|
|
145
|
+
<div class="row">
|
|
146
|
+
<div
|
|
147
|
+
v-for="(fields, fieldsI) in field.fields"
|
|
148
|
+
:key="fieldsI"
|
|
149
|
+
class="col-12"
|
|
150
|
+
:class="field.class"
|
|
151
|
+
>
|
|
152
|
+
<!-- @vuese-ignore -->
|
|
153
|
+
<slot
|
|
154
|
+
:name="fields.slotName"
|
|
155
|
+
v-bind="{
|
|
156
|
+
conf: fields,
|
|
157
|
+
...slotBindings,
|
|
158
|
+
}"
|
|
159
|
+
>
|
|
160
|
+
<DetailField
|
|
161
|
+
v-model="model"
|
|
162
|
+
:conf="fields"
|
|
163
|
+
:errors="errors"
|
|
164
|
+
/>
|
|
165
|
+
</slot>
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
</div>
|
|
169
|
+
</v-card>
|
|
170
|
+
<slot
|
|
171
|
+
v-else
|
|
172
|
+
:name="field.slotName"
|
|
173
|
+
v-bind="{
|
|
174
|
+
conf: field,
|
|
175
|
+
...slotBindings,
|
|
176
|
+
}"
|
|
177
|
+
>
|
|
178
|
+
<DetailField v-model="model" :conf="field" :errors="errors" />
|
|
179
|
+
</slot>
|
|
180
|
+
</div>
|
|
160
181
|
</div>
|
|
161
182
|
<!-- Use this to add content under the sidebar fields. -->
|
|
162
183
|
<slot name="side.bottom" v-bind="slotBindings"></slot>
|
|
@@ -164,7 +185,7 @@
|
|
|
164
185
|
</v-col>
|
|
165
186
|
</v-row>
|
|
166
187
|
</v-form>
|
|
167
|
-
</
|
|
188
|
+
</div>
|
|
168
189
|
</template>
|
|
169
190
|
|
|
170
191
|
|
|
@@ -183,6 +204,16 @@ export default {
|
|
|
183
204
|
};
|
|
184
205
|
},
|
|
185
206
|
props: {
|
|
207
|
+
// V-model of the object we are editing.
|
|
208
|
+
value: {
|
|
209
|
+
type: Object,
|
|
210
|
+
required: false
|
|
211
|
+
},
|
|
212
|
+
// Set the current lang to value.
|
|
213
|
+
lang: {
|
|
214
|
+
type: String,
|
|
215
|
+
required: false
|
|
216
|
+
},
|
|
186
217
|
// The main configuration that determines the arrangement of the fields in the detail layout.
|
|
187
218
|
fields: {
|
|
188
219
|
// [`DetailConfiguration`](#detailconfiguration)
|
|
@@ -195,7 +226,10 @@ export default {
|
|
|
195
226
|
default: () => []
|
|
196
227
|
},
|
|
197
228
|
// The url of the endpoint to which the payload is to be sent. From this url a complete crud (See [this.$mapo.$api.crud](/core/#$api.crud)) will be created.
|
|
198
|
-
endpoint:
|
|
229
|
+
endpoint: {
|
|
230
|
+
type: String,
|
|
231
|
+
default: null
|
|
232
|
+
},
|
|
199
233
|
// The identifier of the object you need to retrieve and edit. It can be "new" if you need to create a new payload.
|
|
200
234
|
identifier: {
|
|
201
235
|
// `String|Number`.
|
|
@@ -208,20 +242,29 @@ export default {
|
|
|
208
242
|
sticky: {
|
|
209
243
|
type: Boolean,
|
|
210
244
|
default: true
|
|
211
|
-
}
|
|
245
|
+
},
|
|
246
|
+
// Set the multipart politic. Accepts `'auto'|'force|'disable'`. If auto is set the request is transformed in multipart if any file is in the payload. If set to force the request is transformed in multipart no matter if files are found. If set to `'disable'` the request is never transformed in multipart.
|
|
247
|
+
multipart: {
|
|
248
|
+
type: String,
|
|
249
|
+
default: "auto",
|
|
250
|
+
validator: function (value) {
|
|
251
|
+
// The value must match one of these strings
|
|
252
|
+
return ["auto", "force", "disable"].indexOf(value) !== -1;
|
|
253
|
+
},
|
|
254
|
+
},
|
|
212
255
|
},
|
|
213
256
|
methods: {
|
|
214
257
|
saveItem(back = false) {
|
|
215
258
|
this.errors = null;
|
|
216
259
|
this.$refs.form?.resetValidation();
|
|
217
260
|
this.crud
|
|
218
|
-
.updateOrCreate(this.model)
|
|
261
|
+
.updateOrCreate(this.model, {}, { multipart: this.multipart })
|
|
219
262
|
.then(() => back && this.$router.back())
|
|
220
263
|
.catch(error => {
|
|
221
264
|
this.errors =
|
|
222
265
|
(error.response.status == 400 && error.response.data) || null;
|
|
223
266
|
this.$mapo.$snack.open({
|
|
224
|
-
message: "Something whent bad, please try again later...",
|
|
267
|
+
message: error.response?.data?.detail || "Something whent bad, please try again later...",
|
|
225
268
|
color: "error"
|
|
226
269
|
});
|
|
227
270
|
});
|
|
@@ -231,7 +274,7 @@ export default {
|
|
|
231
274
|
.open({
|
|
232
275
|
title: "Delete",
|
|
233
276
|
question: "Are you sure you want to delete this item?",
|
|
234
|
-
approveButton: { text: "Delete", attrs: { color: "red" } }
|
|
277
|
+
approveButton: { text: "Delete", attrs: { color: "red", text: true } }
|
|
235
278
|
})
|
|
236
279
|
.then(res => {
|
|
237
280
|
if (res) {
|
|
@@ -240,19 +283,32 @@ export default {
|
|
|
240
283
|
.then(() => this.$router.back())
|
|
241
284
|
.catch(error =>
|
|
242
285
|
this.$mapo.$snack.open({
|
|
243
|
-
message: "Something whent bad, please try again later...",
|
|
286
|
+
message: error.response?.data?.detail || "Something whent bad, please try again later...",
|
|
244
287
|
color: "error"
|
|
245
288
|
})
|
|
246
289
|
);
|
|
247
290
|
}
|
|
248
291
|
});
|
|
249
292
|
},
|
|
250
|
-
|
|
293
|
+
initLang(lang = this.currentLang) {
|
|
294
|
+
if (lang && !this.model.translations) {
|
|
295
|
+
this.model.translations = {};
|
|
296
|
+
}
|
|
297
|
+
if (lang && !this.model.translations[lang]) {
|
|
298
|
+
this.model.translations[lang] = {};
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
parseConf(field, i) {
|
|
251
302
|
const conf = typeof field === "string" ? { value: field } : field;
|
|
252
|
-
conf.value = conf.value
|
|
253
|
-
conf.
|
|
303
|
+
conf.value = conf.value || "";
|
|
304
|
+
conf.value = conf.value.replace(new RegExp(`^translations\.(${this.langs.join("|")})\.?`), "");
|
|
305
|
+
conf.slotName = `fields.${conf.value || i}`;
|
|
254
306
|
if (this.currentLang && !field.synci18n) {
|
|
255
|
-
|
|
307
|
+
const base = `translations.${this.currentLang}`;
|
|
308
|
+
conf.value = (conf.value && `${base}.${conf.value}`) || base;
|
|
309
|
+
}
|
|
310
|
+
if (this.isReadonly){
|
|
311
|
+
conf.attrs = {...conf.attrs, readonly: true}
|
|
256
312
|
}
|
|
257
313
|
return conf;
|
|
258
314
|
},
|
|
@@ -261,21 +317,35 @@ export default {
|
|
|
261
317
|
const parseGroup = group =>
|
|
262
318
|
typeof group === "string"
|
|
263
319
|
? { name: group, icon }
|
|
264
|
-
: { ...group, icon: group.icon
|
|
265
|
-
return fields.map(f =>
|
|
320
|
+
: { ...group, icon: group.icon !== undefined ? group.icon : icon };
|
|
321
|
+
return fields.map((f, i) =>
|
|
266
322
|
f.group
|
|
267
323
|
? { group: parseGroup(f.group), fields: this.mapConf(f.fields) }
|
|
268
|
-
: this.parseConf(f)
|
|
324
|
+
: this.parseConf(f, i)
|
|
269
325
|
);
|
|
270
326
|
}
|
|
271
327
|
},
|
|
272
328
|
watch: {
|
|
273
329
|
currentLang(val) {
|
|
274
|
-
|
|
275
|
-
|
|
330
|
+
this.initLang();
|
|
331
|
+
// Fired when the current language changes.
|
|
332
|
+
// @arg Emits the language name as a string.
|
|
333
|
+
this.$emit("update:lang", val);
|
|
334
|
+
},
|
|
335
|
+
model(val) {
|
|
336
|
+
// Fired when the v-model changes.
|
|
337
|
+
// @arg Emits the entire payload modified.
|
|
338
|
+
this.$emit("input", val);
|
|
339
|
+
},
|
|
340
|
+
lang(val) {
|
|
341
|
+
if (val && this.langs.includes(val)) {
|
|
342
|
+
this.currentLang = val;
|
|
276
343
|
}
|
|
277
|
-
|
|
278
|
-
|
|
344
|
+
},
|
|
345
|
+
value(val) {
|
|
346
|
+
if (val) {
|
|
347
|
+
this.model = val;
|
|
348
|
+
this.initLang();
|
|
279
349
|
}
|
|
280
350
|
}
|
|
281
351
|
},
|
|
@@ -283,6 +353,18 @@ export default {
|
|
|
283
353
|
crud() {
|
|
284
354
|
return this.$mapo.$api.crud(this.endpoint);
|
|
285
355
|
},
|
|
356
|
+
isReadonly() {
|
|
357
|
+
if (this.$mapo.$auth.routeMiddlewares.includes("permissions")){
|
|
358
|
+
return !this.$mapo.$auth.user.permissions.includes(this.isNew ? "add" : "change")
|
|
359
|
+
}
|
|
360
|
+
return false
|
|
361
|
+
},
|
|
362
|
+
canDelete() {
|
|
363
|
+
if (this.$mapo.$auth.routeMiddlewares.includes("permissions")){
|
|
364
|
+
return this.$mapo.$auth.user.permissions.includes("delete")
|
|
365
|
+
}
|
|
366
|
+
return true
|
|
367
|
+
},
|
|
286
368
|
mainFields() {
|
|
287
369
|
return this.mapConf(
|
|
288
370
|
this.fields instanceof Array ? this.fields : this.fields.main || []
|
|
@@ -304,7 +386,7 @@ export default {
|
|
|
304
386
|
},
|
|
305
387
|
langs() {
|
|
306
388
|
return (
|
|
307
|
-
this.model?.
|
|
389
|
+
this.model?.lang_info?.site_languages.map(l => l.id) || this.languages
|
|
308
390
|
);
|
|
309
391
|
},
|
|
310
392
|
slotBindings() {
|
|
@@ -331,7 +413,10 @@ export default {
|
|
|
331
413
|
},
|
|
332
414
|
mounted() {
|
|
333
415
|
if (this.identifier && this.identifier !== "new") {
|
|
334
|
-
this.crud.detail(this.identifier).then(res =>
|
|
416
|
+
this.crud.detail(this.identifier).then(res => {
|
|
417
|
+
this.model = res;
|
|
418
|
+
this.initLang();
|
|
419
|
+
});
|
|
335
420
|
}
|
|
336
421
|
}
|
|
337
422
|
};
|
|
@@ -383,10 +468,10 @@ Here the list of the FieldConfiguration type association.
|
|
|
383
468
|
- `switch` ==> [v-switch](https://vuetifyjs.com/en/components/switches/),
|
|
384
469
|
- `slider` ==> [v-slider](https://vuetifyjs.com/en/components/sliders/),
|
|
385
470
|
- `file` ==> [v-file-input](https://vuetifyjs.com/en/components/file-inputs/),
|
|
386
|
-
- `editor` ==> [
|
|
471
|
+
- `editor` ==> [wyg-editor](/components/fields/wygEditor/wygEditor/),
|
|
387
472
|
- `media` ==> [media-field](/components/fields/MediaField/),
|
|
388
|
-
- `m2m` ==> [
|
|
389
|
-
- `mediaList` ==> [media-
|
|
473
|
+
- `m2m` or `fks` ==> [fks-field](/components/fields/FksField/),
|
|
474
|
+
- `mediaList` ==> [media-fks-field](/components/fields/MediaM2mField/)
|
|
390
475
|
|
|
391
476
|
|
|
392
477
|
#### Example of a [`FieldConfiguration`](#fieldconfiguration):
|
|
@@ -446,6 +531,7 @@ export default {
|
|
|
446
531
|
"title",
|
|
447
532
|
{ value: "description", type: "textarea" },
|
|
448
533
|
"permalink",
|
|
534
|
+
{ type: "seoPreview" }
|
|
449
535
|
]
|
|
450
536
|
}
|
|
451
537
|
],
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<div>
|
|
3
|
+
<span class="mapo-label" :class="`mapo-label-${conf.value}`">{{label}}</span>
|
|
4
|
+
<component :is="is" v-model="model" v-bind="fieldAttrs"></component>
|
|
5
|
+
</div>
|
|
3
6
|
</template>
|
|
4
7
|
|
|
8
|
+
<style>
|
|
9
|
+
.mapo-label {
|
|
10
|
+
display: none;
|
|
11
|
+
}
|
|
12
|
+
</style>
|
|
13
|
+
|
|
5
14
|
<script>
|
|
6
|
-
import
|
|
15
|
+
import wygEditor from "@mapomodule/uikit/components/fields/wygEditor/wygEditor.vue";
|
|
7
16
|
import DateField from "@mapomodule/uikit/components/fields/DateField.vue";
|
|
8
|
-
import
|
|
17
|
+
import FksField from "@mapomodule/uikit/components/fields/FksField.vue";
|
|
9
18
|
import MediaM2mField from "@mapomodule/uikit/components/fields/MediaM2mField.vue";
|
|
10
19
|
import MediaField from "@mapomodule/uikit/components/fields/MediaField.vue";
|
|
20
|
+
import SeoPreview from "@mapomodule/uikit/components/fields/SeoPreview.vue";
|
|
21
|
+
|
|
11
22
|
|
|
12
23
|
import { getPointed, setPointed } from "@mapomodule/utils/helpers/objHelpers";
|
|
13
24
|
import defaults from "./defaults";
|
|
@@ -18,26 +29,27 @@ import defaults from "./defaults";
|
|
|
18
29
|
export default {
|
|
19
30
|
name: "DetailField",
|
|
20
31
|
components: {
|
|
21
|
-
|
|
32
|
+
wygEditor,
|
|
22
33
|
DateField,
|
|
23
|
-
|
|
34
|
+
FksField,
|
|
24
35
|
MediaM2mField,
|
|
25
|
-
MediaField
|
|
36
|
+
MediaField,
|
|
37
|
+
SeoPreview,
|
|
26
38
|
},
|
|
27
39
|
|
|
28
40
|
data() {
|
|
29
41
|
return {
|
|
30
42
|
model: null,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
defaultMap: defaults.mapping,
|
|
44
|
+
defaultAttrs: defaults.props,
|
|
45
|
+
defaultAccess: defaults.accessor,
|
|
34
46
|
};
|
|
35
47
|
},
|
|
36
48
|
props: {
|
|
37
49
|
// V-model of the payload needed to edit the field value in realtime.
|
|
38
50
|
value: {
|
|
39
51
|
type: Object,
|
|
40
|
-
required: true
|
|
52
|
+
required: true,
|
|
41
53
|
},
|
|
42
54
|
// An object representing all the errors of all fields. This means that this component will find the error of its field following the dottedPath of the value in the error dict.
|
|
43
55
|
errors: Object,
|
|
@@ -45,18 +57,18 @@ export default {
|
|
|
45
57
|
conf: {
|
|
46
58
|
// [`FieldConfiguration`](/components/detail/Detail/#fieldconfiguration)
|
|
47
59
|
type: Object,
|
|
48
|
-
required: true
|
|
49
|
-
}
|
|
60
|
+
required: true,
|
|
61
|
+
},
|
|
50
62
|
},
|
|
51
63
|
watch: {
|
|
52
64
|
value: {
|
|
53
65
|
deep: true,
|
|
54
66
|
handler(val) {
|
|
55
67
|
this.setModel(val);
|
|
56
|
-
}
|
|
68
|
+
},
|
|
57
69
|
},
|
|
58
|
-
conf(
|
|
59
|
-
if (
|
|
70
|
+
"conf.value"(newValue, oldValue) {
|
|
71
|
+
if (newValue !== oldValue) {
|
|
60
72
|
this.setModel();
|
|
61
73
|
}
|
|
62
74
|
},
|
|
@@ -70,43 +82,44 @@ export default {
|
|
|
70
82
|
// Fired when the v-model changes.
|
|
71
83
|
// @arg Emits the entire payload modified.
|
|
72
84
|
this.$emit("input", dump);
|
|
73
|
-
}
|
|
85
|
+
},
|
|
74
86
|
},
|
|
75
87
|
methods: {
|
|
76
88
|
setModel(val = this.value) {
|
|
77
89
|
var model = this.accessor.get({
|
|
78
90
|
model: { ...val },
|
|
79
|
-
val: getPointed({ ...val }, this.conf.value)
|
|
91
|
+
val: getPointed({ ...val }, this.conf.value),
|
|
80
92
|
});
|
|
81
93
|
if (val && JSON.stringify(this.model) !== JSON.stringify(model))
|
|
82
94
|
this.model = model;
|
|
83
|
-
}
|
|
95
|
+
},
|
|
84
96
|
},
|
|
85
97
|
computed: {
|
|
86
98
|
accessor() {
|
|
87
|
-
let func = function({ val }) {
|
|
99
|
+
let func = function ({ val }) {
|
|
88
100
|
return val;
|
|
89
101
|
};
|
|
90
102
|
return {
|
|
91
103
|
get: func,
|
|
92
104
|
set: func,
|
|
93
|
-
...(this.
|
|
94
|
-
...this.conf.accessor
|
|
105
|
+
...(this.defaultAccess[this.is] || {}),
|
|
106
|
+
...this.conf.accessor,
|
|
95
107
|
};
|
|
96
108
|
},
|
|
97
|
-
|
|
109
|
+
fieldAttrs() {
|
|
98
110
|
return {
|
|
99
111
|
label: this.label,
|
|
100
112
|
errorMessages: getPointed(this.errors || {}, this.conf.value, []),
|
|
101
|
-
...
|
|
102
|
-
...this.
|
|
113
|
+
...this.defaultAttrs.All,
|
|
114
|
+
...(this.defaultAttrs[this.is.replace(/-./g, x=>x[1].toUpperCase())] || {}),
|
|
115
|
+
...this.conf.attrs,
|
|
103
116
|
};
|
|
104
117
|
},
|
|
105
118
|
label() {
|
|
106
119
|
if (this.conf.label !== undefined) {
|
|
107
120
|
return this.conf.label;
|
|
108
121
|
}
|
|
109
|
-
const titleCase = string =>
|
|
122
|
+
const titleCase = (string) =>
|
|
110
123
|
(string && string[0].toUpperCase() + string.slice(1).toLowerCase()) ||
|
|
111
124
|
"";
|
|
112
125
|
return titleCase(
|
|
@@ -120,10 +133,10 @@ export default {
|
|
|
120
133
|
is() {
|
|
121
134
|
return (
|
|
122
135
|
this.conf.is ||
|
|
123
|
-
(this.conf.type && this.
|
|
124
|
-
"
|
|
136
|
+
(this.conf.type && this.defaultMap[this.conf.type]) ||
|
|
137
|
+
"vTextField"
|
|
125
138
|
);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
139
|
+
},
|
|
140
|
+
},
|
|
128
141
|
};
|
|
129
142
|
</script>
|