@mapomodule/uikit 1.0.0-alpha.9 → 2.0.0-beta.1
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/README.md +167 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +18 -0
- package/dist/module.d.cts +2 -0
- package/dist/module.d.mts +2 -0
- package/dist/module.d.ts +2 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +18 -0
- package/dist/types.d.mts +13 -0
- package/package.json +63 -10
- package/src/index.ts +10 -0
- package/src/module.ts +181 -0
- package/src/runtime/assets/main.css +59 -0
- package/src/runtime/components/MapoConfirmDialog.vue +34 -0
- package/src/runtime/components/MapoDetail.vue +861 -0
- package/src/runtime/components/MapoDetailLangSwitch.vue +166 -0
- package/src/runtime/components/MapoList.vue +339 -0
- package/src/runtime/components/MapoListActions.vue +152 -0
- package/src/runtime/components/MapoListFilters.vue +289 -0
- package/src/runtime/components/MapoListHead.vue +12 -0
- package/src/runtime/components/MapoListQuickEdit.vue +163 -0
- package/src/runtime/components/MapoListTable.vue +926 -0
- package/src/runtime/components/MapoListTabs.vue +48 -0
- package/src/runtime/components/MapoLogin.vue +209 -0
- package/src/runtime/components/MapoLogoutButton.vue +46 -0
- package/src/runtime/components/MapoRootComponents.vue +9 -0
- package/src/runtime/components/MapoSidebar.vue +112 -0
- package/src/runtime/components/MapoSidebarList.vue +35 -0
- package/src/runtime/components/MapoSidebarListItem.vue +79 -0
- package/src/runtime/components/MapoSidebarProfile.vue +57 -0
- package/src/runtime/components/MapoSnackBar.vue +42 -0
- package/src/runtime/components/MapoThemeToggle.vue +23 -0
- package/src/runtime/components/MapoTopbar.vue +36 -0
- package/src/runtime/layouts/default.vue +53 -0
- package/src/runtime/layouts/empty.vue +9 -0
- package/src/runtime/page-meta.nuxt.d.ts +45 -0
- package/src/runtime/pages/index.vue +14 -0
- package/src/runtime/pages/login.vue +7 -0
- package/src/runtime/types/list.ts +64 -0
- package/CHANGELOG.md +0 -177
- package/LICENSE.md +0 -20
- package/assets/mixins.scss +0 -22
- package/assets/variables.scss +0 -18
- package/components/ConfirmDialog.vue +0 -152
- package/components/Detail/Detail.vue +0 -566
- package/components/Detail/DetailField.vue +0 -142
- package/components/Detail/DetailLangSwitch.vue +0 -72
- package/components/Detail/defaults.js +0 -57
- package/components/DropArea.vue +0 -250
- package/components/List/List.vue +0 -254
- package/components/List/ListActions.vue +0 -164
- package/components/List/ListFilters.vue +0 -334
- package/components/List/ListHead.vue +0 -67
- package/components/List/ListQuickEdit.vue +0 -302
- package/components/List/ListTable.vue +0 -406
- package/components/List/ListTabs.vue +0 -65
- package/components/Login.vue +0 -124
- package/components/Logo.vue +0 -79
- package/components/LogoutButton.vue +0 -39
- package/components/MediaManager/MediaEditor.vue +0 -309
- package/components/MediaManager/MediaFolders.vue +0 -263
- package/components/MediaManager/MediaGallery.vue +0 -206
- package/components/MediaManager/MediaManager.vue +0 -233
- package/components/MediaManager/MediaManagerDialog.vue +0 -96
- package/components/MediaManager/MediaPreview.vue +0 -180
- package/components/MediaManager/MediaUploader.vue +0 -165
- package/components/RootComponents.vue +0 -25
- package/components/SnackBar.vue +0 -70
- package/components/fields/DateField.vue +0 -74
- package/components/fields/FksField.vue +0 -60
- package/components/fields/MediaField.vue +0 -213
- package/components/fields/MediaM2mField.vue +0 -243
- package/components/fields/SeoPreview.vue +0 -89
- package/components/fields/wygEditor/defaults.js +0 -55
- package/components/fields/wygEditor/utils/events.js +0 -64
- package/components/fields/wygEditor/utils/mapomedia.plugin.js +0 -31
- package/components/fields/wygEditor/utils/script.injector.js +0 -29
- package/components/fields/wygEditor/wygEditor.vue +0 -196
- package/components/layout/Sidebar/Sidebar.vue +0 -80
- package/components/layout/Sidebar/SidebarFooter.vue +0 -71
- package/components/layout/Sidebar/SidebarList.vue +0 -44
- package/components/layout/Sidebar/SidebarListItem.vue +0 -144
- package/components/layout/Topbar/Topbar.vue +0 -27
- package/components/layout/routebuilder.js +0 -48
- package/defaults.js +0 -29
- package/layouts/default.vue +0 -21
- package/layouts/empty.vue +0 -6
- package/layouts/error.vue +0 -45
- package/module.js +0 -78
- package/pages/index.vue +0 -35
- package/pages/login.vue +0 -10
- package/static/favicon.ico +0 -0
|
@@ -1,566 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<!-- Use this to override the title of the detail component. -->
|
|
4
|
-
<slot name="title" v-bind="slotBindings">
|
|
5
|
-
<!-- `<h1> "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
|
-
</v-row>
|
|
9
|
-
</slot>
|
|
10
|
-
<v-form ref="form">
|
|
11
|
-
<v-row>
|
|
12
|
-
<v-col cols="12" md="8">
|
|
13
|
-
<!-- Use this to add content at the top of the central layout. -->
|
|
14
|
-
<slot name="body.top" v-bind="slotBindings"></slot>
|
|
15
|
-
<!-- Use this to override the Language Switch panel. -->
|
|
16
|
-
<slot name="body.lang" v-bind="slotBindings">
|
|
17
|
-
<!-- [`DetailLangSwitch`](/components/detail/DetailLangSwitch/) -->
|
|
18
|
-
<DetailLangSwitch
|
|
19
|
-
v-if="langs && langs.length > 1"
|
|
20
|
-
class="mb-4"
|
|
21
|
-
v-model="currentLang"
|
|
22
|
-
:langs="langs"
|
|
23
|
-
:errors="errors"
|
|
24
|
-
/></slot>
|
|
25
|
-
<!-- Use this to add content under the Language Switch panel. -->
|
|
26
|
-
<slot name="body.top.underlang" v-bind="slotBindings"></slot>
|
|
27
|
-
<!-- Use this to override the content of the main body. -->
|
|
28
|
-
<slot name="body" v-bind="slotBindings">
|
|
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"
|
|
36
|
-
>
|
|
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>
|
|
80
|
-
</div>
|
|
81
|
-
</slot>
|
|
82
|
-
<!-- Use this to add content under the main body. -->
|
|
83
|
-
<slot name="body.bottom" v-bind="slotBindings"></slot>
|
|
84
|
-
</v-col>
|
|
85
|
-
<v-col cols="12" md="4">
|
|
86
|
-
<div class="d-flex flex-column" :style="stickySide">
|
|
87
|
-
<!-- Use this to add content on the top of the sidebar button panel. -->
|
|
88
|
-
<slot name="side.buttons.top" v-bind="slotBindings"></slot>
|
|
89
|
-
<!-- Use this to override the the sidebar button panel. -->
|
|
90
|
-
<slot name="side.buttons" v-bind="slotBindings">
|
|
91
|
-
<!-- Save, Save and continue, Back, and Delete buttons. -->
|
|
92
|
-
<div class="mt-4 mt-md-0 mb-md-4 mb-0 order-1 order-md-0">
|
|
93
|
-
<!-- Use this to override the Save button. -->
|
|
94
|
-
<slot name="button.save" v-bind="slotBindings">
|
|
95
|
-
<!-- The Save button. -->
|
|
96
|
-
<v-btn :disabled="isReadonly" class="mb-2" tile block @click="saveItem(true)">{{
|
|
97
|
-
isNew ? "Create" : "Save"
|
|
98
|
-
}}</v-btn>
|
|
99
|
-
</slot>
|
|
100
|
-
<!-- Use this to override the Save and continue button. -->
|
|
101
|
-
<slot name="button.savecontinue" v-bind="slotBindings">
|
|
102
|
-
<!-- The Save and continue button. -->
|
|
103
|
-
<v-btn :disabled="isReadonly" class="mb-2" tile block @click="saveItem(false)"
|
|
104
|
-
>{{ isNew ? "Create" : "Save" }} and continue</v-btn
|
|
105
|
-
>
|
|
106
|
-
</slot>
|
|
107
|
-
<!-- Use this to override the Back button. -->
|
|
108
|
-
<slot name="button.back" v-bind="slotBindings">
|
|
109
|
-
<!-- The Back button. -->
|
|
110
|
-
<v-btn class="mb-2" tile block @click="$router.back()"
|
|
111
|
-
>Back</v-btn
|
|
112
|
-
>
|
|
113
|
-
</slot>
|
|
114
|
-
<!-- Use this to override the Delete button. -->
|
|
115
|
-
<slot name="button.delete" v-bind="slotBindings">
|
|
116
|
-
<!-- The Delete button. -->
|
|
117
|
-
<v-btn
|
|
118
|
-
v-if="!isNew"
|
|
119
|
-
class="mb-2"
|
|
120
|
-
color="error"
|
|
121
|
-
tile
|
|
122
|
-
block
|
|
123
|
-
:disabled="!canDelete"
|
|
124
|
-
@click="deleteItem"
|
|
125
|
-
>Delete</v-btn
|
|
126
|
-
>
|
|
127
|
-
</slot>
|
|
128
|
-
</div>
|
|
129
|
-
</slot>
|
|
130
|
-
<!-- Use this to add content on the top of the sidebar fields (or under sidebar buttons). -->
|
|
131
|
-
<slot name="side.top" v-bind="slotBindings"></slot>
|
|
132
|
-
<div class="row">
|
|
133
|
-
<div
|
|
134
|
-
class="col-12"
|
|
135
|
-
:class="field.class"
|
|
136
|
-
v-for="(field, index) in sideFields"
|
|
137
|
-
:key="index"
|
|
138
|
-
>
|
|
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>
|
|
181
|
-
</div>
|
|
182
|
-
<!-- Use this to add content under the sidebar fields. -->
|
|
183
|
-
<slot name="side.bottom" v-bind="slotBindings"></slot>
|
|
184
|
-
</div>
|
|
185
|
-
</v-col>
|
|
186
|
-
</v-row>
|
|
187
|
-
</v-form>
|
|
188
|
-
</div>
|
|
189
|
-
</template>
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
<script>
|
|
193
|
-
/**
|
|
194
|
-
* The purpose of this component is to provide you with a very quick way to create an edit page for a payload to send to the server.
|
|
195
|
-
* A use case example could be "build a page that allows you to change the specifications of a product for an ecommerce".<br> <h4>Index:</h4> [[toc]]
|
|
196
|
-
*/
|
|
197
|
-
export default {
|
|
198
|
-
name: "Detail",
|
|
199
|
-
data() {
|
|
200
|
-
return {
|
|
201
|
-
model: {},
|
|
202
|
-
currentLang: null,
|
|
203
|
-
errors: null
|
|
204
|
-
};
|
|
205
|
-
},
|
|
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
|
-
},
|
|
217
|
-
// The main configuration that determines the arrangement of the fields in the detail layout.
|
|
218
|
-
fields: {
|
|
219
|
-
// [`DetailConfiguration`](#detailconfiguration)
|
|
220
|
-
type: Object | Array,
|
|
221
|
-
required: true
|
|
222
|
-
},
|
|
223
|
-
// A list of languages into which the payload needs to be translated.
|
|
224
|
-
languages: {
|
|
225
|
-
type: Array,
|
|
226
|
-
default: () => []
|
|
227
|
-
},
|
|
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.
|
|
229
|
-
endpoint: {
|
|
230
|
-
type: String,
|
|
231
|
-
default: null
|
|
232
|
-
},
|
|
233
|
-
// The identifier of the object you need to retrieve and edit. It can be "new" if you need to create a new payload.
|
|
234
|
-
identifier: {
|
|
235
|
-
// `String|Number`.
|
|
236
|
-
type: String | Number,
|
|
237
|
-
default: "new"
|
|
238
|
-
},
|
|
239
|
-
// The title of the detail page.
|
|
240
|
-
modelName: String,
|
|
241
|
-
// This determines the style of the sidebar. If set to true the sidebar will remain sticky during the scroll.
|
|
242
|
-
sticky: {
|
|
243
|
-
type: Boolean,
|
|
244
|
-
default: true
|
|
245
|
-
}
|
|
246
|
-
},
|
|
247
|
-
methods: {
|
|
248
|
-
saveItem(back = false) {
|
|
249
|
-
this.errors = null;
|
|
250
|
-
this.$refs.form?.resetValidation();
|
|
251
|
-
this.crud
|
|
252
|
-
.updateOrCreate(this.model)
|
|
253
|
-
.then(() => back && this.$router.back())
|
|
254
|
-
.catch(error => {
|
|
255
|
-
this.errors =
|
|
256
|
-
(error.response.status == 400 && error.response.data) || null;
|
|
257
|
-
this.$mapo.$snack.open({
|
|
258
|
-
message: error.response?.data?.detail || "Something whent bad, please try again later...",
|
|
259
|
-
color: "error"
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
},
|
|
263
|
-
deleteItem() {
|
|
264
|
-
this.$mapo.$confirm
|
|
265
|
-
.open({
|
|
266
|
-
title: "Delete",
|
|
267
|
-
question: "Are you sure you want to delete this item?",
|
|
268
|
-
approveButton: { text: "Delete", attrs: { color: "red", text: true } }
|
|
269
|
-
})
|
|
270
|
-
.then(res => {
|
|
271
|
-
if (res) {
|
|
272
|
-
this.crud
|
|
273
|
-
.delete(this.identifier)
|
|
274
|
-
.then(() => this.$router.back())
|
|
275
|
-
.catch(error =>
|
|
276
|
-
this.$mapo.$snack.open({
|
|
277
|
-
message: error.response?.data?.detail || "Something whent bad, please try again later...",
|
|
278
|
-
color: "error"
|
|
279
|
-
})
|
|
280
|
-
);
|
|
281
|
-
}
|
|
282
|
-
});
|
|
283
|
-
},
|
|
284
|
-
initLang(lang = this.currentLang) {
|
|
285
|
-
if (lang && !this.model.translations) {
|
|
286
|
-
this.model.translations = {};
|
|
287
|
-
}
|
|
288
|
-
if (lang && !this.model.translations[lang]) {
|
|
289
|
-
this.model.translations[lang] = {};
|
|
290
|
-
}
|
|
291
|
-
},
|
|
292
|
-
parseConf(field, i) {
|
|
293
|
-
const conf = typeof field === "string" ? { value: field } : field;
|
|
294
|
-
conf.value = conf.value || "";
|
|
295
|
-
conf.value = conf.value.replace(new RegExp(`^translations\.(${this.langs.join("|")})\.?`), "");
|
|
296
|
-
conf.slotName = `fields.${conf.value || i}`;
|
|
297
|
-
if (this.currentLang && !field.synci18n) {
|
|
298
|
-
const base = `translations.${this.currentLang}`;
|
|
299
|
-
conf.value = (conf.value && `${base}.${conf.value}`) || base;
|
|
300
|
-
}
|
|
301
|
-
if (this.isReadonly){
|
|
302
|
-
conf.attrs = {...conf.attrs, readonly: true}
|
|
303
|
-
}
|
|
304
|
-
return conf;
|
|
305
|
-
},
|
|
306
|
-
mapConf(fields) {
|
|
307
|
-
const icon = "mdi-cube-outline";
|
|
308
|
-
const parseGroup = group =>
|
|
309
|
-
typeof group === "string"
|
|
310
|
-
? { name: group, icon }
|
|
311
|
-
: { ...group, icon: group.icon !== undefined ? group.icon : icon };
|
|
312
|
-
return fields.map((f, i) =>
|
|
313
|
-
f.group
|
|
314
|
-
? { group: parseGroup(f.group), fields: this.mapConf(f.fields) }
|
|
315
|
-
: this.parseConf(f, i)
|
|
316
|
-
);
|
|
317
|
-
}
|
|
318
|
-
},
|
|
319
|
-
watch: {
|
|
320
|
-
currentLang(val) {
|
|
321
|
-
this.initLang();
|
|
322
|
-
// Fired when the current language changes.
|
|
323
|
-
// @arg Emits the language name as a string.
|
|
324
|
-
this.$emit("update:lang", val);
|
|
325
|
-
},
|
|
326
|
-
model(val) {
|
|
327
|
-
// Fired when the v-model changes.
|
|
328
|
-
// @arg Emits the entire payload modified.
|
|
329
|
-
this.$emit("input", val);
|
|
330
|
-
},
|
|
331
|
-
lang(val) {
|
|
332
|
-
if (val && this.langs.includes(val)) {
|
|
333
|
-
this.currentLang = val;
|
|
334
|
-
}
|
|
335
|
-
},
|
|
336
|
-
value(val) {
|
|
337
|
-
if (val) {
|
|
338
|
-
this.model = val;
|
|
339
|
-
this.initLang();
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
},
|
|
343
|
-
computed: {
|
|
344
|
-
crud() {
|
|
345
|
-
return this.$mapo.$api.crud(this.endpoint);
|
|
346
|
-
},
|
|
347
|
-
isReadonly() {
|
|
348
|
-
if (this.$mapo.$auth.routeMiddlewares.includes("permissions")){
|
|
349
|
-
return !this.$mapo.$auth.user.permissions.includes(this.isNew ? "add" : "change")
|
|
350
|
-
}
|
|
351
|
-
return false
|
|
352
|
-
},
|
|
353
|
-
canDelete() {
|
|
354
|
-
if (this.$mapo.$auth.routeMiddlewares.includes("permissions")){
|
|
355
|
-
return this.$mapo.$auth.user.permissions.includes("delete")
|
|
356
|
-
}
|
|
357
|
-
return true
|
|
358
|
-
},
|
|
359
|
-
mainFields() {
|
|
360
|
-
return this.mapConf(
|
|
361
|
-
this.fields instanceof Array ? this.fields : this.fields.main || []
|
|
362
|
-
);
|
|
363
|
-
},
|
|
364
|
-
sideFields() {
|
|
365
|
-
return this.mapConf(
|
|
366
|
-
(this.fields instanceof Object && this.fields.sidenav) || []
|
|
367
|
-
);
|
|
368
|
-
},
|
|
369
|
-
isNew() {
|
|
370
|
-
return this.identifier && this.identifier == "new";
|
|
371
|
-
},
|
|
372
|
-
loading() {
|
|
373
|
-
if (this.identifier === "new") {
|
|
374
|
-
return false;
|
|
375
|
-
}
|
|
376
|
-
return !Object.keys(this.model).length;
|
|
377
|
-
},
|
|
378
|
-
langs() {
|
|
379
|
-
return (
|
|
380
|
-
this.model?.lang_info?.site_languages.map(l => l.id) || this.languages
|
|
381
|
-
);
|
|
382
|
-
},
|
|
383
|
-
slotBindings() {
|
|
384
|
-
return {
|
|
385
|
-
model: this.model,
|
|
386
|
-
currentLang: this.currentLang,
|
|
387
|
-
crud: this.crud,
|
|
388
|
-
isNew: this.isNew,
|
|
389
|
-
langs: this.langs,
|
|
390
|
-
loading: this.loading,
|
|
391
|
-
form: this.$refs.form,
|
|
392
|
-
saveItem: this.saveItem,
|
|
393
|
-
deleteItem: this.deleteItem
|
|
394
|
-
};
|
|
395
|
-
},
|
|
396
|
-
stickySide() {
|
|
397
|
-
return this.sticky
|
|
398
|
-
? {
|
|
399
|
-
position: "sticky",
|
|
400
|
-
top: "60px"
|
|
401
|
-
}
|
|
402
|
-
: {};
|
|
403
|
-
}
|
|
404
|
-
},
|
|
405
|
-
mounted() {
|
|
406
|
-
if (this.identifier && this.identifier !== "new") {
|
|
407
|
-
this.crud.detail(this.identifier).then(res => {
|
|
408
|
-
this.model = res;
|
|
409
|
-
this.initLang();
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
};
|
|
414
|
-
</script>
|
|
415
|
-
|
|
416
|
-
<docs>
|
|
417
|
-
|
|
418
|
-
## DetailConfiguration
|
|
419
|
-
|
|
420
|
-
The DetailConfiguration determines the behavior of the main form and is an `Array` of [`FieldConfiguration`](#fieldconfiguration).
|
|
421
|
-
Each field configuration represents a field of the form.
|
|
422
|
-
The configuration can also consist of an object with two keys `{ main sidenav }`.
|
|
423
|
-
Each key is an `Array` of [`FieldConfiguration`](#fieldconfiguration) and will modify a different part of the component:
|
|
424
|
-
- The main body
|
|
425
|
-
- The sidebar
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
### FieldConfiguration
|
|
429
|
-
|
|
430
|
-
The `FieldConfiguration` is a `String` containing the dottedPath of a value inside the payload we want to modify.
|
|
431
|
-
So, for example, if we have the payload: `{ image: { name: "...", url: "..." } }` we can modify the image name using the dottedPath `"image.name"`.
|
|
432
|
-
|
|
433
|
-
The default component used to render a field of a form is a [`v-text-field`](https://vuetifyjs.com/en/components/text-fields/).
|
|
434
|
-
If you want more control over the generated component you can use an `Object` with this attributes:
|
|
435
|
-
|
|
436
|
-
|Name|Description|Type|Required|Default|
|
|
437
|
-
|---|---|---|---|---|
|
|
438
|
-
|value|The dottedPath of the value we want to modify.|`String`|`true`|-|
|
|
439
|
-
|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`|
|
|
440
|
-
|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`|
|
|
441
|
-
|accessor|[`Accessor`](#accessor) object to specify the setter and the getter of the field.|`Object`|`false`|`{set: x=>x, get: x=>x}`|
|
|
442
|
-
|attrs|The attributes that will be passed to the component.|`Object`|`false`|-|
|
|
443
|
-
|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`|-|
|
|
444
|
-
|
|
445
|
-
#### Accessor
|
|
446
|
-
|
|
447
|
-
The accessor object contains two funcition `get` and `set`. Each function will be called with a ctx as argument. The ctx contains the val (value) and the model (the payload).
|
|
448
|
-
If you want to change the value as it is being processed by the component, you can set one or both of the accessors.
|
|
449
|
-
Each function must return the processed value.
|
|
450
|
-
|
|
451
|
-
#### Field types
|
|
452
|
-
|
|
453
|
-
Here the list of the FieldConfiguration type association.
|
|
454
|
-
|
|
455
|
-
- `text` ==> [v-text-field](https://vuetifyjs.com/en/components/text-fields/),
|
|
456
|
-
- `select` ==> [v-select](https://vuetifyjs.com/en/components/selects/),
|
|
457
|
-
- `date` ==> [date-field](/components/fields/DateField/),
|
|
458
|
-
- `textarea` ==> [v-textarea](https://vuetifyjs.com/en/components/textareas/),
|
|
459
|
-
- `switch` ==> [v-switch](https://vuetifyjs.com/en/components/switches/),
|
|
460
|
-
- `slider` ==> [v-slider](https://vuetifyjs.com/en/components/sliders/),
|
|
461
|
-
- `file` ==> [v-file-input](https://vuetifyjs.com/en/components/file-inputs/),
|
|
462
|
-
- `editor` ==> [wyg-editor](/components/fields/wygEditor/wygEditor/),
|
|
463
|
-
- `media` ==> [media-field](/components/fields/MediaField/),
|
|
464
|
-
- `m2m` or `fks` ==> [fks-field](/components/fields/FksField/),
|
|
465
|
-
- `mediaList` ==> [media-fks-field](/components/fields/MediaM2mField/)
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
#### Example of a [`FieldConfiguration`](#fieldconfiguration):
|
|
469
|
-
|
|
470
|
-
```js
|
|
471
|
-
{
|
|
472
|
-
value: "pubblicationDate",
|
|
473
|
-
accessor: {
|
|
474
|
-
set: ({ val }) => val && new Date(val).toISOString()
|
|
475
|
-
},
|
|
476
|
-
type: "date",
|
|
477
|
-
synci18n: true,
|
|
478
|
-
attrs: { color: "purple" }
|
|
479
|
-
}
|
|
480
|
-
```
|
|
481
|
-
|
|
482
|
-
### FieldGroup
|
|
483
|
-
|
|
484
|
-
You can use this mixed with `FieldConfiguration` to group multiple fields in one card with a title and an icon.
|
|
485
|
-
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).
|
|
486
|
-
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.
|
|
487
|
-
|
|
488
|
-
<br><br>
|
|
489
|
-
|
|
490
|
-
## Live Demo
|
|
491
|
-
|
|
492
|
-
<br>
|
|
493
|
-
|
|
494
|
-
::: warning LIVE DEMO 🎉🎉🎉
|
|
495
|
-
This is an interactive example. You can play with it but remember that all http features are disabled since there is no backend server.
|
|
496
|
-
:::
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
::: demo
|
|
500
|
-
<template>
|
|
501
|
-
<v-app>
|
|
502
|
-
<Detail
|
|
503
|
-
endpoint="api/camomilla/articles"
|
|
504
|
-
identifier="new"
|
|
505
|
-
:fields="fields"
|
|
506
|
-
:languages="['it', 'en', 'de']"
|
|
507
|
-
modelName="article"
|
|
508
|
-
/>
|
|
509
|
-
</v-app>
|
|
510
|
-
</template>
|
|
511
|
-
|
|
512
|
-
<script>
|
|
513
|
-
export default {
|
|
514
|
-
data: () => ({
|
|
515
|
-
fields: {
|
|
516
|
-
main: [
|
|
517
|
-
{ value: "identifier", synci18n: true },
|
|
518
|
-
{ value: "content", type: "editor" },
|
|
519
|
-
{
|
|
520
|
-
group: "Seo",
|
|
521
|
-
fields: [
|
|
522
|
-
"title",
|
|
523
|
-
{ value: "description", type: "textarea" },
|
|
524
|
-
"permalink",
|
|
525
|
-
{ type: "seoPreview" }
|
|
526
|
-
]
|
|
527
|
-
}
|
|
528
|
-
],
|
|
529
|
-
sidenav: [
|
|
530
|
-
{
|
|
531
|
-
group: "Status",
|
|
532
|
-
fields: [
|
|
533
|
-
{ value: "trash", type: "switch", synci18n: true },
|
|
534
|
-
{
|
|
535
|
-
value: "status",
|
|
536
|
-
type: "select",
|
|
537
|
-
attrs: {
|
|
538
|
-
items: [
|
|
539
|
-
{ text: "Draft", value: "DRF" },
|
|
540
|
-
{ text: "Published", value: "PUB" },
|
|
541
|
-
{ text: "Trash", value: "TRS" }
|
|
542
|
-
]
|
|
543
|
-
},
|
|
544
|
-
synci18n: true
|
|
545
|
-
},
|
|
546
|
-
{
|
|
547
|
-
value: "pubblication_date",
|
|
548
|
-
accessor: {
|
|
549
|
-
set: ({ val }) => val && new Date(val).toISOString()
|
|
550
|
-
},
|
|
551
|
-
type: "date",
|
|
552
|
-
synci18n: true
|
|
553
|
-
}
|
|
554
|
-
]
|
|
555
|
-
},
|
|
556
|
-
{ value: "highlight_image", type: "media", synci18n: true }
|
|
557
|
-
]
|
|
558
|
-
}
|
|
559
|
-
})
|
|
560
|
-
};
|
|
561
|
-
</script>
|
|
562
|
-
:::
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
</docs>
|