@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,10 +1,23 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<div>
|
|
3
|
+
<div v-show="loading">
|
|
4
|
+
<v-progress-linear
|
|
5
|
+
color="primary"
|
|
6
|
+
indeterminate
|
|
7
|
+
absolute
|
|
8
|
+
style="top: 0;"
|
|
9
|
+
></v-progress-linear>
|
|
10
|
+
<span class="detail-component-loading ">
|
|
11
|
+
<v-icon size="30">mdi-timer-sand</v-icon>
|
|
12
|
+
Fetching data..
|
|
13
|
+
</span>
|
|
14
|
+
</div>
|
|
15
|
+
<div v-show="!loading">
|
|
3
16
|
<!-- Use this to override the title of the detail component. -->
|
|
4
17
|
<slot name="title" v-bind="slotBindings">
|
|
5
18
|
<!-- `<h1> "Create | Edit" + modelName </h1>` -->
|
|
6
|
-
<v-row class="mb-
|
|
7
|
-
<h1>{{ isNew ? "Create" : "Edit" }} {{ modelName }}</h1>
|
|
19
|
+
<v-row class="mb-5">
|
|
20
|
+
<v-col col="12"><h1 class="display-1">{{ isNew ? "Create" : "Edit" }} {{ modelName }}</h1></v-col>
|
|
8
21
|
</v-row>
|
|
9
22
|
</slot>
|
|
10
23
|
<v-form ref="form">
|
|
@@ -17,6 +30,7 @@
|
|
|
17
30
|
<!-- [`DetailLangSwitch`](/components/detail/DetailLangSwitch/) -->
|
|
18
31
|
<DetailLangSwitch
|
|
19
32
|
v-if="langs && langs.length"
|
|
33
|
+
v-show="langs.length > 1"
|
|
20
34
|
class="mb-4"
|
|
21
35
|
v-model="currentLang"
|
|
22
36
|
:langs="langs"
|
|
@@ -26,47 +40,65 @@
|
|
|
26
40
|
<slot name="body.top.underlang" v-bind="slotBindings"></slot>
|
|
27
41
|
<!-- Use this to override the content of the main body. -->
|
|
28
42
|
<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
|
-
}"
|
|
43
|
+
<div class="row">
|
|
44
|
+
<!-- The result of the [`DetailConfiguration`](#detailconfiguration) contained in the main body. -->
|
|
45
|
+
<div
|
|
46
|
+
class="col-12"
|
|
47
|
+
:class="field.class"
|
|
48
|
+
v-for="(field, index) in mainFields"
|
|
49
|
+
:key="index"
|
|
67
50
|
>
|
|
68
|
-
<
|
|
69
|
-
|
|
51
|
+
<v-card v-if="field.group" class="my-2 rounded-0">
|
|
52
|
+
<v-card-title>
|
|
53
|
+
<v-icon left> {{ field.group.icon }} </v-icon>
|
|
54
|
+
<span>{{ field.group.name }}</span>
|
|
55
|
+
</v-card-title>
|
|
56
|
+
<div class="container">
|
|
57
|
+
<div class="row">
|
|
58
|
+
<div
|
|
59
|
+
v-for="(fields, fieldsI) in field.fields"
|
|
60
|
+
:key="fieldsI"
|
|
61
|
+
class="col-12"
|
|
62
|
+
:class="fields.class"
|
|
63
|
+
>
|
|
64
|
+
<!-- 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`. -->
|
|
65
|
+
<slot
|
|
66
|
+
:name="fields.slotName"
|
|
67
|
+
v-bind="{
|
|
68
|
+
conf: fields,
|
|
69
|
+
...slotBindings,
|
|
70
|
+
}"
|
|
71
|
+
>
|
|
72
|
+
<!-- A [`DetailField`](/components/detail/DetailField/) configured by a [`FieldConfiguration`](#fieldconfiguration). -->
|
|
73
|
+
<DetailField
|
|
74
|
+
v-model="model"
|
|
75
|
+
:langs="langs"
|
|
76
|
+
:currentLang="currentLang"
|
|
77
|
+
:conf="fields"
|
|
78
|
+
:errors="errors"
|
|
79
|
+
/>
|
|
80
|
+
</slot>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
</v-card>
|
|
85
|
+
<slot
|
|
86
|
+
v-else
|
|
87
|
+
:name="field.slotName"
|
|
88
|
+
v-bind="{
|
|
89
|
+
conf: field,
|
|
90
|
+
...slotBindings,
|
|
91
|
+
}"
|
|
92
|
+
>
|
|
93
|
+
<DetailField
|
|
94
|
+
v-model="model"
|
|
95
|
+
:langs="langs"
|
|
96
|
+
:currentLang="currentLang"
|
|
97
|
+
:conf="field"
|
|
98
|
+
:errors="errors"
|
|
99
|
+
/>
|
|
100
|
+
</slot>
|
|
101
|
+
</div>
|
|
70
102
|
</div>
|
|
71
103
|
</slot>
|
|
72
104
|
<!-- Use this to add content under the main body. -->
|
|
@@ -83,21 +115,21 @@
|
|
|
83
115
|
<!-- Use this to override the Save button. -->
|
|
84
116
|
<slot name="button.save" v-bind="slotBindings">
|
|
85
117
|
<!-- The Save button. -->
|
|
86
|
-
<v-btn class="mb-2" tile block @click="saveItem(true)">{{
|
|
118
|
+
<v-btn v-show="canGoBack" :disabled="isReadonly" class="mb-2" tile block @click="saveItem(true)">{{
|
|
87
119
|
isNew ? "Create" : "Save"
|
|
88
120
|
}}</v-btn>
|
|
89
121
|
</slot>
|
|
90
122
|
<!-- Use this to override the Save and continue button. -->
|
|
91
123
|
<slot name="button.savecontinue" v-bind="slotBindings">
|
|
92
124
|
<!-- The Save and continue button. -->
|
|
93
|
-
<v-btn class="mb-2" tile block @click="saveItem(false)"
|
|
125
|
+
<v-btn :disabled="isReadonly" class="mb-2" tile block @click="saveItem(false)"
|
|
94
126
|
>{{ isNew ? "Create" : "Save" }} and continue</v-btn
|
|
95
127
|
>
|
|
96
128
|
</slot>
|
|
97
129
|
<!-- Use this to override the Back button. -->
|
|
98
130
|
<slot name="button.back" v-bind="slotBindings">
|
|
99
131
|
<!-- The Back button. -->
|
|
100
|
-
<v-btn class="mb-2" tile block @click="
|
|
132
|
+
<v-btn v-show="canGoBack" class="mb-2" tile block @click="back"
|
|
101
133
|
>Back</v-btn
|
|
102
134
|
>
|
|
103
135
|
</slot>
|
|
@@ -110,6 +142,7 @@
|
|
|
110
142
|
color="error"
|
|
111
143
|
tile
|
|
112
144
|
block
|
|
145
|
+
:disabled="!canDelete"
|
|
113
146
|
@click="deleteItem"
|
|
114
147
|
>Delete</v-btn
|
|
115
148
|
>
|
|
@@ -118,45 +151,63 @@
|
|
|
118
151
|
</slot>
|
|
119
152
|
<!-- Use this to add content on the top of the sidebar fields (or under sidebar buttons). -->
|
|
120
153
|
<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
|
-
}"
|
|
154
|
+
<div class="row">
|
|
155
|
+
<div
|
|
156
|
+
class="col-12"
|
|
157
|
+
:class="field.class"
|
|
158
|
+
v-for="(field, index) in sideFields"
|
|
159
|
+
:key="index"
|
|
157
160
|
>
|
|
158
|
-
<
|
|
159
|
-
|
|
161
|
+
<v-card v-if="field.group" class="rounded-0 mb-4">
|
|
162
|
+
<v-card-title>
|
|
163
|
+
<v-icon left> {{ field.group.icon }} </v-icon>
|
|
164
|
+
<span>{{ field.group.name }}</span>
|
|
165
|
+
</v-card-title>
|
|
166
|
+
<div class="container">
|
|
167
|
+
<div class="row">
|
|
168
|
+
<div
|
|
169
|
+
v-for="(fields, fieldsI) in field.fields"
|
|
170
|
+
:key="fieldsI"
|
|
171
|
+
class="col-12"
|
|
172
|
+
:class="field.class"
|
|
173
|
+
>
|
|
174
|
+
<!-- @vuese-ignore -->
|
|
175
|
+
<slot
|
|
176
|
+
:name="fields.slotName"
|
|
177
|
+
v-bind="{
|
|
178
|
+
conf: fields,
|
|
179
|
+
...slotBindings,
|
|
180
|
+
}"
|
|
181
|
+
>
|
|
182
|
+
<DetailField
|
|
183
|
+
v-model="model"
|
|
184
|
+
:langs="langs"
|
|
185
|
+
:currentLang="currentLang"
|
|
186
|
+
:conf="fields"
|
|
187
|
+
:errors="errors"
|
|
188
|
+
/>
|
|
189
|
+
</slot>
|
|
190
|
+
</div>
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
</v-card>
|
|
194
|
+
<slot
|
|
195
|
+
v-else
|
|
196
|
+
:name="field.slotName"
|
|
197
|
+
v-bind="{
|
|
198
|
+
conf: field,
|
|
199
|
+
...slotBindings,
|
|
200
|
+
}"
|
|
201
|
+
>
|
|
202
|
+
<DetailField
|
|
203
|
+
v-model="model"
|
|
204
|
+
:langs="langs"
|
|
205
|
+
:currentLang="currentLang"
|
|
206
|
+
:conf="field"
|
|
207
|
+
:errors="errors"
|
|
208
|
+
/>
|
|
209
|
+
</slot>
|
|
210
|
+
</div>
|
|
160
211
|
</div>
|
|
161
212
|
<!-- Use this to add content under the sidebar fields. -->
|
|
162
213
|
<slot name="side.bottom" v-bind="slotBindings"></slot>
|
|
@@ -164,9 +215,22 @@
|
|
|
164
215
|
</v-col>
|
|
165
216
|
</v-row>
|
|
166
217
|
</v-form>
|
|
167
|
-
</
|
|
218
|
+
</div>
|
|
219
|
+
</div>
|
|
168
220
|
</template>
|
|
169
221
|
|
|
222
|
+
<style lang="scss" scoped>
|
|
223
|
+
.detail-component-loading {
|
|
224
|
+
position: absolute;
|
|
225
|
+
top: 50%;
|
|
226
|
+
transform: translateY(-50%);
|
|
227
|
+
width: 100%;
|
|
228
|
+
display: flex;
|
|
229
|
+
flex-direction: column;
|
|
230
|
+
justify-content: center;
|
|
231
|
+
align-items: center;
|
|
232
|
+
}
|
|
233
|
+
</style>
|
|
170
234
|
|
|
171
235
|
<script>
|
|
172
236
|
/**
|
|
@@ -178,11 +242,22 @@ export default {
|
|
|
178
242
|
data() {
|
|
179
243
|
return {
|
|
180
244
|
model: {},
|
|
181
|
-
|
|
245
|
+
modelLanguages: [],
|
|
246
|
+
currentLang: this.lang,
|
|
182
247
|
errors: null
|
|
183
248
|
};
|
|
184
249
|
},
|
|
185
250
|
props: {
|
|
251
|
+
// V-model of the object we are editing.
|
|
252
|
+
value: {
|
|
253
|
+
type: Object,
|
|
254
|
+
required: false
|
|
255
|
+
},
|
|
256
|
+
// Set the current lang to value.
|
|
257
|
+
lang: {
|
|
258
|
+
type: String,
|
|
259
|
+
required: false
|
|
260
|
+
},
|
|
186
261
|
// The main configuration that determines the arrangement of the fields in the detail layout.
|
|
187
262
|
fields: {
|
|
188
263
|
// [`DetailConfiguration`](#detailconfiguration)
|
|
@@ -195,7 +270,10 @@ export default {
|
|
|
195
270
|
default: () => []
|
|
196
271
|
},
|
|
197
272
|
// 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:
|
|
273
|
+
endpoint: {
|
|
274
|
+
type: String,
|
|
275
|
+
default: null
|
|
276
|
+
},
|
|
199
277
|
// The identifier of the object you need to retrieve and edit. It can be "new" if you need to create a new payload.
|
|
200
278
|
identifier: {
|
|
201
279
|
// `String|Number`.
|
|
@@ -208,20 +286,32 @@ export default {
|
|
|
208
286
|
sticky: {
|
|
209
287
|
type: Boolean,
|
|
210
288
|
default: true
|
|
211
|
-
}
|
|
289
|
+
},
|
|
290
|
+
// 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.
|
|
291
|
+
multipart: {
|
|
292
|
+
type: String,
|
|
293
|
+
default: "auto",
|
|
294
|
+
validator: function (value) {
|
|
295
|
+
// The value must match one of these strings
|
|
296
|
+
return ["auto", "force", "disable"].indexOf(value) !== -1;
|
|
297
|
+
},
|
|
298
|
+
},
|
|
212
299
|
},
|
|
213
300
|
methods: {
|
|
301
|
+
back() {
|
|
302
|
+
this.$nuxt.context?.from?.name == "login" ? this.$router.go(-3) : this.$router.back()
|
|
303
|
+
},
|
|
214
304
|
saveItem(back = false) {
|
|
215
305
|
this.errors = null;
|
|
216
306
|
this.$refs.form?.resetValidation();
|
|
217
307
|
this.crud
|
|
218
|
-
.updateOrCreate(this.model)
|
|
219
|
-
.then(() => back
|
|
308
|
+
.updateOrCreate(this.model, {}, { multipart: this.multipart })
|
|
309
|
+
.then((resp) => { back ? this.back() : this.model = resp })
|
|
220
310
|
.catch(error => {
|
|
221
311
|
this.errors =
|
|
222
312
|
(error.response.status == 400 && error.response.data) || null;
|
|
223
313
|
this.$mapo.$snack.open({
|
|
224
|
-
message: "Something whent bad, please try again later...",
|
|
314
|
+
message: error.response?.data?.detail || "Something whent bad, please try again later...",
|
|
225
315
|
color: "error"
|
|
226
316
|
});
|
|
227
317
|
});
|
|
@@ -231,28 +321,41 @@ export default {
|
|
|
231
321
|
.open({
|
|
232
322
|
title: "Delete",
|
|
233
323
|
question: "Are you sure you want to delete this item?",
|
|
234
|
-
approveButton: { text: "Delete", attrs: { color: "red" } }
|
|
324
|
+
approveButton: { text: "Delete", attrs: { color: "red", text: true } }
|
|
235
325
|
})
|
|
236
326
|
.then(res => {
|
|
237
327
|
if (res) {
|
|
238
328
|
this.crud
|
|
239
329
|
.delete(this.identifier)
|
|
240
|
-
.then(() => this
|
|
330
|
+
.then(() => this.back())
|
|
241
331
|
.catch(error =>
|
|
242
332
|
this.$mapo.$snack.open({
|
|
243
|
-
message: "Something whent bad, please try again later...",
|
|
333
|
+
message: error.response?.data?.detail || "Something whent bad, please try again later...",
|
|
244
334
|
color: "error"
|
|
245
335
|
})
|
|
246
336
|
);
|
|
247
337
|
}
|
|
248
338
|
});
|
|
249
339
|
},
|
|
250
|
-
|
|
340
|
+
initLang(lang = this.currentLang) {
|
|
341
|
+
if (lang && !this.model.translations) {
|
|
342
|
+
this.model.translations = {};
|
|
343
|
+
}
|
|
344
|
+
if (lang && !this.model.translations[lang]) {
|
|
345
|
+
this.model.translations[lang] = {};
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
parseConf(field, i) {
|
|
251
349
|
const conf = typeof field === "string" ? { value: field } : field;
|
|
252
|
-
conf.value = conf.value
|
|
253
|
-
conf.
|
|
350
|
+
conf.value = conf.value || "";
|
|
351
|
+
conf.value = conf.value.replace(new RegExp(`^translations\.(${this.langs.join("|")})\.?`), "");
|
|
352
|
+
conf.slotName = `fields.${conf.value || i}`;
|
|
254
353
|
if (this.currentLang && !field.synci18n) {
|
|
255
|
-
|
|
354
|
+
const base = `translations.${this.currentLang}`;
|
|
355
|
+
conf.value = (conf.value && `${base}.${conf.value}`) || base;
|
|
356
|
+
}
|
|
357
|
+
if (this.isReadonly){
|
|
358
|
+
conf.attrs = {...conf.attrs, readonly: true}
|
|
256
359
|
}
|
|
257
360
|
return conf;
|
|
258
361
|
},
|
|
@@ -261,28 +364,60 @@ export default {
|
|
|
261
364
|
const parseGroup = group =>
|
|
262
365
|
typeof group === "string"
|
|
263
366
|
? { name: group, icon }
|
|
264
|
-
: { ...group, icon: group.icon
|
|
265
|
-
return fields.map(f =>
|
|
367
|
+
: { ...group, icon: group.icon !== undefined ? group.icon : icon };
|
|
368
|
+
return fields.map((f, i) =>
|
|
266
369
|
f.group
|
|
267
370
|
? { group: parseGroup(f.group), fields: this.mapConf(f.fields) }
|
|
268
|
-
: this.parseConf(f)
|
|
371
|
+
: this.parseConf(f, i)
|
|
269
372
|
);
|
|
270
373
|
}
|
|
271
374
|
},
|
|
272
375
|
watch: {
|
|
273
376
|
currentLang(val) {
|
|
274
|
-
|
|
275
|
-
|
|
377
|
+
this.initLang();
|
|
378
|
+
// Fired when the current language changes.
|
|
379
|
+
// @arg Emits the language name as a string.
|
|
380
|
+
this.$emit("update:lang", val);
|
|
381
|
+
},
|
|
382
|
+
model(val) {
|
|
383
|
+
// Fired when the v-model changes.
|
|
384
|
+
// @arg Emits the entire payload modified.
|
|
385
|
+
this.$emit("input", val);
|
|
386
|
+
},
|
|
387
|
+
lang(val) {
|
|
388
|
+
if (val && this.langs.includes(val)) {
|
|
389
|
+
this.currentLang = val;
|
|
276
390
|
}
|
|
277
|
-
|
|
278
|
-
|
|
391
|
+
},
|
|
392
|
+
value(val) {
|
|
393
|
+
if (val) {
|
|
394
|
+
this.model = val;
|
|
395
|
+
this.initLang();
|
|
279
396
|
}
|
|
280
397
|
}
|
|
281
398
|
},
|
|
282
|
-
|
|
399
|
+
computed: {
|
|
400
|
+
canGoBack() {
|
|
401
|
+
if (typeof window !== "undefined") {
|
|
402
|
+
return this.$nuxt?.context?.from?.name !== "login" && window.history.length > 1 || window.history.length > 3
|
|
403
|
+
}
|
|
404
|
+
return true;
|
|
405
|
+
},
|
|
283
406
|
crud() {
|
|
284
407
|
return this.$mapo.$api.crud(this.endpoint);
|
|
285
408
|
},
|
|
409
|
+
isReadonly() {
|
|
410
|
+
if (this.$mapo.$auth.routeMiddlewares.includes("permissions")){
|
|
411
|
+
return !this.$mapo.$auth.user.permissions.includes(this.isNew ? "add" : "change")
|
|
412
|
+
}
|
|
413
|
+
return false
|
|
414
|
+
},
|
|
415
|
+
canDelete() {
|
|
416
|
+
if (this.$mapo.$auth.routeMiddlewares.includes("permissions")){
|
|
417
|
+
return this.$mapo.$auth.user.permissions.includes("delete")
|
|
418
|
+
}
|
|
419
|
+
return true
|
|
420
|
+
},
|
|
286
421
|
mainFields() {
|
|
287
422
|
return this.mapConf(
|
|
288
423
|
this.fields instanceof Array ? this.fields : this.fields.main || []
|
|
@@ -303,13 +438,12 @@ export default {
|
|
|
303
438
|
return !Object.keys(this.model).length;
|
|
304
439
|
},
|
|
305
440
|
langs() {
|
|
306
|
-
return
|
|
307
|
-
this.model?.active_languages?.languages.map(l => l.id) || this.languages
|
|
308
|
-
);
|
|
441
|
+
return this.modelLanguages || this.languages;
|
|
309
442
|
},
|
|
310
443
|
slotBindings() {
|
|
311
444
|
return {
|
|
312
445
|
model: this.model,
|
|
446
|
+
errors: this.errors,
|
|
313
447
|
currentLang: this.currentLang,
|
|
314
448
|
crud: this.crud,
|
|
315
449
|
isNew: this.isNew,
|
|
@@ -331,7 +465,17 @@ export default {
|
|
|
331
465
|
},
|
|
332
466
|
mounted() {
|
|
333
467
|
if (this.identifier && this.identifier !== "new") {
|
|
334
|
-
this.crud.detail(this.identifier).then(res =>
|
|
468
|
+
this.crud.detail(this.identifier).then(res => {
|
|
469
|
+
this.model = res;
|
|
470
|
+
this.modelLanguages = this.model?.lang_info?.site_languages.map(l => l.id)
|
|
471
|
+
this.initLang();
|
|
472
|
+
}).catch(error => {
|
|
473
|
+
this.$nuxt.error({ statusCode: error.response.status, message: error.response.data?.detail || "Ops some error occurred.." })
|
|
474
|
+
});
|
|
475
|
+
} else if (this.value) {
|
|
476
|
+
this.model = this.value;
|
|
477
|
+
this.modelLanguages = this.model?.lang_info?.site_languages.map(l => l.id)
|
|
478
|
+
this.initLang();
|
|
335
479
|
}
|
|
336
480
|
}
|
|
337
481
|
};
|
|
@@ -341,7 +485,7 @@ export default {
|
|
|
341
485
|
|
|
342
486
|
## DetailConfiguration
|
|
343
487
|
|
|
344
|
-
The DetailConfiguration determines the behavior of the main form and is an `Array` of [`FieldConfiguration`](#fieldconfiguration).
|
|
488
|
+
The DetailConfiguration determines the behavior of the main form and is an `Array` of [`FieldConfiguration`](#fieldconfiguration).
|
|
345
489
|
Each field configuration represents a field of the form.
|
|
346
490
|
The configuration can also consist of an object with two keys `{ main sidenav }`.
|
|
347
491
|
Each key is an `Array` of [`FieldConfiguration`](#fieldconfiguration) and will modify a different part of the component:
|
|
@@ -351,7 +495,7 @@ Each key is an `Array` of [`FieldConfiguration`](#fieldconfiguration) and will m
|
|
|
351
495
|
|
|
352
496
|
### FieldConfiguration
|
|
353
497
|
|
|
354
|
-
The `FieldConfiguration` is a `String` containing the dottedPath of a value inside the payload we want to modify.
|
|
498
|
+
The `FieldConfiguration` is a `String` containing the dottedPath of a value inside the payload we want to modify.
|
|
355
499
|
So, for example, if we have the payload: `{ image: { name: "...", url: "..." } }` we can modify the image name using the dottedPath `"image.name"`.
|
|
356
500
|
|
|
357
501
|
The default component used to render a field of a form is a [`v-text-field`](https://vuetifyjs.com/en/components/text-fields/).
|
|
@@ -359,12 +503,12 @@ If you want more control over the generated component you can use an `Object` wi
|
|
|
359
503
|
|
|
360
504
|
|Name|Description|Type|Required|Default|
|
|
361
505
|
|---|---|---|---|---|
|
|
362
|
-
|value|The dottedPath of the value we want to modify.|`String`|`true`|-|
|
|
363
|
-
|synci18n|Determines if the field is translatable or not. If set to true the value will remain the same in all translations (untranslatable).|`Boolean`|`false`|`false`|
|
|
364
|
-
|type|Type of the field. This determines which component will be rendered. The list of possible choices can be found [here](#field-types) |`String`|`false`|`text`|
|
|
365
|
-
|accessor|[`Accessor`](#accessor) object to specify the setter and the getter of the field.|`Object`|`false`|`{set: x=>x, get: x=>x}`|
|
|
366
|
-
|attrs|The attributes that will be passed to the component.|`Object`|`false`|-|
|
|
367
|
-
|is|The component to be rendered in the form. This has a higher priority than the "type" attribute. Here you can pass in any regitered Vue component instance or name. [Learn more](https://vuejs.org/v2/guide/components.html#Dynamic-Components).|`String | VueComponent`|`false`|-|
|
|
506
|
+
|value|The dottedPath of the value we want to modify.|`String`|`true`|-|
|
|
507
|
+
|synci18n|Determines if the field is translatable or not. If set to true the value will remain the same in all translations (untranslatable).|`Boolean`|`false`|`false`|
|
|
508
|
+
|type|Type of the field. This determines which component will be rendered. The list of possible choices can be found [here](#field-types) |`String`|`false`|`text`|
|
|
509
|
+
|accessor|[`Accessor`](#accessor) object to specify the setter and the getter of the field.|`Object`|`false`|`{set: x=>x, get: x=>x}`|
|
|
510
|
+
|attrs|The attributes that will be passed to the component.|`Object`|`false`|-|
|
|
511
|
+
|is|The component to be rendered in the form. This has a higher priority than the "type" attribute. Here you can pass in any regitered Vue component instance or name. [Learn more](https://vuejs.org/v2/guide/components.html#Dynamic-Components).|`String | VueComponent`|`false`|-|
|
|
368
512
|
|
|
369
513
|
#### Accessor
|
|
370
514
|
|
|
@@ -374,7 +518,7 @@ Each function must return the processed value.
|
|
|
374
518
|
|
|
375
519
|
#### Field types
|
|
376
520
|
|
|
377
|
-
Here the list of the FieldConfiguration type association.
|
|
521
|
+
Here the list of the FieldConfiguration type association.
|
|
378
522
|
|
|
379
523
|
- `text` ==> [v-text-field](https://vuetifyjs.com/en/components/text-fields/),
|
|
380
524
|
- `select` ==> [v-select](https://vuetifyjs.com/en/components/selects/),
|
|
@@ -382,11 +526,12 @@ Here the list of the FieldConfiguration type association.
|
|
|
382
526
|
- `textarea` ==> [v-textarea](https://vuetifyjs.com/en/components/textareas/),
|
|
383
527
|
- `switch` ==> [v-switch](https://vuetifyjs.com/en/components/switches/),
|
|
384
528
|
- `slider` ==> [v-slider](https://vuetifyjs.com/en/components/sliders/),
|
|
385
|
-
- `file` ==> [
|
|
386
|
-
- `editor` ==> [
|
|
529
|
+
- `file` ==> [file-field](/components/fields/FileField/),
|
|
530
|
+
- `editor` ==> [wyg-editor](/components/fields/wygEditor/wygEditor/),
|
|
387
531
|
- `media` ==> [media-field](/components/fields/MediaField/),
|
|
388
|
-
- `m2m` ==> [m2m-field](/components/fields/M2mField/),
|
|
389
532
|
- `mediaList` ==> [media-m2m-field](/components/fields/MediaM2mField/)
|
|
533
|
+
- `m2m` or `fks` ==> [fks-field](/components/fields/FksField/),
|
|
534
|
+
- `repeater` ==> [repeater](/components/fields/Repeater/),
|
|
390
535
|
|
|
391
536
|
|
|
392
537
|
#### Example of a [`FieldConfiguration`](#fieldconfiguration):
|
|
@@ -405,8 +550,8 @@ Here the list of the FieldConfiguration type association.
|
|
|
405
550
|
|
|
406
551
|
### FieldGroup
|
|
407
552
|
|
|
408
|
-
You can use this mixed with `FieldConfiguration` to group multiple fields in one card with a title and an icon.
|
|
409
|
-
The `FieldGroup` has the key group that is a string repreenting the name of the group and the key fields that is an `Array` of [`FieldConfiguration`](#fieldconfiguration).
|
|
553
|
+
You can use this mixed with `FieldConfiguration` to group multiple fields in one card with a title and an icon.
|
|
554
|
+
The `FieldGroup` has the key group that is a string repreenting the name of the group and the key fields that is an `Array` of [`FieldConfiguration`](#fieldconfiguration).
|
|
410
555
|
The group key can also be an `Object`. In that case it contains the name and the icon for the group `{name: "...", icon: "..."}`. For a list of all available icons, visit the official [Material Design Icons](https://materialdesignicons.com/) page.
|
|
411
556
|
|
|
412
557
|
<br><br>
|
|
@@ -423,8 +568,9 @@ This is an interactive example. You can play with it but remember that all http
|
|
|
423
568
|
::: demo
|
|
424
569
|
<template>
|
|
425
570
|
<v-app>
|
|
571
|
+
<div class="d-flex justify-end"><ThemeToggle/></div>
|
|
426
572
|
<Detail
|
|
427
|
-
endpoint="api/
|
|
573
|
+
endpoint="api/articles"
|
|
428
574
|
identifier="new"
|
|
429
575
|
:fields="fields"
|
|
430
576
|
:languages="['it', 'en', 'de']"
|
|
@@ -440,12 +586,21 @@ export default {
|
|
|
440
586
|
main: [
|
|
441
587
|
{ value: "identifier", synci18n: true },
|
|
442
588
|
{ value: "content", type: "editor" },
|
|
589
|
+
{ value: "sections", type: "repeater", attrs: {
|
|
590
|
+
sortable: true,
|
|
591
|
+
fields: [
|
|
592
|
+
{ value: "title", class: "col-md-6" },
|
|
593
|
+
{ value: "subtitle", class: "col-md-6" },
|
|
594
|
+
{ value: "content", type: "textarea" },
|
|
595
|
+
]}
|
|
596
|
+
},
|
|
443
597
|
{
|
|
444
598
|
group: "Seo",
|
|
445
599
|
fields: [
|
|
446
600
|
"title",
|
|
447
601
|
{ value: "description", type: "textarea" },
|
|
448
602
|
"permalink",
|
|
603
|
+
{ type: "seoPreview" }
|
|
449
604
|
]
|
|
450
605
|
}
|
|
451
606
|
],
|
|
@@ -486,4 +641,4 @@ export default {
|
|
|
486
641
|
|
|
487
642
|
|
|
488
643
|
|
|
489
|
-
</docs>
|
|
644
|
+
</docs>
|