@mapomodule/uikit 1.0.0-alpha.2 → 1.0.0-alpha.22
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 +406 -0
- package/components/Detail/Detail.vue +288 -260
- package/components/Detail/DetailLangSwitch.vue +1 -1
- package/components/DropArea.vue +3 -3
- package/components/Form/Form.vue +224 -0
- package/components/Form/FormField.vue +185 -0
- package/components/Form/FormGroup.vue +88 -0
- package/components/Form/FormTabs.vue +134 -0
- package/components/Form/defaults.js +58 -0
- package/components/{fields → Form/fields}/DateField.vue +9 -3
- package/components/Form/fields/FileField.vue +125 -0
- package/components/Form/fields/FksField.vue +88 -0
- package/components/{fields → Form/fields}/MediaField.vue +36 -6
- package/components/{fields → Form/fields}/MediaM2mField.vue +8 -3
- package/components/Form/fields/Repeater.vue +562 -0
- package/components/Form/fields/SeoPreview.vue +89 -0
- package/components/{fields/TinyMce → Form/fields/wygEditor}/defaults.js +7 -5
- package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/events.js +0 -0
- package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/mapomedia.plugin.js +7 -6
- package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/script.injector.js +0 -0
- package/components/Form/fields/wygEditor/wygEditor.vue +256 -0
- 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 +128 -59
- package/components/List/ListTable.vue +293 -80
- 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/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/module.js +1 -1
- package/package.json +5 -4
- package/pages/index.vue +1 -2
- package/components/Detail/DetailField.vue +0 -129
- package/components/Detail/defaults.js +0 -50
- 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,48 +40,23 @@
|
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
}"
|
|
67
|
-
>
|
|
68
|
-
<DetailField v-model="model" :conf="field" :errors="errors" />
|
|
69
|
-
</slot>
|
|
70
|
-
</div>
|
|
43
|
+
<Form
|
|
44
|
+
v-model="model"
|
|
45
|
+
:currentLang="currentLang"
|
|
46
|
+
:languages="langs"
|
|
47
|
+
:errors="errors"
|
|
48
|
+
:fields="mainFields"
|
|
49
|
+
:moreSlotBindings="slotBindings"
|
|
50
|
+
>
|
|
51
|
+
<template v-for="(_, slot) in $slots" :slot="slot">
|
|
52
|
+
<!-- @vuese-ignore -->
|
|
53
|
+
<slot :name="slot"></slot>
|
|
54
|
+
</template>
|
|
55
|
+
<template v-for="(_, slot) in $scopedSlots" v-slot:[slot]="props">
|
|
56
|
+
<!-- @vuese-ignore -->
|
|
57
|
+
<slot :name="slot" v-bind="props" />
|
|
58
|
+
</template>
|
|
59
|
+
</Form>
|
|
71
60
|
</slot>
|
|
72
61
|
<!-- Use this to add content under the main body. -->
|
|
73
62
|
<slot name="body.bottom" v-bind="slotBindings"></slot>
|
|
@@ -83,21 +72,21 @@
|
|
|
83
72
|
<!-- Use this to override the Save button. -->
|
|
84
73
|
<slot name="button.save" v-bind="slotBindings">
|
|
85
74
|
<!-- The Save button. -->
|
|
86
|
-
<v-btn class="mb-2" tile block @click="saveItem(true)">{{
|
|
75
|
+
<v-btn v-show="canGoBack" :disabled="isReadonly" class="mb-2" tile block @click="saveItem(true)">{{
|
|
87
76
|
isNew ? "Create" : "Save"
|
|
88
77
|
}}</v-btn>
|
|
89
78
|
</slot>
|
|
90
79
|
<!-- Use this to override the Save and continue button. -->
|
|
91
80
|
<slot name="button.savecontinue" v-bind="slotBindings">
|
|
92
81
|
<!-- The Save and continue button. -->
|
|
93
|
-
<v-btn class="mb-2" tile block @click="saveItem(false)"
|
|
82
|
+
<v-btn :disabled="isReadonly" class="mb-2" tile block @click="saveItem(false)"
|
|
94
83
|
>{{ isNew ? "Create" : "Save" }} and continue</v-btn
|
|
95
84
|
>
|
|
96
85
|
</slot>
|
|
97
86
|
<!-- Use this to override the Back button. -->
|
|
98
87
|
<slot name="button.back" v-bind="slotBindings">
|
|
99
88
|
<!-- The Back button. -->
|
|
100
|
-
<v-btn class="mb-2" tile block @click="
|
|
89
|
+
<v-btn v-show="canGoBack" class="mb-2" tile block @click="back"
|
|
101
90
|
>Back</v-btn
|
|
102
91
|
>
|
|
103
92
|
</slot>
|
|
@@ -110,6 +99,7 @@
|
|
|
110
99
|
color="error"
|
|
111
100
|
tile
|
|
112
101
|
block
|
|
102
|
+
:disabled="!canDelete"
|
|
113
103
|
@click="deleteItem"
|
|
114
104
|
>Delete</v-btn
|
|
115
105
|
>
|
|
@@ -118,55 +108,45 @@
|
|
|
118
108
|
</slot>
|
|
119
109
|
<!-- Use this to add content on the top of the sidebar fields (or under sidebar buttons). -->
|
|
120
110
|
<slot name="side.top" v-bind="slotBindings"></slot>
|
|
121
|
-
<
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
}"
|
|
157
|
-
>
|
|
158
|
-
<DetailField v-model="model" :conf="field" :errors="errors" />
|
|
159
|
-
</slot>
|
|
160
|
-
</div>
|
|
111
|
+
<Form
|
|
112
|
+
v-model="model"
|
|
113
|
+
:currentLang="currentLang"
|
|
114
|
+
:languages="langs"
|
|
115
|
+
:errors="errors"
|
|
116
|
+
:fields="sideFields"
|
|
117
|
+
:moreSlotBindings="slotBindings"
|
|
118
|
+
>
|
|
119
|
+
<template v-for="(_, slot) in $slots" :slot="slot">
|
|
120
|
+
<!-- @vuese-ignore -->
|
|
121
|
+
<slot :name="slot"></slot>
|
|
122
|
+
</template>
|
|
123
|
+
<template v-for="(_, slot) in $scopedSlots" v-slot:[slot]="props">
|
|
124
|
+
<!-- @vuese-ignore -->
|
|
125
|
+
<slot :name="slot" v-bind="props" />
|
|
126
|
+
</template>
|
|
127
|
+
</Form>
|
|
161
128
|
<!-- Use this to add content under the sidebar fields. -->
|
|
162
129
|
<slot name="side.bottom" v-bind="slotBindings"></slot>
|
|
163
130
|
</div>
|
|
164
131
|
</v-col>
|
|
165
132
|
</v-row>
|
|
166
133
|
</v-form>
|
|
167
|
-
</
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
168
136
|
</template>
|
|
169
137
|
|
|
138
|
+
<style lang="scss" scoped>
|
|
139
|
+
.detail-component-loading {
|
|
140
|
+
position: absolute;
|
|
141
|
+
top: 50%;
|
|
142
|
+
transform: translateY(-50%);
|
|
143
|
+
width: 100%;
|
|
144
|
+
display: flex;
|
|
145
|
+
flex-direction: column;
|
|
146
|
+
justify-content: center;
|
|
147
|
+
align-items: center;
|
|
148
|
+
}
|
|
149
|
+
</style>
|
|
170
150
|
|
|
171
151
|
<script>
|
|
172
152
|
/**
|
|
@@ -174,166 +154,203 @@
|
|
|
174
154
|
* 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]]
|
|
175
155
|
*/
|
|
176
156
|
export default {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
props: {
|
|
186
|
-
// The main configuration that determines the arrangement of the fields in the detail layout.
|
|
187
|
-
fields: {
|
|
188
|
-
// [`DetailConfiguration`](#detailconfiguration)
|
|
189
|
-
type: Object | Array,
|
|
190
|
-
required: true
|
|
191
|
-
},
|
|
192
|
-
// A list of languages into which the payload needs to be translated.
|
|
193
|
-
languages: {
|
|
194
|
-
type: Array,
|
|
195
|
-
default: () => []
|
|
196
|
-
},
|
|
197
|
-
// 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: String,
|
|
199
|
-
// The identifier of the object you need to retrieve and edit. It can be "new" if you need to create a new payload.
|
|
200
|
-
identifier: {
|
|
201
|
-
// `String|Number`.
|
|
202
|
-
type: String | Number,
|
|
203
|
-
default: "new"
|
|
157
|
+
name: "Detail",
|
|
158
|
+
data() {
|
|
159
|
+
return {
|
|
160
|
+
model: {},
|
|
161
|
+
modelLanguages: [],
|
|
162
|
+
currentLang: this.lang,
|
|
163
|
+
errors: null
|
|
164
|
+
};
|
|
204
165
|
},
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
166
|
+
props: {
|
|
167
|
+
// V-model of the object we are editing.
|
|
168
|
+
value: {
|
|
169
|
+
type: Object,
|
|
170
|
+
required: false
|
|
171
|
+
},
|
|
172
|
+
// Set the current lang to value.
|
|
173
|
+
lang: {
|
|
174
|
+
type: String,
|
|
175
|
+
required: false
|
|
176
|
+
},
|
|
177
|
+
// The main configuration that determines the arrangement of the fields in the detail layout.
|
|
178
|
+
fields: {
|
|
179
|
+
// [`DetailConfiguration`](#detailconfiguration)
|
|
180
|
+
type: Object | Array,
|
|
181
|
+
required: true
|
|
182
|
+
},
|
|
183
|
+
// A list of languages into which the payload needs to be translated.
|
|
184
|
+
languages: {
|
|
185
|
+
type: Array,
|
|
186
|
+
default: () => []
|
|
187
|
+
},
|
|
188
|
+
// 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.
|
|
189
|
+
endpoint: {
|
|
190
|
+
type: String,
|
|
191
|
+
default: null
|
|
192
|
+
},
|
|
193
|
+
// The identifier of the object you need to retrieve and edit. It can be "new" if you need to create a new payload.
|
|
194
|
+
identifier: {
|
|
195
|
+
// `String|Number`.
|
|
196
|
+
type: String | Number,
|
|
197
|
+
default: "new"
|
|
198
|
+
},
|
|
199
|
+
// The title of the detail page.
|
|
200
|
+
modelName: String,
|
|
201
|
+
// This determines the style of the sidebar. If set to true the sidebar will remain sticky during the scroll.
|
|
202
|
+
sticky: {
|
|
203
|
+
type: Boolean,
|
|
204
|
+
default: true
|
|
205
|
+
},
|
|
206
|
+
// 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.
|
|
207
|
+
multipart: {
|
|
208
|
+
type: String,
|
|
209
|
+
default: "auto",
|
|
210
|
+
validator: function (value) {
|
|
211
|
+
// The value must match one of these strings
|
|
212
|
+
return ["auto", "force", "disable"].indexOf(value) !== -1;
|
|
213
|
+
},
|
|
214
|
+
},
|
|
228
215
|
},
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
.then(res => {
|
|
237
|
-
if (res) {
|
|
216
|
+
methods: {
|
|
217
|
+
back() {
|
|
218
|
+
this.$nuxt.context?.from?.name == "login" ? this.$router.go(-3) : this.$router.back();
|
|
219
|
+
},
|
|
220
|
+
saveItem(back = false) {
|
|
221
|
+
this.errors = null;
|
|
222
|
+
this.$refs.form?.resetValidation();
|
|
238
223
|
this.crud
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
224
|
+
.updateOrCreate(this.model, {}, { multipart: this.multipart })
|
|
225
|
+
.then((resp) => { back ? this.back() : this.model = resp; })
|
|
226
|
+
.catch(error => {
|
|
227
|
+
this.errors =
|
|
228
|
+
(error.response.status == 400 && error.response.data) || null;
|
|
242
229
|
this.$mapo.$snack.open({
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
})
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
? { group: parseGroup(f.group), fields: this.mapConf(f.fields) }
|
|
268
|
-
: this.parseConf(f)
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
},
|
|
272
|
-
watch: {
|
|
273
|
-
currentLang(val) {
|
|
274
|
-
if (val && !this.model.translations) {
|
|
275
|
-
this.model.translations = {};
|
|
276
|
-
}
|
|
277
|
-
if (val && !this.model.translations[val]) {
|
|
278
|
-
this.model.translations[val] = {};
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
},
|
|
282
|
-
computed: {
|
|
283
|
-
crud() {
|
|
284
|
-
return this.$mapo.$api.crud(this.endpoint);
|
|
285
|
-
},
|
|
286
|
-
mainFields() {
|
|
287
|
-
return this.mapConf(
|
|
288
|
-
this.fields instanceof Array ? this.fields : this.fields.main || []
|
|
289
|
-
);
|
|
290
|
-
},
|
|
291
|
-
sideFields() {
|
|
292
|
-
return this.mapConf(
|
|
293
|
-
(this.fields instanceof Object && this.fields.sidenav) || []
|
|
294
|
-
);
|
|
295
|
-
},
|
|
296
|
-
isNew() {
|
|
297
|
-
return this.identifier && this.identifier == "new";
|
|
230
|
+
message: error.response?.data?.detail || "Something whent bad, please try again later...",
|
|
231
|
+
color: "error"
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
},
|
|
235
|
+
deleteItem() {
|
|
236
|
+
this.$mapo.$confirm
|
|
237
|
+
.open({
|
|
238
|
+
title: "Delete",
|
|
239
|
+
question: "Are you sure you want to delete this item?",
|
|
240
|
+
approveButton: { text: "Delete", attrs: { color: "red", text: true } }
|
|
241
|
+
})
|
|
242
|
+
.then(res => {
|
|
243
|
+
if (res) {
|
|
244
|
+
this.crud
|
|
245
|
+
.delete(this.identifier)
|
|
246
|
+
.then(() => this.back())
|
|
247
|
+
.catch(error => this.$mapo.$snack.open({
|
|
248
|
+
message: error.response?.data?.detail || "Something whent bad, please try again later...",
|
|
249
|
+
color: "error"
|
|
250
|
+
}));
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
},
|
|
298
254
|
},
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
255
|
+
watch: {
|
|
256
|
+
currentLang(val) {
|
|
257
|
+
// Fired when the current language changes.
|
|
258
|
+
// @arg Emits the language name as a string.
|
|
259
|
+
this.$emit("update:lang", val);
|
|
260
|
+
},
|
|
261
|
+
model(val) {
|
|
262
|
+
// Fired when the v-model changes.
|
|
263
|
+
// @arg Emits the entire payload modified.
|
|
264
|
+
this.$emit("input", val);
|
|
265
|
+
},
|
|
266
|
+
lang(val) {
|
|
267
|
+
if (val && this.langs.includes(val)) {
|
|
268
|
+
this.currentLang = val;
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
value(val) {
|
|
272
|
+
if (val) {
|
|
273
|
+
this.model = val;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
304
276
|
},
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
277
|
+
computed: {
|
|
278
|
+
canGoBack() {
|
|
279
|
+
if (typeof window !== "undefined") {
|
|
280
|
+
return this.$nuxt?.context?.from?.name !== "login" && window.history.length > 1 || window.history.length > 3;
|
|
281
|
+
}
|
|
282
|
+
return true;
|
|
283
|
+
},
|
|
284
|
+
crud() {
|
|
285
|
+
return this.$mapo.$api.crud(this.endpoint);
|
|
286
|
+
},
|
|
287
|
+
isReadonly() {
|
|
288
|
+
if (this.$mapo.$auth.routeMiddlewares.includes("permissions")) {
|
|
289
|
+
return !this.$mapo.$auth.user.permissions.includes(this.isNew ? "add" : "change");
|
|
290
|
+
}
|
|
291
|
+
return false;
|
|
292
|
+
},
|
|
293
|
+
canDelete() {
|
|
294
|
+
if (this.$mapo.$auth.routeMiddlewares.includes("permissions")) {
|
|
295
|
+
return this.$mapo.$auth.user.permissions.includes("delete");
|
|
296
|
+
}
|
|
297
|
+
return true;
|
|
298
|
+
},
|
|
299
|
+
mainFields() {
|
|
300
|
+
return this.fields instanceof Array ? this.fields : this.fields.main || [];
|
|
301
|
+
},
|
|
302
|
+
sideFields() {
|
|
303
|
+
return (this.fields instanceof Object && this.fields.sidenav) || [];
|
|
304
|
+
},
|
|
305
|
+
isNew() {
|
|
306
|
+
return this.identifier && this.identifier == "new";
|
|
307
|
+
},
|
|
308
|
+
loading() {
|
|
309
|
+
if (this.identifier === "new") {
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
return !Object.keys(this.model).length;
|
|
313
|
+
},
|
|
314
|
+
langs() {
|
|
315
|
+
return this.modelLanguages || this.languages;
|
|
316
|
+
},
|
|
317
|
+
slotBindings() {
|
|
318
|
+
return {
|
|
319
|
+
model: this.model,
|
|
320
|
+
errors: this.errors,
|
|
321
|
+
currentLang: this.currentLang,
|
|
322
|
+
crud: this.crud,
|
|
323
|
+
isNew: this.isNew,
|
|
324
|
+
langs: this.langs,
|
|
325
|
+
loading: this.loading,
|
|
326
|
+
form: this.$refs.form,
|
|
327
|
+
saveItem: this.saveItem,
|
|
328
|
+
deleteItem: this.deleteItem
|
|
329
|
+
};
|
|
330
|
+
},
|
|
331
|
+
stickySide() {
|
|
332
|
+
return this.sticky
|
|
333
|
+
? {
|
|
334
|
+
position: "sticky",
|
|
335
|
+
top: "60px"
|
|
336
|
+
}
|
|
337
|
+
: {};
|
|
338
|
+
}
|
|
309
339
|
},
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
340
|
+
mounted() {
|
|
341
|
+
if (this.identifier && this.identifier !== "new") {
|
|
342
|
+
this.crud.detail(this.identifier).then(res => {
|
|
343
|
+
this.model = res;
|
|
344
|
+
this.modelLanguages = this.model?.lang_info?.site_languages.map(l => l.id);
|
|
345
|
+
}).catch(error => {
|
|
346
|
+
this.$nuxt.error({ statusCode: error.response.status, message: error.response.data?.detail || "Ops some error occurred.." });
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
else if (this.value) {
|
|
350
|
+
this.model = this.value;
|
|
351
|
+
this.modelLanguages = this.model?.lang_info?.site_languages.map(l => l.id);
|
|
352
|
+
}
|
|
322
353
|
},
|
|
323
|
-
stickySide() {
|
|
324
|
-
return this.sticky
|
|
325
|
-
? {
|
|
326
|
-
position: "sticky",
|
|
327
|
-
top: "60px"
|
|
328
|
-
}
|
|
329
|
-
: {};
|
|
330
|
-
}
|
|
331
|
-
},
|
|
332
|
-
mounted() {
|
|
333
|
-
if (this.identifier && this.identifier !== "new") {
|
|
334
|
-
this.crud.detail(this.identifier).then(res => (this.model = res));
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
354
|
};
|
|
338
355
|
</script>
|
|
339
356
|
|
|
@@ -341,7 +358,7 @@ export default {
|
|
|
341
358
|
|
|
342
359
|
## DetailConfiguration
|
|
343
360
|
|
|
344
|
-
The DetailConfiguration determines the behavior of the main form and is an `Array` of [`FieldConfiguration`](#fieldconfiguration).
|
|
361
|
+
The DetailConfiguration determines the behavior of the main form and is an `Array` of [`FieldConfiguration`](#fieldconfiguration).
|
|
345
362
|
Each field configuration represents a field of the form.
|
|
346
363
|
The configuration can also consist of an object with two keys `{ main sidenav }`.
|
|
347
364
|
Each key is an `Array` of [`FieldConfiguration`](#fieldconfiguration) and will modify a different part of the component:
|
|
@@ -351,7 +368,7 @@ Each key is an `Array` of [`FieldConfiguration`](#fieldconfiguration) and will m
|
|
|
351
368
|
|
|
352
369
|
### FieldConfiguration
|
|
353
370
|
|
|
354
|
-
The `FieldConfiguration` is a `String` containing the dottedPath of a value inside the payload we want to modify.
|
|
371
|
+
The `FieldConfiguration` is a `String` containing the dottedPath of a value inside the payload we want to modify.
|
|
355
372
|
So, for example, if we have the payload: `{ image: { name: "...", url: "..." } }` we can modify the image name using the dottedPath `"image.name"`.
|
|
356
373
|
|
|
357
374
|
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 +376,12 @@ If you want more control over the generated component you can use an `Object` wi
|
|
|
359
376
|
|
|
360
377
|
|Name|Description|Type|Required|Default|
|
|
361
378
|
|---|---|---|---|---|
|
|
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`|-|
|
|
379
|
+
|value|The dottedPath of the value we want to modify.|`String`|`true`|-|
|
|
380
|
+
|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`|
|
|
381
|
+
|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`|
|
|
382
|
+
|accessor|[`Accessor`](#accessor) object to specify the setter and the getter of the field.|`Object`|`false`|`{set: x=>x, get: x=>x}`|
|
|
383
|
+
|attrs|The attributes that will be passed to the component.|`Object`|`false`|-|
|
|
384
|
+
|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
385
|
|
|
369
386
|
#### Accessor
|
|
370
387
|
|
|
@@ -374,19 +391,20 @@ Each function must return the processed value.
|
|
|
374
391
|
|
|
375
392
|
#### Field types
|
|
376
393
|
|
|
377
|
-
Here the list of the FieldConfiguration type association.
|
|
394
|
+
Here the list of the FieldConfiguration type association.
|
|
378
395
|
|
|
379
396
|
- `text` ==> [v-text-field](https://vuetifyjs.com/en/components/text-fields/),
|
|
380
397
|
- `select` ==> [v-select](https://vuetifyjs.com/en/components/selects/),
|
|
381
|
-
- `date` ==> [date-field](/components/fields/DateField/),
|
|
398
|
+
- `date` ==> [date-field](/components/Form/fields/DateField/),
|
|
382
399
|
- `textarea` ==> [v-textarea](https://vuetifyjs.com/en/components/textareas/),
|
|
383
400
|
- `switch` ==> [v-switch](https://vuetifyjs.com/en/components/switches/),
|
|
384
401
|
- `slider` ==> [v-slider](https://vuetifyjs.com/en/components/sliders/),
|
|
385
|
-
- `file` ==> [
|
|
386
|
-
- `editor` ==> [
|
|
387
|
-
- `media` ==> [media-field](/components/fields/MediaField/),
|
|
388
|
-
- `
|
|
389
|
-
- `
|
|
402
|
+
- `file` ==> [file-field](/components/Form/fields/FileField/),
|
|
403
|
+
- `editor` ==> [wyg-editor](/components/Form/fields/wygEditor/wygEditor/),
|
|
404
|
+
- `media` ==> [media-field](/components/Form/fields/MediaField/),
|
|
405
|
+
- `mediaList` ==> [media-m2m-field](/components/Form/fields/MediaM2mField/)
|
|
406
|
+
- `m2m` or `fks` ==> [fks-field](/components/Form/fields/FksField/),
|
|
407
|
+
- `repeater` ==> [repeater](/components/Form/fields/Repeater/),
|
|
390
408
|
|
|
391
409
|
|
|
392
410
|
#### Example of a [`FieldConfiguration`](#fieldconfiguration):
|
|
@@ -405,8 +423,8 @@ Here the list of the FieldConfiguration type association.
|
|
|
405
423
|
|
|
406
424
|
### FieldGroup
|
|
407
425
|
|
|
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).
|
|
426
|
+
You can use this mixed with `FieldConfiguration` to group multiple fields in one card with a title and an icon.
|
|
427
|
+
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
428
|
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
429
|
|
|
412
430
|
<br><br>
|
|
@@ -423,8 +441,9 @@ This is an interactive example. You can play with it but remember that all http
|
|
|
423
441
|
::: demo
|
|
424
442
|
<template>
|
|
425
443
|
<v-app>
|
|
444
|
+
<div class="d-flex justify-end"><ThemeToggle/></div>
|
|
426
445
|
<Detail
|
|
427
|
-
endpoint="api/
|
|
446
|
+
endpoint="api/articles"
|
|
428
447
|
identifier="new"
|
|
429
448
|
:fields="fields"
|
|
430
449
|
:languages="['it', 'en', 'de']"
|
|
@@ -440,12 +459,21 @@ export default {
|
|
|
440
459
|
main: [
|
|
441
460
|
{ value: "identifier", synci18n: true },
|
|
442
461
|
{ value: "content", type: "editor" },
|
|
462
|
+
{ value: "sections", type: "repeater", attrs: {
|
|
463
|
+
sortable: true,
|
|
464
|
+
fields: [
|
|
465
|
+
{ value: "title", class: "col-md-6" },
|
|
466
|
+
{ value: "subtitle", class: "col-md-6" },
|
|
467
|
+
{ value: "content", type: "textarea" },
|
|
468
|
+
]}
|
|
469
|
+
},
|
|
443
470
|
{
|
|
444
471
|
group: "Seo",
|
|
445
472
|
fields: [
|
|
446
473
|
"title",
|
|
447
474
|
{ value: "description", type: "textarea" },
|
|
448
475
|
"permalink",
|
|
476
|
+
{ type: "seoPreview" }
|
|
449
477
|
]
|
|
450
478
|
}
|
|
451
479
|
],
|
|
@@ -486,4 +514,4 @@ export default {
|
|
|
486
514
|
|
|
487
515
|
|
|
488
516
|
|
|
489
|
-
</docs>
|
|
517
|
+
</docs>
|