@mapomodule/uikit 1.0.0-alpha.21 → 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 +28 -0
- package/components/Detail/Detail.vue +230 -357
- package/components/Form/Form.vue +224 -0
- package/components/{Detail/DetailField.vue → Form/FormField.vue} +32 -15
- package/components/Form/FormGroup.vue +88 -0
- package/components/Form/FormTabs.vue +134 -0
- package/components/{Detail → Form}/defaults.js +0 -0
- package/components/{fields → Form/fields}/DateField.vue +0 -0
- package/components/{fields → Form/fields}/FileField.vue +0 -0
- package/components/{fields → Form/fields}/FksField.vue +0 -0
- package/components/{fields → Form/fields}/MediaField.vue +0 -0
- package/components/{fields → Form/fields}/MediaM2mField.vue +0 -0
- package/components/Form/fields/Repeater.vue +562 -0
- package/components/{fields → Form/fields}/SeoPreview.vue +0 -0
- package/components/{fields → Form/fields}/wygEditor/defaults.js +0 -0
- package/components/{fields → Form/fields}/wygEditor/utils/events.js +0 -0
- package/components/{fields → Form/fields}/wygEditor/utils/mapomedia.plugin.js +0 -0
- package/components/{fields → Form/fields}/wygEditor/utils/script.injector.js +0 -0
- package/components/{fields → Form/fields}/wygEditor/wygEditor.vue +0 -0
- package/components/List/ListQuickEdit.vue +17 -100
- package/components/List/ListTable.vue +4 -6
- package/module.js +1 -1
- package/package.json +3 -3
- package/components/fields/Repeater.vue +0 -338
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,34 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.0.0-alpha.22](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.21...v1.0.0-alpha.22) (2022-05-01)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* fix detail component slot bindings ([c4367a3](https://github.com/lotrekagency/mapo/commit/c4367a38336570e550024340725bca6da2fd2a06))
|
|
12
|
+
* fix form fields components discovery ([3f4fb0b](https://github.com/lotrekagency/mapo/commit/3f4fb0b3a5dc570c125f99f225bd4e2e557c453a))
|
|
13
|
+
* fix language switch in repeater ([76d4b80](https://github.com/lotrekagency/mapo/commit/76d4b80ac66fd5344a4b0deb7576dfb1a16b8f89))
|
|
14
|
+
* fix missing funtions in confs. this is a bit hacky. better to find a better solution ([e3117cf](https://github.com/lotrekagency/mapo/commit/e3117cf6b25bffcb87aac148d670e676869ddeda))
|
|
15
|
+
* fix repeater commands showing only on sidebar hover ([82de95d](https://github.com/lotrekagency/mapo/commit/82de95d66aa2edc85860c856a8288f468d8ee014))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* added a collapsed Label prop to define it in the repeater ([ec26fcb](https://github.com/lotrekagency/mapo/commit/ec26fcbf69c43e04cc9791ca7e5c88779c70372e))
|
|
21
|
+
* added a vShow callback prop to conditionally display a field ([c94a280](https://github.com/lotrekagency/mapo/commit/c94a280d16114a8b7480f5e22a81db46e8cc34d7))
|
|
22
|
+
* added collapsed mode to repeaters ([e99e2cd](https://github.com/lotrekagency/mapo/commit/e99e2cdc15c3f24c5b850b3e6ea1fc53685baccb))
|
|
23
|
+
* added onChange callback to fields ([f19a994](https://github.com/lotrekagency/mapo/commit/f19a9944aa7f6f5abacb70cdc3936c9db8df4176))
|
|
24
|
+
* big code refactor and improovements to fields management ([a818d8b](https://github.com/lotrekagency/mapo/commit/a818d8b891dbb4892f50267d6355c41297e2c6c6))
|
|
25
|
+
* Form component has now many more slots ([5db0da8](https://github.com/lotrekagency/mapo/commit/5db0da85d5adc6b19370dc1fdc06542048cc36ac))
|
|
26
|
+
* move vShow check in form component and add vVisible check ([c219cec](https://github.com/lotrekagency/mapo/commit/c219cec33b00d1b605522772f7ed57eed7c37fee))
|
|
27
|
+
* **form:** added tabs configuration to forms ([387e521](https://github.com/lotrekagency/mapo/commit/387e521422d0e8ac35817abdf36d927011c17798))
|
|
28
|
+
* **repeater:** now repeater with templates has more precise slots ([67eb56f](https://github.com/lotrekagency/mapo/commit/67eb56f66bda6f7ba6c85c5017bc4c216263e56a))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
6
34
|
# [1.0.0-alpha.21](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.20...v1.0.0-alpha.21) (2022-04-25)
|
|
7
35
|
|
|
8
36
|
**Note:** Version bump only for package @mapomodule/uikit
|
|
@@ -40,66 +40,23 @@
|
|
|
40
40
|
<slot name="body.top.underlang" v-bind="slotBindings"></slot>
|
|
41
41
|
<!-- Use this to override the content of the main body. -->
|
|
42
42
|
<slot name="body" v-bind="slotBindings">
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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>
|
|
102
|
-
</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>
|
|
103
60
|
</slot>
|
|
104
61
|
<!-- Use this to add content under the main body. -->
|
|
105
62
|
<slot name="body.bottom" v-bind="slotBindings"></slot>
|
|
@@ -151,64 +108,23 @@
|
|
|
151
108
|
</slot>
|
|
152
109
|
<!-- Use this to add content on the top of the sidebar fields (or under sidebar buttons). -->
|
|
153
110
|
<slot name="side.top" v-bind="slotBindings"></slot>
|
|
154
|
-
<
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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>
|
|
211
|
-
</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>
|
|
212
128
|
<!-- Use this to add content under the sidebar fields. -->
|
|
213
129
|
<slot name="side.bottom" v-bind="slotBindings"></slot>
|
|
214
130
|
</div>
|
|
@@ -238,246 +154,203 @@
|
|
|
238
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]]
|
|
239
155
|
*/
|
|
240
156
|
export default {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
},
|
|
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
|
-
},
|
|
261
|
-
// The main configuration that determines the arrangement of the fields in the detail layout.
|
|
262
|
-
fields: {
|
|
263
|
-
// [`DetailConfiguration`](#detailconfiguration)
|
|
264
|
-
type: Object | Array,
|
|
265
|
-
required: true
|
|
157
|
+
name: "Detail",
|
|
158
|
+
data() {
|
|
159
|
+
return {
|
|
160
|
+
model: {},
|
|
161
|
+
modelLanguages: [],
|
|
162
|
+
currentLang: this.lang,
|
|
163
|
+
errors: null
|
|
164
|
+
};
|
|
266
165
|
},
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
});
|
|
317
|
-
});
|
|
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
|
+
},
|
|
318
215
|
},
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
.then(res => {
|
|
327
|
-
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();
|
|
328
223
|
this.crud
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
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;
|
|
332
229
|
this.$mapo.$snack.open({
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
})
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
if (this.isReadonly){
|
|
358
|
-
conf.attrs = {...conf.attrs, readonly: true}
|
|
359
|
-
}
|
|
360
|
-
return conf;
|
|
361
|
-
},
|
|
362
|
-
mapConf(fields) {
|
|
363
|
-
const icon = "mdi-cube-outline";
|
|
364
|
-
const parseGroup = group =>
|
|
365
|
-
typeof group === "string"
|
|
366
|
-
? { name: group, icon }
|
|
367
|
-
: { ...group, icon: group.icon !== undefined ? group.icon : icon };
|
|
368
|
-
return fields.map((f, i) =>
|
|
369
|
-
f.group
|
|
370
|
-
? { group: parseGroup(f.group), fields: this.mapConf(f.fields) }
|
|
371
|
-
: this.parseConf(f, i)
|
|
372
|
-
);
|
|
373
|
-
}
|
|
374
|
-
},
|
|
375
|
-
watch: {
|
|
376
|
-
currentLang(val) {
|
|
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;
|
|
390
|
-
}
|
|
391
|
-
},
|
|
392
|
-
value(val) {
|
|
393
|
-
if (val) {
|
|
394
|
-
this.model = val;
|
|
395
|
-
this.initLang();
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
},
|
|
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
|
-
},
|
|
406
|
-
crud() {
|
|
407
|
-
return this.$mapo.$api.crud(this.endpoint);
|
|
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
|
-
},
|
|
421
|
-
mainFields() {
|
|
422
|
-
return this.mapConf(
|
|
423
|
-
this.fields instanceof Array ? this.fields : this.fields.main || []
|
|
424
|
-
);
|
|
425
|
-
},
|
|
426
|
-
sideFields() {
|
|
427
|
-
return this.mapConf(
|
|
428
|
-
(this.fields instanceof Object && this.fields.sidenav) || []
|
|
429
|
-
);
|
|
430
|
-
},
|
|
431
|
-
isNew() {
|
|
432
|
-
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
|
+
},
|
|
433
254
|
},
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
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
|
+
}
|
|
439
276
|
},
|
|
440
|
-
|
|
441
|
-
|
|
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
|
+
}
|
|
442
339
|
},
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
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
|
+
}
|
|
456
353
|
},
|
|
457
|
-
stickySide() {
|
|
458
|
-
return this.sticky
|
|
459
|
-
? {
|
|
460
|
-
position: "sticky",
|
|
461
|
-
top: "60px"
|
|
462
|
-
}
|
|
463
|
-
: {};
|
|
464
|
-
}
|
|
465
|
-
},
|
|
466
|
-
mounted() {
|
|
467
|
-
if (this.identifier && this.identifier !== "new") {
|
|
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();
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
354
|
};
|
|
482
355
|
</script>
|
|
483
356
|
|
|
@@ -522,16 +395,16 @@ Here the list of the FieldConfiguration type association.
|
|
|
522
395
|
|
|
523
396
|
- `text` ==> [v-text-field](https://vuetifyjs.com/en/components/text-fields/),
|
|
524
397
|
- `select` ==> [v-select](https://vuetifyjs.com/en/components/selects/),
|
|
525
|
-
- `date` ==> [date-field](/components/fields/DateField/),
|
|
398
|
+
- `date` ==> [date-field](/components/Form/fields/DateField/),
|
|
526
399
|
- `textarea` ==> [v-textarea](https://vuetifyjs.com/en/components/textareas/),
|
|
527
400
|
- `switch` ==> [v-switch](https://vuetifyjs.com/en/components/switches/),
|
|
528
401
|
- `slider` ==> [v-slider](https://vuetifyjs.com/en/components/sliders/),
|
|
529
|
-
- `file` ==> [file-field](/components/fields/FileField/),
|
|
530
|
-
- `editor` ==> [wyg-editor](/components/fields/wygEditor/wygEditor/),
|
|
531
|
-
- `media` ==> [media-field](/components/fields/MediaField/),
|
|
532
|
-
- `mediaList` ==> [media-m2m-field](/components/fields/MediaM2mField/)
|
|
533
|
-
- `m2m` or `fks` ==> [fks-field](/components/fields/FksField/),
|
|
534
|
-
- `repeater` ==> [repeater](/components/fields/Repeater/),
|
|
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/),
|
|
535
408
|
|
|
536
409
|
|
|
537
410
|
#### Example of a [`FieldConfiguration`](#fieldconfiguration):
|