@mapomodule/uikit 1.0.0-alpha.9 → 1.0.0
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 +853 -0
- package/components/ConfirmDialog.vue +58 -37
- package/components/Detail/Detail.vue +415 -285
- package/components/Detail/DetailLangSwitch.vue +8 -1
- package/components/DropArea.vue +62 -55
- package/components/Form/Form.vue +218 -0
- package/components/Form/FormField.vue +216 -0
- package/components/Form/FormGroup.vue +146 -0
- package/components/Form/FormTabs.vue +188 -0
- package/components/Form/defaults.js +98 -0
- package/components/Form/fields/ColorField.vue +79 -0
- package/components/{fields → Form/fields}/DateField.vue +12 -9
- package/components/Form/fields/DateTimeField.vue +271 -0
- package/components/Form/fields/EnhancedMediaField.vue +224 -0
- package/components/Form/fields/FileField.vue +125 -0
- package/components/Form/fields/FksField.vue +115 -0
- package/components/Form/fields/MediaField.vue +159 -0
- package/components/Form/fields/MediaM2mField.vue +149 -0
- package/components/Form/fields/Repeater.vue +618 -0
- package/components/{fields → Form/fields}/SeoPreview.vue +10 -10
- package/components/Form/fields/TimeField.vue +154 -0
- package/components/Form/fields/mapField/leaflet.injector.js +39 -0
- package/components/Form/fields/mapField/mapField.vue +350 -0
- package/components/Form/fields/wygEditor/defaults.js +25 -0
- package/components/{fields → Form/fields}/wygEditor/utils/mapomedia.plugin.js +7 -6
- package/components/{fields → Form/fields}/wygEditor/wygEditor.vue +114 -25
- package/components/Form/fields/wygEditorCKE/defaults.js +103 -0
- package/components/Form/fields/wygEditorCKE/utils/ckeditor.injector.js +29 -0
- package/components/Form/fields/wygEditorCKE/wygEditorCKE.vue +270 -0
- package/components/LangSwitcher.vue +44 -0
- package/components/List/List.vue +34 -17
- package/components/List/ListActions.vue +5 -5
- package/components/List/ListFilters.vue +48 -10
- package/components/List/ListHead.vue +1 -1
- package/components/List/ListQuickEdit.vue +28 -102
- package/components/List/ListTable.vue +89 -11
- package/components/Login.vue +5 -4
- package/components/LogoutButton.vue +43 -28
- package/components/MediaManager/MediaBreadcrumbs.vue +45 -0
- package/components/MediaManager/MediaEditor.vue +226 -195
- package/components/MediaManager/MediaFileChanger.vue +78 -0
- package/components/MediaManager/MediaFolders.vue +207 -183
- package/components/MediaManager/MediaGallery.vue +212 -137
- package/components/MediaManager/MediaManager.vue +97 -171
- package/components/MediaManager/MediaManagerDialog.vue +28 -20
- package/components/MediaManager/MediaPreview.vue +89 -11
- package/components/MediaManager/MediaUploader.vue +75 -77
- package/components/MenuManager/MenuManager.vue +332 -0
- package/components/MenuManager/MenuNodeEditor.vue +270 -0
- package/components/MenuManager/MenuTreeview.vue +237 -0
- package/components/MenuManager/MenuTreeviewNode.vue +208 -0
- package/components/PagePreview.vue +58 -0
- package/components/SnackBar.vue +2 -3
- package/components/ThemeToggle.vue +13 -0
- package/components/layout/Sidebar/Sidebar.vue +48 -39
- package/components/layout/Sidebar/SidebarList.vue +10 -5
- package/components/layout/Sidebar/SidebarListItem.vue +56 -15
- package/components/layout/Sidebar/SidebarProfile.vue +42 -0
- package/components/layout/Sidebar/SidebarTitle.vue +45 -0
- package/components/layout/Topbar/Topbar.vue +11 -9
- package/components/layout/routebuilder.js +2 -2
- package/defaults/i18n.js +37 -0
- package/defaults/vuetify.js +34 -0
- package/layouts/default.vue +33 -7
- package/layouts/empty.vue +10 -0
- package/module.js +7 -5
- package/package.json +6 -4
- package/pages/index.vue +19 -17
- package/static/mapo/ckeditor/plugins/image2/dev/assets/image1.jpg +0 -0
- package/static/mapo/ckeditor/plugins/image2/dev/assets/image2.jpg +0 -0
- package/static/mapo/ckeditor/plugins/image2/dev/contents.css +35 -0
- package/static/mapo/ckeditor/plugins/image2/dev/image2.html +338 -0
- package/static/mapo/ckeditor/plugins/image2/dialogs/image2.js +557 -0
- package/static/mapo/ckeditor/plugins/image2/icons/hidpi/image.png +0 -0
- package/static/mapo/ckeditor/plugins/image2/icons/image.png +0 -0
- package/static/mapo/ckeditor/plugins/image2/lang/af.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/ar.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/az.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/bg.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/bn.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/bs.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/ca.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/cs.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/cy.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/da.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/de-ch.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/de.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/el.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/en-au.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/en-ca.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/en-gb.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/en.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/eo.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/es-mx.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/es.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/et.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/eu.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/fa.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/fi.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/fo.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/fr-ca.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/fr.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/gl.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/gu.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/he.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/hi.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/hr.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/hu.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/id.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/is.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/it.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/ja.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/ka.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/km.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/ko.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/ku.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/lt.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/lv.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/mk.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/mn.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/ms.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/nb.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/nl.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/no.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/oc.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/pl.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/pt-br.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/pt.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/ro.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/ru.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/si.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/sk.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/sl.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/sq.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/sr-latn.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/sr.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/sv.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/th.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/tr.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/tt.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/ug.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/uk.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/vi.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/zh-cn.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/lang/zh.js +21 -0
- package/static/mapo/ckeditor/plugins/image2/plugin.js +1798 -0
- package/static/mapo/ckeditor/plugins/image2/samples/assets/image1.jpg +0 -0
- package/static/mapo/ckeditor/plugins/image2/samples/assets/image2.jpg +0 -0
- package/static/mapo/ckeditor/plugins/image2/samples/image2.html +68 -0
- package/static/mapo/ckeditor/skins/moono/dev/icons16.png +0 -0
- package/static/mapo/ckeditor/skins/moono/dev/icons16.svg +2374 -0
- package/static/mapo/ckeditor/skins/moono/dev/icons32.png +0 -0
- package/static/mapo/ckeditor/skins/moono/dev/icons32.svg +2722 -0
- package/static/mapo/ckeditor/skins/moono/dev/locations.json +144 -0
- package/static/mapo/ckeditor/skins/moono/dialog.css +5 -0
- package/static/mapo/ckeditor/skins/moono/dialog_ie.css +5 -0
- package/static/mapo/ckeditor/skins/moono/dialog_ie7.css +5 -0
- package/static/mapo/ckeditor/skins/moono/dialog_ie8.css +5 -0
- package/static/mapo/ckeditor/skins/moono/dialog_iequirks.css +5 -0
- package/static/mapo/ckeditor/skins/moono/editor.css +5 -0
- package/static/mapo/ckeditor/skins/moono/editor_gecko.css +5 -0
- package/static/mapo/ckeditor/skins/moono/editor_ie.css +5 -0
- package/static/mapo/ckeditor/skins/moono/editor_ie7.css +5 -0
- package/static/mapo/ckeditor/skins/moono/editor_ie8.css +5 -0
- package/static/mapo/ckeditor/skins/moono/editor_iequirks.css +5 -0
- package/static/mapo/ckeditor/skins/moono/icons.png +0 -0
- package/static/mapo/ckeditor/skins/moono/icons_hidpi.png +0 -0
- package/static/mapo/ckeditor/skins/moono/images/anchor.png +0 -0
- package/static/mapo/ckeditor/skins/moono/images/arrow.png +0 -0
- package/static/mapo/ckeditor/skins/moono/images/close.png +0 -0
- package/static/mapo/ckeditor/skins/moono/images/hidpi/anchor.png +0 -0
- package/static/mapo/ckeditor/skins/moono/images/hidpi/close.png +0 -0
- package/static/mapo/ckeditor/skins/moono/images/hidpi/lock-open.png +0 -0
- package/static/mapo/ckeditor/skins/moono/images/hidpi/lock.png +0 -0
- package/static/mapo/ckeditor/skins/moono/images/hidpi/refresh.png +0 -0
- package/static/mapo/ckeditor/skins/moono/images/lock-open.png +0 -0
- package/static/mapo/ckeditor/skins/moono/images/lock.png +0 -0
- package/static/mapo/ckeditor/skins/moono/images/refresh.png +0 -0
- package/static/mapo/ckeditor/skins/moono/images/spinner.gif +0 -0
- package/static/mapo/ckeditor/skins/moono/readme.md +49 -0
- package/static/mapo/ckeditor/skins/moono/skin.js +10 -0
- package/static/mapo/ckeditor/skins/moono-dark/dialog.css +5 -0
- package/static/mapo/ckeditor/skins/moono-dark/dialog_ie.css +5 -0
- package/static/mapo/ckeditor/skins/moono-dark/dialog_ie7.css +5 -0
- package/static/mapo/ckeditor/skins/moono-dark/dialog_ie8.css +5 -0
- package/static/mapo/ckeditor/skins/moono-dark/dialog_iequirks.css +5 -0
- package/static/mapo/ckeditor/skins/moono-dark/editor.css +5 -0
- package/static/mapo/ckeditor/skins/moono-dark/editor_gecko.css +5 -0
- package/static/mapo/ckeditor/skins/moono-dark/editor_ie.css +5 -0
- package/static/mapo/ckeditor/skins/moono-dark/editor_ie7.css +5 -0
- package/static/mapo/ckeditor/skins/moono-dark/editor_ie8.css +5 -0
- package/static/mapo/ckeditor/skins/moono-dark/editor_iequirks.css +5 -0
- package/static/mapo/ckeditor/skins/moono-dark/icons.png +0 -0
- package/static/mapo/ckeditor/skins/moono-dark/icons_hidpi.png +0 -0
- package/static/mapo/ckeditor/skins/moono-dark/images/arrow.png +0 -0
- package/static/mapo/ckeditor/skins/moono-dark/images/close.png +0 -0
- package/static/mapo/ckeditor/skins/moono-dark/images/hidpi/close.png +0 -0
- package/static/mapo/ckeditor/skins/moono-dark/images/hidpi/lock-open.png +0 -0
- package/static/mapo/ckeditor/skins/moono-dark/images/hidpi/lock.png +0 -0
- package/static/mapo/ckeditor/skins/moono-dark/images/hidpi/refresh.png +0 -0
- package/static/mapo/ckeditor/skins/moono-dark/images/lock-open.png +0 -0
- package/static/mapo/ckeditor/skins/moono-dark/images/lock.png +0 -0
- package/static/mapo/ckeditor/skins/moono-dark/images/refresh.png +0 -0
- package/static/mapo/ckeditor/skins/moono-dark/readme.md +51 -0
- package/static/mapo/ckeditor/skins/moono-dark/skin.js +5 -0
- package/static/mapo/tinymce-skins/mapo-dark/content.inline.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-dark/content.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-dark/content.mobile.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-dark/skin.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-dark/skin.mobile.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-light/content.inline.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-light/content.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-light/content.mobile.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-light/skin.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-light/skin.mobile.min.css +7 -0
- package/translations/en-US.js +177 -0
- package/translations/it-IT.js +180 -0
- package/LICENSE.md +0 -20
- package/components/Detail/DetailField.vue +0 -142
- package/components/Detail/defaults.js +0 -57
- package/components/fields/FksField.vue +0 -60
- package/components/fields/MediaField.vue +0 -213
- package/components/fields/MediaM2mField.vue +0 -243
- package/components/fields/wygEditor/defaults.js +0 -55
- package/components/layout/Sidebar/SidebarFooter.vue +0 -71
- package/defaults.js +0 -29
- package/layouts/error.vue +0 -45
- /package/components/{fields → Form/fields}/wygEditor/utils/events.js +0 -0
- /package/components/{fields/wygEditor/utils/script.injector.js → Form/fields/wygEditor/utils/tinymce.injector.js} +0 -0
- /package/static/{favicon.ico → mapo/favicon.ico} +0 -0
|
@@ -1,195 +1,206 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div>
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
</
|
|
9
|
-
</
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
2
|
+
<div class="mapo-detail--wrapper">
|
|
3
|
+
<div class="mapo-detail--loader" v-if="loading">
|
|
4
|
+
<v-progress-linear color="primary" indeterminate absolute></v-progress-linear>
|
|
5
|
+
<span class="detail-component-loading">
|
|
6
|
+
<v-icon size="30">mdi-timer-sand</v-icon>
|
|
7
|
+
{{ $t("mapo.fetchingData") }}
|
|
8
|
+
</span>
|
|
9
|
+
</div>
|
|
10
|
+
<div class="mapo-detail--loaded" v-else>
|
|
11
|
+
<!-- Use this to override the title of the detail component. -->
|
|
12
|
+
<slot name="title" v-bind="slotBindings">
|
|
13
|
+
<!-- `<h1> "Create | Edit" + modelName </h1>` -->
|
|
14
|
+
<h1 class="mapo-detail--title">
|
|
15
|
+
{{ isNew ? $t("mapo.create") : $t("mapo.edit") }} {{ modelName }}
|
|
16
|
+
</h1>
|
|
17
|
+
</slot>
|
|
18
|
+
<v-form class="mapo-detail--form" ref="form">
|
|
19
|
+
<v-row>
|
|
20
|
+
<v-col class="mapo-detail--main" cols="12" :md="12 - sidenavCol">
|
|
21
|
+
<!-- Use this to add content at the top of the central layout. -->
|
|
22
|
+
<slot name="body.top" v-bind="slotBindings"></slot>
|
|
23
|
+
<!-- Use this to override the Language Switch panel. -->
|
|
24
|
+
<slot name="body.lang" v-bind="slotBindings">
|
|
25
|
+
<!-- [`DetailLangSwitch`](/components/detail/DetailLangSwitch/) -->
|
|
26
|
+
<DetailLangSwitch
|
|
27
|
+
v-if="langs && langs.length"
|
|
28
|
+
v-show="langs.length > 1"
|
|
29
|
+
class="mapo-detail--language-tabs"
|
|
30
|
+
v-model="currentLang"
|
|
31
|
+
:langs="langs"
|
|
32
|
+
:errors="errors"
|
|
33
|
+
/></slot>
|
|
34
|
+
<!-- Use this to add content under the Language Switch panel. -->
|
|
35
|
+
<slot name="body.top.underlang" v-bind="slotBindings"></slot>
|
|
36
|
+
<!-- Use this to override the content of the main body. -->
|
|
37
|
+
<slot name="body" v-bind="slotBindings">
|
|
38
|
+
<Form
|
|
39
|
+
v-model="model"
|
|
40
|
+
:currentLang="currentLang"
|
|
41
|
+
:languages="langs"
|
|
42
|
+
:errors="errors"
|
|
43
|
+
:fields="mainFields"
|
|
44
|
+
:moreSlotBindings="slotBindings"
|
|
45
|
+
:readonly="isReadonly"
|
|
36
46
|
>
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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>
|
|
47
|
+
<template v-for="(_, slot) in $slots" :slot="slot">
|
|
48
|
+
<!-- @vuese-ignore -->
|
|
49
|
+
<slot :name="slot"></slot>
|
|
50
|
+
</template>
|
|
51
|
+
<template v-for="(_, slot) in $scopedSlots" v-slot:[slot]="props">
|
|
52
|
+
<!-- @vuese-ignore -->
|
|
53
|
+
<slot :name="slot" v-bind="props" />
|
|
54
|
+
</template>
|
|
55
|
+
</Form>
|
|
129
56
|
</slot>
|
|
130
|
-
<!-- Use this to add content
|
|
131
|
-
<slot name="
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
57
|
+
<!-- Use this to add content under the main body. -->
|
|
58
|
+
<slot name="body.bottom" v-bind="slotBindings"></slot>
|
|
59
|
+
</v-col>
|
|
60
|
+
<v-col class="mapo-detail--sidenav" cols="12" :md="sidenavCol">
|
|
61
|
+
<div class="mapo-detail--sidenav-col" :style="stickySide">
|
|
62
|
+
<!-- Use this to add content on the top of the sidebar button panel. -->
|
|
63
|
+
<slot name="side.buttons.top" v-bind="slotBindings"></slot>
|
|
64
|
+
<!-- Use this to override the the sidebar button panel. -->
|
|
65
|
+
<slot name="side.buttons" v-bind="slotBindings">
|
|
66
|
+
<!-- Save, Save and continue, Back, and Delete buttons. -->
|
|
67
|
+
<div class="mapo-detail--buttons">
|
|
68
|
+
<!-- Use this to override the Save button. -->
|
|
69
|
+
<slot name="button.save" v-bind="slotBindings">
|
|
70
|
+
<!-- The Save button. -->
|
|
71
|
+
<v-btn
|
|
72
|
+
v-show="canGoBack"
|
|
73
|
+
:loading="buttonClicked == 'saveAndBackBtn'"
|
|
74
|
+
:disabled="isReadonly"
|
|
75
|
+
tile
|
|
76
|
+
block
|
|
77
|
+
@click="saveItem(true)"
|
|
78
|
+
>{{ isNew ? $t("mapo.create") : $t("mapo.save") }}</v-btn
|
|
79
|
+
>
|
|
80
|
+
</slot>
|
|
81
|
+
<!-- Use this to override the Save and continue button. -->
|
|
82
|
+
<slot name="button.savecontinue" v-bind="slotBindings">
|
|
83
|
+
<!-- The Save and continue button. -->
|
|
84
|
+
<v-btn
|
|
85
|
+
:loading="buttonClicked == 'saveBtn'"
|
|
86
|
+
:disabled="isReadonly"
|
|
87
|
+
tile
|
|
88
|
+
block
|
|
89
|
+
@click="saveItem(false)"
|
|
90
|
+
>{{
|
|
91
|
+
isNew ? $t("mapo.createContinue") : $t("mapo.saveContinue")
|
|
92
|
+
}}</v-btn
|
|
93
|
+
>
|
|
94
|
+
</slot>
|
|
95
|
+
<!-- Use this to override the Back button. -->
|
|
96
|
+
<slot name="button.back" v-bind="slotBindings">
|
|
97
|
+
<!-- The Back button. -->
|
|
98
|
+
<v-btn v-show="canGoBack" tile block @click="back">{{
|
|
99
|
+
$t("mapo.back")
|
|
100
|
+
}}</v-btn>
|
|
101
|
+
</slot>
|
|
102
|
+
<!-- Use this to override the Delete button. -->
|
|
103
|
+
<slot
|
|
104
|
+
name="button.delete"
|
|
105
|
+
:loading="buttonClicked == 'deleteBtn'"
|
|
106
|
+
v-bind="slotBindings"
|
|
107
|
+
>
|
|
108
|
+
<!-- The Delete button. -->
|
|
109
|
+
<v-btn
|
|
110
|
+
v-if="!isNew"
|
|
111
|
+
color="error"
|
|
112
|
+
tile
|
|
113
|
+
block
|
|
114
|
+
:disabled="!canDelete"
|
|
115
|
+
@click="deleteItem"
|
|
116
|
+
>{{ $t("mapo.delete") }}</v-btn
|
|
117
|
+
>
|
|
118
|
+
</slot>
|
|
119
|
+
<!-- Use this to override the Preview Page button. -->
|
|
120
|
+
<slot name="button.preview" v-bind="slotBindings">
|
|
121
|
+
<!-- The Preview Page button. Needs a preview field from model. Declare it in the props. -->
|
|
122
|
+
<PagePreview
|
|
123
|
+
v-if="previewUrl"
|
|
124
|
+
:pageUrl="previewUrl"
|
|
125
|
+
/>
|
|
126
|
+
</slot>
|
|
127
|
+
</div>
|
|
128
|
+
</slot>
|
|
129
|
+
<!-- Use this to add content on the top of the sidebar fields (or under sidebar buttons). -->
|
|
130
|
+
<slot name="side.top" v-bind="slotBindings"></slot>
|
|
131
|
+
<Form
|
|
132
|
+
v-model="model"
|
|
133
|
+
:currentLang="currentLang"
|
|
134
|
+
:languages="langs"
|
|
135
|
+
:errors="errors"
|
|
136
|
+
:fields="sideFields"
|
|
137
|
+
:moreSlotBindings="slotBindings"
|
|
138
|
+
:readonly="isReadonly"
|
|
138
139
|
>
|
|
139
|
-
<
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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>
|
|
140
|
+
<template v-for="(_, slot) in $slots" :slot="slot">
|
|
141
|
+
<!-- @vuese-ignore -->
|
|
142
|
+
<slot :name="slot"></slot>
|
|
143
|
+
</template>
|
|
144
|
+
<template v-for="(_, slot) in $scopedSlots" v-slot:[slot]="props">
|
|
145
|
+
<!-- @vuese-ignore -->
|
|
146
|
+
<slot :name="slot" v-bind="props" />
|
|
147
|
+
</template>
|
|
148
|
+
</Form>
|
|
149
|
+
<!-- Use this to add content under the sidebar fields. -->
|
|
150
|
+
<slot name="side.bottom" v-bind="slotBindings"></slot>
|
|
181
151
|
</div>
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
</v-row>
|
|
187
|
-
</v-form>
|
|
152
|
+
</v-col>
|
|
153
|
+
</v-row>
|
|
154
|
+
</v-form>
|
|
155
|
+
</div>
|
|
188
156
|
</div>
|
|
189
157
|
</template>
|
|
190
158
|
|
|
159
|
+
<style lang="scss" scoped>
|
|
160
|
+
.mapo-detail--loader {
|
|
161
|
+
.v-progress-linear {
|
|
162
|
+
top: 0;
|
|
163
|
+
}
|
|
164
|
+
span {
|
|
165
|
+
position: absolute;
|
|
166
|
+
top: 50%;
|
|
167
|
+
transform: translateY(-50%);
|
|
168
|
+
width: 100%;
|
|
169
|
+
display: flex;
|
|
170
|
+
flex-direction: column;
|
|
171
|
+
justify-content: center;
|
|
172
|
+
align-items: center;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
.mapo-detail--title {
|
|
176
|
+
margin-bottom: 20px;
|
|
177
|
+
font-weight: normal;
|
|
178
|
+
}
|
|
179
|
+
.mapo-detail--language-tabs {
|
|
180
|
+
margin-bottom: 20px;
|
|
181
|
+
}
|
|
182
|
+
.mapo-detail--sidenav-col {
|
|
183
|
+
display: flex;
|
|
184
|
+
flex-direction: column;
|
|
185
|
+
}
|
|
186
|
+
.mapo-detail--buttons {
|
|
187
|
+
margin-top: 16px;
|
|
188
|
+
margin-bottom: 0px;
|
|
189
|
+
order: 1;
|
|
190
|
+
@media (min-width: 960px) {
|
|
191
|
+
margin-bottom: 16px;
|
|
192
|
+
margin-top: 0px;
|
|
193
|
+
order: 0;
|
|
194
|
+
}
|
|
195
|
+
.v-btn {
|
|
196
|
+
margin-bottom: 8px;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
</style>
|
|
191
200
|
|
|
192
201
|
<script>
|
|
202
|
+
import { diffObjs, deepClone } from "@mapomodule/utils/helpers/objHelpers";
|
|
203
|
+
|
|
193
204
|
/**
|
|
194
205
|
* 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
206
|
* 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]]
|
|
@@ -199,126 +210,191 @@ export default {
|
|
|
199
210
|
data() {
|
|
200
211
|
return {
|
|
201
212
|
model: {},
|
|
202
|
-
|
|
203
|
-
|
|
213
|
+
modelLanguages: [],
|
|
214
|
+
currentLang: this.lang,
|
|
215
|
+
errors: null,
|
|
216
|
+
buttonClicked: null,
|
|
204
217
|
};
|
|
205
218
|
},
|
|
206
219
|
props: {
|
|
207
220
|
// V-model of the object we are editing.
|
|
208
221
|
value: {
|
|
209
222
|
type: Object,
|
|
210
|
-
required: false
|
|
223
|
+
required: false,
|
|
211
224
|
},
|
|
212
225
|
// Set the current lang to value.
|
|
213
226
|
lang: {
|
|
214
227
|
type: String,
|
|
215
|
-
required: false
|
|
228
|
+
required: false,
|
|
216
229
|
},
|
|
217
230
|
// The main configuration that determines the arrangement of the fields in the detail layout.
|
|
218
231
|
fields: {
|
|
219
232
|
// [`DetailConfiguration`](#detailconfiguration)
|
|
220
233
|
type: Object | Array,
|
|
221
|
-
required: true
|
|
234
|
+
required: true,
|
|
235
|
+
},
|
|
236
|
+
usePatch: {
|
|
237
|
+
type: Boolean,
|
|
238
|
+
default() {
|
|
239
|
+
return this.$mapo.$options?.content?.usePatch || false;
|
|
240
|
+
},
|
|
222
241
|
},
|
|
223
242
|
// A list of languages into which the payload needs to be translated.
|
|
224
243
|
languages: {
|
|
225
244
|
type: Array,
|
|
226
|
-
default
|
|
245
|
+
default() {
|
|
246
|
+
return this.$mapo.$options?.content?.languages || [];
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
// Forces use of languages passed as prop, instead of those loaded with model
|
|
250
|
+
forceLanguages: {
|
|
251
|
+
type: Boolean,
|
|
252
|
+
default() {
|
|
253
|
+
return this.$mapo.$options?.content?.forceLanguages || false;
|
|
254
|
+
},
|
|
227
255
|
},
|
|
228
256
|
// 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
257
|
endpoint: {
|
|
230
258
|
type: String,
|
|
231
|
-
default: null
|
|
259
|
+
default: null,
|
|
260
|
+
},
|
|
261
|
+
// This determines the width of the sidebar in desktop view in a 12 col grid.
|
|
262
|
+
sidenavCol: {
|
|
263
|
+
type: Number | String,
|
|
264
|
+
default: "4",
|
|
265
|
+
validator: function (value) {
|
|
266
|
+
// The value must be a number between 0 and 12
|
|
267
|
+
return [...Array(12).keys()].indexOf(+value) !== -1;
|
|
268
|
+
},
|
|
232
269
|
},
|
|
233
270
|
// The identifier of the object you need to retrieve and edit. It can be "new" if you need to create a new payload.
|
|
234
271
|
identifier: {
|
|
235
272
|
// `String|Number`.
|
|
236
273
|
type: String | Number,
|
|
237
|
-
default: "new"
|
|
274
|
+
default: "new",
|
|
238
275
|
},
|
|
239
276
|
// The title of the detail page.
|
|
240
277
|
modelName: String,
|
|
241
278
|
// This determines the style of the sidebar. If set to true the sidebar will remain sticky during the scroll.
|
|
242
279
|
sticky: {
|
|
243
280
|
type: Boolean,
|
|
244
|
-
default: true
|
|
245
|
-
}
|
|
281
|
+
default: true,
|
|
282
|
+
},
|
|
283
|
+
// 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.
|
|
284
|
+
multipart: {
|
|
285
|
+
type: String,
|
|
286
|
+
default: "auto",
|
|
287
|
+
validator: function (value) {
|
|
288
|
+
// The value must match one of these strings
|
|
289
|
+
return ["auto", "force", "disable"].indexOf(value) !== -1;
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
// The name of the field that contains the url of the page preview. [optional]
|
|
293
|
+
previewField: {
|
|
294
|
+
type: String,
|
|
295
|
+
required: false,
|
|
296
|
+
},
|
|
297
|
+
// This forces the detail page to be readonly.
|
|
298
|
+
readonly: Boolean
|
|
246
299
|
},
|
|
247
300
|
methods: {
|
|
301
|
+
back() {
|
|
302
|
+
this.$nuxt.context?.from?.name == "login"
|
|
303
|
+
? this.$router.go(-3)
|
|
304
|
+
: this.$router.back();
|
|
305
|
+
},
|
|
248
306
|
saveItem(back = false) {
|
|
307
|
+
this.buttonClicked = back ? "saveAndBackBtn" : "saveBtn";
|
|
249
308
|
this.errors = null;
|
|
250
309
|
this.$refs.form?.resetValidation();
|
|
251
|
-
this.
|
|
252
|
-
.
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
this.
|
|
256
|
-
|
|
310
|
+
this.apiSendPayload()
|
|
311
|
+
.then((resp) => {
|
|
312
|
+
Object.assign(this.model, resp);
|
|
313
|
+
this.modelBkp = deepClone(this.model);
|
|
314
|
+
this.$mapo.$snack.open({
|
|
315
|
+
message: this.isNew
|
|
316
|
+
? this.$t("mapo.createSuccess")
|
|
317
|
+
: this.$t("mapo.saveSuccess"),
|
|
318
|
+
color: "success",
|
|
319
|
+
});
|
|
320
|
+
this.isNew && this.$router.replace({ params: { detail: resp.id } });
|
|
321
|
+
back && this.back();
|
|
322
|
+
})
|
|
323
|
+
.catch((error) => {
|
|
324
|
+
this.errors = (error.response.status == 400 && error.response.data) || null;
|
|
257
325
|
this.$mapo.$snack.open({
|
|
258
|
-
message: error.response?.data?.detail || "
|
|
259
|
-
color: "error"
|
|
326
|
+
message: error.response?.data?.detail || this.$t("mapo.genericError"),
|
|
327
|
+
color: "error",
|
|
260
328
|
});
|
|
329
|
+
})
|
|
330
|
+
.finally(() => {
|
|
331
|
+
this.buttonClicked = null;
|
|
261
332
|
});
|
|
262
333
|
},
|
|
263
334
|
deleteItem() {
|
|
264
335
|
this.$mapo.$confirm
|
|
265
336
|
.open({
|
|
266
|
-
title: "
|
|
267
|
-
question:
|
|
268
|
-
approveButton: {
|
|
337
|
+
title: this.$t("mapo.delete"),
|
|
338
|
+
question: this.$t("mapo.confirmDelete"),
|
|
339
|
+
approveButton: {
|
|
340
|
+
text: this.$t("mapo.delete"),
|
|
341
|
+
attrs: { color: "red", text: true },
|
|
342
|
+
},
|
|
269
343
|
})
|
|
270
|
-
.then(res => {
|
|
344
|
+
.then((res) => {
|
|
271
345
|
if (res) {
|
|
346
|
+
this.buttonClicked = "deleteBtn";
|
|
272
347
|
this.crud
|
|
273
348
|
.delete(this.identifier)
|
|
274
|
-
.then(() =>
|
|
275
|
-
|
|
349
|
+
.then(() => {
|
|
350
|
+
this.unsetRouterGuard();
|
|
351
|
+
this.back();
|
|
352
|
+
})
|
|
353
|
+
.catch((error) =>
|
|
276
354
|
this.$mapo.$snack.open({
|
|
277
|
-
message: error.response?.data?.detail || "
|
|
278
|
-
color: "error"
|
|
355
|
+
message: error.response?.data?.detail || this.$t("mapo.genericError"),
|
|
356
|
+
color: "error",
|
|
279
357
|
})
|
|
280
|
-
)
|
|
358
|
+
)
|
|
359
|
+
.finally(() => {
|
|
360
|
+
this.buttonClicked = null;
|
|
361
|
+
});
|
|
281
362
|
}
|
|
282
363
|
});
|
|
283
364
|
},
|
|
284
|
-
|
|
285
|
-
if (
|
|
286
|
-
this
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
365
|
+
async checkUnsavedHook(to, from, next) {
|
|
366
|
+
if (to.name !== from.name && this.hasDiff) {
|
|
367
|
+
this.$mapo.$confirm
|
|
368
|
+
.open({
|
|
369
|
+
title: this.$t("mapo.unsavedData"),
|
|
370
|
+
question: this.$t("mapo.confirmLeaveChanges"),
|
|
371
|
+
approveButton: { text: this.$t("mapo.confirm"), attrs: { text: true } },
|
|
372
|
+
})
|
|
373
|
+
.then(next);
|
|
374
|
+
} else {
|
|
375
|
+
next();
|
|
290
376
|
}
|
|
291
377
|
},
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
if (this.isReadonly){
|
|
302
|
-
conf.attrs = {...conf.attrs, readonly: true}
|
|
378
|
+
setRouterGuard() {
|
|
379
|
+
this.$router.beforeHooks.push(this.checkUnsavedHook);
|
|
380
|
+
window?.addEventListener("beforeunload", this.preventWindowClose);
|
|
381
|
+
},
|
|
382
|
+
preventWindowClose(event) {
|
|
383
|
+
const text = this.$t("mapo.confirmLeaveChanges");
|
|
384
|
+
if (this.hasDiff) {
|
|
385
|
+
event.returnValue = text;
|
|
386
|
+
return text;
|
|
303
387
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
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)
|
|
388
|
+
},
|
|
389
|
+
unsetRouterGuard() {
|
|
390
|
+
window?.removeEventListener("beforeunload", this.preventWindowClose);
|
|
391
|
+
this.$router.beforeHooks = this.$router.beforeHooks.filter(
|
|
392
|
+
(f) => f != this.checkUnsavedHook
|
|
316
393
|
);
|
|
317
|
-
}
|
|
394
|
+
},
|
|
318
395
|
},
|
|
319
396
|
watch: {
|
|
320
397
|
currentLang(val) {
|
|
321
|
-
this.initLang();
|
|
322
398
|
// Fired when the current language changes.
|
|
323
399
|
// @arg Emits the language name as a string.
|
|
324
400
|
this.$emit("update:lang", val);
|
|
@@ -336,35 +412,55 @@ export default {
|
|
|
336
412
|
value(val) {
|
|
337
413
|
if (val) {
|
|
338
414
|
this.model = val;
|
|
339
|
-
this.initLang();
|
|
340
415
|
}
|
|
341
|
-
}
|
|
416
|
+
},
|
|
342
417
|
},
|
|
343
418
|
computed: {
|
|
419
|
+
canGoBack() {
|
|
420
|
+
if (typeof window !== "undefined") {
|
|
421
|
+
return (
|
|
422
|
+
(this.$nuxt?.context?.from?.name !== "login" && window.history.length > 1) ||
|
|
423
|
+
window.history.length > 3
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
return true;
|
|
427
|
+
},
|
|
344
428
|
crud() {
|
|
345
429
|
return this.$mapo.$api.crud(this.endpoint);
|
|
346
430
|
},
|
|
431
|
+
apiSendPayload() {
|
|
432
|
+
let method, args;
|
|
433
|
+
if (!this.model.id) {
|
|
434
|
+
method = this.crud.create;
|
|
435
|
+
args = [this.model, {}, { multipart: this.multipart }];
|
|
436
|
+
} else if (this.usePatch) {
|
|
437
|
+
method = this.crud.partialUpdate;
|
|
438
|
+
args = [this.model.id, this.modelDiff, {}, { multipart: this.multipart }];
|
|
439
|
+
} else {
|
|
440
|
+
method = this.crud.update;
|
|
441
|
+
args = [this.model.id, this.model, {}, { multipart: this.multipart }];
|
|
442
|
+
}
|
|
443
|
+
return async () => method(...args);
|
|
444
|
+
},
|
|
347
445
|
isReadonly() {
|
|
348
|
-
if (this
|
|
349
|
-
|
|
446
|
+
if (this.readonly) return this.readonly;
|
|
447
|
+
if (this.$mapo.$auth.routeMiddlewares.includes("permissions")) {
|
|
448
|
+
return !this.$mapo.$auth.user.permissions.includes(this.isNew ? "add" : "change");
|
|
350
449
|
}
|
|
351
|
-
return
|
|
450
|
+
return !!this.buttonClicked;
|
|
352
451
|
},
|
|
353
452
|
canDelete() {
|
|
354
|
-
if (this
|
|
355
|
-
|
|
453
|
+
if (this.readonly) return false;
|
|
454
|
+
if (this.$mapo.$auth.routeMiddlewares.includes("permissions")) {
|
|
455
|
+
return this.$mapo.$auth.user.permissions.includes("delete");
|
|
356
456
|
}
|
|
357
|
-
return true
|
|
457
|
+
return true;
|
|
358
458
|
},
|
|
359
459
|
mainFields() {
|
|
360
|
-
return this.
|
|
361
|
-
this.fields instanceof Array ? this.fields : this.fields.main || []
|
|
362
|
-
);
|
|
460
|
+
return this.fields instanceof Array ? this.fields : this.fields.main || [];
|
|
363
461
|
},
|
|
364
462
|
sideFields() {
|
|
365
|
-
return this.
|
|
366
|
-
(this.fields instanceof Object && this.fields.sidenav) || []
|
|
367
|
-
);
|
|
463
|
+
return (this.fields instanceof Object && this.fields.sidenav) || [];
|
|
368
464
|
},
|
|
369
465
|
isNew() {
|
|
370
466
|
return this.identifier && this.identifier == "new";
|
|
@@ -376,13 +472,14 @@ export default {
|
|
|
376
472
|
return !Object.keys(this.model).length;
|
|
377
473
|
},
|
|
378
474
|
langs() {
|
|
379
|
-
return (
|
|
380
|
-
|
|
381
|
-
|
|
475
|
+
return !this.forceLanguages && (this.modelLanguages || []).length
|
|
476
|
+
? this.modelLanguages
|
|
477
|
+
: this.languages;
|
|
382
478
|
},
|
|
383
479
|
slotBindings() {
|
|
384
480
|
return {
|
|
385
481
|
model: this.model,
|
|
482
|
+
errors: this.errors,
|
|
386
483
|
currentLang: this.currentLang,
|
|
387
484
|
crud: this.crud,
|
|
388
485
|
isNew: this.isNew,
|
|
@@ -390,26 +487,48 @@ export default {
|
|
|
390
487
|
loading: this.loading,
|
|
391
488
|
form: this.$refs.form,
|
|
392
489
|
saveItem: this.saveItem,
|
|
393
|
-
deleteItem: this.deleteItem
|
|
490
|
+
deleteItem: this.deleteItem,
|
|
394
491
|
};
|
|
395
492
|
},
|
|
396
493
|
stickySide() {
|
|
397
494
|
return this.sticky
|
|
398
495
|
? {
|
|
399
496
|
position: "sticky",
|
|
400
|
-
top: "60px"
|
|
497
|
+
top: "60px",
|
|
401
498
|
}
|
|
402
499
|
: {};
|
|
403
|
-
}
|
|
500
|
+
},
|
|
501
|
+
modelDiff() {
|
|
502
|
+
return diffObjs(this.modelBkp, this.model) || {};
|
|
503
|
+
},
|
|
504
|
+
hasDiff() {
|
|
505
|
+
return !!(this.modelDiff && Object.keys(this.modelDiff).length > 0);
|
|
506
|
+
},
|
|
507
|
+
previewUrl() {
|
|
508
|
+
return this.previewField ? this.model[this.previewField] : null;
|
|
509
|
+
},
|
|
404
510
|
},
|
|
405
|
-
mounted() {
|
|
511
|
+
async mounted() {
|
|
406
512
|
if (this.identifier && this.identifier !== "new") {
|
|
407
|
-
|
|
408
|
-
this.model =
|
|
409
|
-
this.
|
|
410
|
-
})
|
|
513
|
+
try {
|
|
514
|
+
this.model = await this.crud.detail(this.identifier);
|
|
515
|
+
this.modelLanguages = this.model?.lang_info?.site_languages.map((l) => l.id);
|
|
516
|
+
} catch (error) {
|
|
517
|
+
this.$nuxt.error({
|
|
518
|
+
statusCode: error.response.status,
|
|
519
|
+
message: error.response.data?.detail || this.$t("mapo.genericError"),
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
} else if (this.value) {
|
|
523
|
+
this.model = this.value;
|
|
524
|
+
this.modelLanguages = this.model?.lang_info?.site_languages.map((l) => l.id);
|
|
411
525
|
}
|
|
412
|
-
|
|
526
|
+
this.modelBkp = deepClone(this.model);
|
|
527
|
+
this.setRouterGuard();
|
|
528
|
+
},
|
|
529
|
+
destroyed() {
|
|
530
|
+
this.unsetRouterGuard();
|
|
531
|
+
},
|
|
413
532
|
};
|
|
414
533
|
</script>
|
|
415
534
|
|
|
@@ -417,7 +536,7 @@ export default {
|
|
|
417
536
|
|
|
418
537
|
## DetailConfiguration
|
|
419
538
|
|
|
420
|
-
The DetailConfiguration determines the behavior of the main form and is an `Array` of [`FieldConfiguration`](#fieldconfiguration).
|
|
539
|
+
The DetailConfiguration determines the behavior of the main form and is an `Array` of [`FieldConfiguration`](#fieldconfiguration).
|
|
421
540
|
Each field configuration represents a field of the form.
|
|
422
541
|
The configuration can also consist of an object with two keys `{ main sidenav }`.
|
|
423
542
|
Each key is an `Array` of [`FieldConfiguration`](#fieldconfiguration) and will modify a different part of the component:
|
|
@@ -427,7 +546,7 @@ Each key is an `Array` of [`FieldConfiguration`](#fieldconfiguration) and will m
|
|
|
427
546
|
|
|
428
547
|
### FieldConfiguration
|
|
429
548
|
|
|
430
|
-
The `FieldConfiguration` is a `String` containing the dottedPath of a value inside the payload we want to modify.
|
|
549
|
+
The `FieldConfiguration` is a `String` containing the dottedPath of a value inside the payload we want to modify.
|
|
431
550
|
So, for example, if we have the payload: `{ image: { name: "...", url: "..." } }` we can modify the image name using the dottedPath `"image.name"`.
|
|
432
551
|
|
|
433
552
|
The default component used to render a field of a form is a [`v-text-field`](https://vuetifyjs.com/en/components/text-fields/).
|
|
@@ -435,12 +554,12 @@ If you want more control over the generated component you can use an `Object` wi
|
|
|
435
554
|
|
|
436
555
|
|Name|Description|Type|Required|Default|
|
|
437
556
|
|---|---|---|---|---|
|
|
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`|-|
|
|
557
|
+
|value|The dottedPath of the value we want to modify.|`String`|`true`|-|
|
|
558
|
+
|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`|
|
|
559
|
+
|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`|
|
|
560
|
+
|accessor|[`Accessor`](#accessor) object to specify the setter and the getter of the field.|`Object`|`false`|`{set: x=>x, get: x=>x}`|
|
|
561
|
+
|attrs|The attributes that will be passed to the component.|`Object`|`false`|-|
|
|
562
|
+
|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
563
|
|
|
445
564
|
#### Accessor
|
|
446
565
|
|
|
@@ -450,19 +569,21 @@ Each function must return the processed value.
|
|
|
450
569
|
|
|
451
570
|
#### Field types
|
|
452
571
|
|
|
453
|
-
Here the list of the FieldConfiguration type association.
|
|
572
|
+
Here the list of the FieldConfiguration type association.
|
|
454
573
|
|
|
455
574
|
- `text` ==> [v-text-field](https://vuetifyjs.com/en/components/text-fields/),
|
|
456
575
|
- `select` ==> [v-select](https://vuetifyjs.com/en/components/selects/),
|
|
457
|
-
- `date` ==> [date-field](/components/fields/DateField/),
|
|
576
|
+
- `date` ==> [date-field](/components/Form/fields/DateField/),
|
|
458
577
|
- `textarea` ==> [v-textarea](https://vuetifyjs.com/en/components/textareas/),
|
|
459
578
|
- `switch` ==> [v-switch](https://vuetifyjs.com/en/components/switches/),
|
|
460
579
|
- `slider` ==> [v-slider](https://vuetifyjs.com/en/components/sliders/),
|
|
461
|
-
- `file` ==> [
|
|
462
|
-
- `editor` ==> [wyg-editor](/components/fields/wygEditor/wygEditor/),
|
|
463
|
-
- `media` ==> [media-field](/components/fields/MediaField/),
|
|
464
|
-
- `
|
|
465
|
-
- `mediaList` ==> [media-
|
|
580
|
+
- `file` ==> [file-field](/components/Form/fields/FileField/),
|
|
581
|
+
- `editor` ==> [wyg-editor](/components/Form/fields/wygEditor/wygEditor/),
|
|
582
|
+
- `media` ==> [media-field](/components/Form/fields/MediaField/),
|
|
583
|
+
- `enhancedMedia` ==> [enhanced-media-field](/components/Form/fields/EnhancedMediaField/),
|
|
584
|
+
- `mediaList` ==> [media-m2m-field](/components/Form/fields/MediaM2mField/)
|
|
585
|
+
- `m2m` or `fks` ==> [fks-field](/components/Form/fields/FksField/),
|
|
586
|
+
- `repeater` ==> [repeater](/components/Form/fields/Repeater/),
|
|
466
587
|
|
|
467
588
|
|
|
468
589
|
#### Example of a [`FieldConfiguration`](#fieldconfiguration):
|
|
@@ -481,8 +602,8 @@ Here the list of the FieldConfiguration type association.
|
|
|
481
602
|
|
|
482
603
|
### FieldGroup
|
|
483
604
|
|
|
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).
|
|
605
|
+
You can use this mixed with `FieldConfiguration` to group multiple fields in one card with a title and an icon.
|
|
606
|
+
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
607
|
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
608
|
|
|
488
609
|
<br><br>
|
|
@@ -499,8 +620,9 @@ This is an interactive example. You can play with it but remember that all http
|
|
|
499
620
|
::: demo
|
|
500
621
|
<template>
|
|
501
622
|
<v-app>
|
|
623
|
+
<div class="d-flex justify-end"><ThemeToggle/></div>
|
|
502
624
|
<Detail
|
|
503
|
-
endpoint="api/
|
|
625
|
+
endpoint="api/articles"
|
|
504
626
|
identifier="new"
|
|
505
627
|
:fields="fields"
|
|
506
628
|
:languages="['it', 'en', 'de']"
|
|
@@ -516,6 +638,14 @@ export default {
|
|
|
516
638
|
main: [
|
|
517
639
|
{ value: "identifier", synci18n: true },
|
|
518
640
|
{ value: "content", type: "editor" },
|
|
641
|
+
{ value: "sections", type: "repeater", attrs: {
|
|
642
|
+
sortable: true,
|
|
643
|
+
fields: [
|
|
644
|
+
{ value: "title", class: "col-md-6" },
|
|
645
|
+
{ value: "subtitle", class: "col-md-6" },
|
|
646
|
+
{ value: "content", type: "textarea" },
|
|
647
|
+
]}
|
|
648
|
+
},
|
|
519
649
|
{
|
|
520
650
|
group: "Seo",
|
|
521
651
|
fields: [
|
|
@@ -563,4 +693,4 @@ export default {
|
|
|
563
693
|
|
|
564
694
|
|
|
565
695
|
|
|
566
|
-
</docs>
|
|
696
|
+
</docs>
|