@mapomodule/uikit 1.0.0-alpha.6 → 1.0.0-alpha.60
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 +953 -0
- package/components/ConfirmDialog.vue +58 -37
- package/components/Detail/Detail.vue +421 -271
- package/components/Detail/DetailLangSwitch.vue +9 -2
- package/components/DropArea.vue +63 -56
- 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 +20 -11
- 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/TinyMce → Form/fields/wygEditor}/utils/mapomedia.plugin.js +7 -6
- package/components/Form/fields/wygEditor/wygEditor.vue +285 -0
- 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 +22 -4
- package/components/List/ListFilters.vue +48 -10
- package/components/List/ListHead.vue +11 -3
- package/components/List/ListQuickEdit.vue +124 -64
- package/components/List/ListTable.vue +118 -18
- package/components/Login.vue +17 -7
- package/components/LogoutButton.vue +43 -28
- package/components/MediaManager/MediaBreadcrumbs.vue +45 -0
- package/components/MediaManager/MediaEditor.vue +297 -120
- package/components/MediaManager/MediaFileChanger.vue +78 -0
- package/components/MediaManager/MediaFolders.vue +224 -116
- package/components/MediaManager/MediaGallery.vue +224 -145
- package/components/MediaManager/MediaManager.vue +125 -159
- package/components/MediaManager/MediaManagerDialog.vue +36 -31
- package/components/MediaManager/MediaPreview.vue +258 -0
- package/components/MediaManager/MediaUploader.vue +91 -90
- 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 +5 -7
- package/components/ThemeToggle.vue +13 -0
- package/components/layout/Sidebar/Sidebar.vue +48 -39
- package/components/layout/Sidebar/SidebarList.vue +11 -4
- package/components/layout/Sidebar/SidebarListItem.vue +113 -13
- 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 +35 -11
- 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 -132
- package/components/Detail/defaults.js +0 -55
- package/components/fields/M2mField.vue +0 -95
- package/components/fields/MediaField.vue +0 -195
- package/components/fields/MediaM2mField.vue +0 -238
- package/components/fields/TinyMce/TinyMce.vue +0 -180
- package/components/fields/TinyMce/defaults.js +0 -55
- package/components/layout/Sidebar/SidebarFooter.vue +0 -70
- package/defaults.js +0 -29
- package/layouts/error.vue +0 -45
- /package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/events.js +0 -0
- /package/components/{fields/TinyMce/utils/script.injector.js → Form/fields/wygEditor/utils/tinymce.injector.js} +0 -0
- /package/static/{favicon.ico → mapo/favicon.ico} +0 -0
|
@@ -1,190 +1,206 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
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
|
-
|
|
47
|
-
|
|
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>
|
|
56
|
+
</slot>
|
|
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
|
|
48
79
|
>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
</slot>
|
|
77
|
-
</div>
|
|
78
|
-
</div>
|
|
79
|
-
</slot>
|
|
80
|
-
<!-- Use this to add content under the main body. -->
|
|
81
|
-
<slot name="body.bottom" v-bind="slotBindings"></slot>
|
|
82
|
-
</v-col>
|
|
83
|
-
<v-col cols="12" md="4">
|
|
84
|
-
<div class="d-flex flex-column" :style="stickySide">
|
|
85
|
-
<!-- Use this to add content on the top of the sidebar button panel. -->
|
|
86
|
-
<slot name="side.buttons.top" v-bind="slotBindings"></slot>
|
|
87
|
-
<!-- Use this to override the the sidebar button panel. -->
|
|
88
|
-
<slot name="side.buttons" v-bind="slotBindings">
|
|
89
|
-
<!-- Save, Save and continue, Back, and Delete buttons. -->
|
|
90
|
-
<div class="mt-4 mt-md-0 mb-md-4 mb-0 order-1 order-md-0">
|
|
91
|
-
<!-- Use this to override the Save button. -->
|
|
92
|
-
<slot name="button.save" v-bind="slotBindings">
|
|
93
|
-
<!-- The Save button. -->
|
|
94
|
-
<v-btn class="mb-2" tile block @click="saveItem(true)">{{
|
|
95
|
-
isNew ? "Create" : "Save"
|
|
96
|
-
}}</v-btn>
|
|
97
|
-
</slot>
|
|
98
|
-
<!-- Use this to override the Save and continue button. -->
|
|
99
|
-
<slot name="button.savecontinue" v-bind="slotBindings">
|
|
100
|
-
<!-- The Save and continue button. -->
|
|
101
|
-
<v-btn class="mb-2" tile block @click="saveItem(false)"
|
|
102
|
-
>{{ isNew ? "Create" : "Save" }} and continue</v-btn
|
|
103
|
-
>
|
|
104
|
-
</slot>
|
|
105
|
-
<!-- Use this to override the Back button. -->
|
|
106
|
-
<slot name="button.back" v-bind="slotBindings">
|
|
107
|
-
<!-- The Back button. -->
|
|
108
|
-
<v-btn class="mb-2" tile block @click="$router.back()"
|
|
109
|
-
>Back</v-btn
|
|
110
|
-
>
|
|
111
|
-
</slot>
|
|
112
|
-
<!-- Use this to override the Delete button. -->
|
|
113
|
-
<slot name="button.delete" v-bind="slotBindings">
|
|
114
|
-
<!-- The Delete button. -->
|
|
115
|
-
<v-btn
|
|
116
|
-
v-if="!isNew"
|
|
117
|
-
class="mb-2"
|
|
118
|
-
color="error"
|
|
119
|
-
tile
|
|
120
|
-
block
|
|
121
|
-
@click="deleteItem"
|
|
122
|
-
>Delete</v-btn
|
|
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"
|
|
123
107
|
>
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
v-for="(field, index) in sideFields"
|
|
134
|
-
:key="index"
|
|
135
|
-
>
|
|
136
|
-
<v-card v-if="field.group" class="mb-4">
|
|
137
|
-
<v-card-title>
|
|
138
|
-
<v-icon left> {{ field.group.icon }} </v-icon>
|
|
139
|
-
<span>{{ field.group.name }}</span>
|
|
140
|
-
</v-card-title>
|
|
141
|
-
<v-card-text class="row">
|
|
142
|
-
<div
|
|
143
|
-
v-for="(fields, fieldsI) in field.fields"
|
|
144
|
-
:key="fieldsI"
|
|
145
|
-
class="col-12"
|
|
146
|
-
:class="field.class"
|
|
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
|
|
147
117
|
>
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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"
|
|
139
|
+
>
|
|
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>
|
|
176
151
|
</div>
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
</v-form>
|
|
183
|
-
</v-container>
|
|
152
|
+
</v-col>
|
|
153
|
+
</v-row>
|
|
154
|
+
</v-form>
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
184
157
|
</template>
|
|
185
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>
|
|
186
200
|
|
|
187
201
|
<script>
|
|
202
|
+
import { diffObjs, deepClone } from "@mapomodule/utils/helpers/objHelpers";
|
|
203
|
+
|
|
188
204
|
/**
|
|
189
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.
|
|
190
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]]
|
|
@@ -194,123 +210,191 @@ export default {
|
|
|
194
210
|
data() {
|
|
195
211
|
return {
|
|
196
212
|
model: {},
|
|
197
|
-
|
|
198
|
-
|
|
213
|
+
modelLanguages: [],
|
|
214
|
+
currentLang: this.lang,
|
|
215
|
+
errors: null,
|
|
216
|
+
buttonClicked: null,
|
|
199
217
|
};
|
|
200
218
|
},
|
|
201
219
|
props: {
|
|
202
220
|
// V-model of the object we are editing.
|
|
203
221
|
value: {
|
|
204
222
|
type: Object,
|
|
205
|
-
required: false
|
|
223
|
+
required: false,
|
|
206
224
|
},
|
|
207
225
|
// Set the current lang to value.
|
|
208
226
|
lang: {
|
|
209
227
|
type: String,
|
|
210
|
-
required: false
|
|
228
|
+
required: false,
|
|
211
229
|
},
|
|
212
230
|
// The main configuration that determines the arrangement of the fields in the detail layout.
|
|
213
231
|
fields: {
|
|
214
232
|
// [`DetailConfiguration`](#detailconfiguration)
|
|
215
233
|
type: Object | Array,
|
|
216
|
-
required: true
|
|
234
|
+
required: true,
|
|
235
|
+
},
|
|
236
|
+
usePatch: {
|
|
237
|
+
type: Boolean,
|
|
238
|
+
default() {
|
|
239
|
+
return this.$mapo.$options?.content?.usePatch || false;
|
|
240
|
+
},
|
|
217
241
|
},
|
|
218
242
|
// A list of languages into which the payload needs to be translated.
|
|
219
243
|
languages: {
|
|
220
244
|
type: Array,
|
|
221
|
-
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
|
+
},
|
|
222
255
|
},
|
|
223
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.
|
|
224
257
|
endpoint: {
|
|
225
258
|
type: String,
|
|
226
|
-
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
|
+
},
|
|
227
269
|
},
|
|
228
270
|
// The identifier of the object you need to retrieve and edit. It can be "new" if you need to create a new payload.
|
|
229
271
|
identifier: {
|
|
230
272
|
// `String|Number`.
|
|
231
273
|
type: String | Number,
|
|
232
|
-
default: "new"
|
|
274
|
+
default: "new",
|
|
233
275
|
},
|
|
234
276
|
// The title of the detail page.
|
|
235
277
|
modelName: String,
|
|
236
278
|
// This determines the style of the sidebar. If set to true the sidebar will remain sticky during the scroll.
|
|
237
279
|
sticky: {
|
|
238
280
|
type: Boolean,
|
|
239
|
-
default: true
|
|
240
|
-
}
|
|
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
|
|
241
299
|
},
|
|
242
300
|
methods: {
|
|
301
|
+
back() {
|
|
302
|
+
this.$nuxt.context?.from?.name == "login"
|
|
303
|
+
? this.$router.go(-3)
|
|
304
|
+
: this.$router.back();
|
|
305
|
+
},
|
|
243
306
|
saveItem(back = false) {
|
|
307
|
+
this.buttonClicked = back ? "saveAndBackBtn" : "saveBtn";
|
|
244
308
|
this.errors = null;
|
|
245
309
|
this.$refs.form?.resetValidation();
|
|
246
|
-
this.
|
|
247
|
-
.
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
this.
|
|
251
|
-
|
|
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;
|
|
252
325
|
this.$mapo.$snack.open({
|
|
253
|
-
message:
|
|
254
|
-
color: "error"
|
|
326
|
+
message: error.response?.data?.detail || this.$t("mapo.genericError"),
|
|
327
|
+
color: "error",
|
|
255
328
|
});
|
|
329
|
+
})
|
|
330
|
+
.finally(() => {
|
|
331
|
+
this.buttonClicked = null;
|
|
256
332
|
});
|
|
257
333
|
},
|
|
258
334
|
deleteItem() {
|
|
259
335
|
this.$mapo.$confirm
|
|
260
336
|
.open({
|
|
261
|
-
title: "
|
|
262
|
-
question:
|
|
263
|
-
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
|
+
},
|
|
264
343
|
})
|
|
265
|
-
.then(res => {
|
|
344
|
+
.then((res) => {
|
|
266
345
|
if (res) {
|
|
346
|
+
this.buttonClicked = "deleteBtn";
|
|
267
347
|
this.crud
|
|
268
348
|
.delete(this.identifier)
|
|
269
|
-
.then(() =>
|
|
270
|
-
|
|
349
|
+
.then(() => {
|
|
350
|
+
this.unsetRouterGuard();
|
|
351
|
+
this.back();
|
|
352
|
+
})
|
|
353
|
+
.catch((error) =>
|
|
271
354
|
this.$mapo.$snack.open({
|
|
272
|
-
message:
|
|
273
|
-
color: "error"
|
|
355
|
+
message: error.response?.data?.detail || this.$t("mapo.genericError"),
|
|
356
|
+
color: "error",
|
|
274
357
|
})
|
|
275
|
-
)
|
|
358
|
+
)
|
|
359
|
+
.finally(() => {
|
|
360
|
+
this.buttonClicked = null;
|
|
361
|
+
});
|
|
276
362
|
}
|
|
277
363
|
});
|
|
278
364
|
},
|
|
279
|
-
|
|
280
|
-
if (
|
|
281
|
-
this
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
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();
|
|
285
376
|
}
|
|
286
377
|
},
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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;
|
|
295
387
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
typeof group === "string"
|
|
302
|
-
? { name: group, icon }
|
|
303
|
-
: { ...group, icon: group.icon || icon };
|
|
304
|
-
return fields.map((f, i) =>
|
|
305
|
-
f.group
|
|
306
|
-
? { group: parseGroup(f.group), fields: this.mapConf(f.fields) }
|
|
307
|
-
: 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
|
|
308
393
|
);
|
|
309
|
-
}
|
|
394
|
+
},
|
|
310
395
|
},
|
|
311
396
|
watch: {
|
|
312
397
|
currentLang(val) {
|
|
313
|
-
this.initLang();
|
|
314
398
|
// Fired when the current language changes.
|
|
315
399
|
// @arg Emits the language name as a string.
|
|
316
400
|
this.$emit("update:lang", val);
|
|
@@ -328,23 +412,55 @@ export default {
|
|
|
328
412
|
value(val) {
|
|
329
413
|
if (val) {
|
|
330
414
|
this.model = val;
|
|
331
|
-
this.initLang();
|
|
332
415
|
}
|
|
333
|
-
}
|
|
416
|
+
},
|
|
334
417
|
},
|
|
335
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
|
+
},
|
|
336
428
|
crud() {
|
|
337
429
|
return this.$mapo.$api.crud(this.endpoint);
|
|
338
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
|
+
},
|
|
445
|
+
isReadonly() {
|
|
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");
|
|
449
|
+
}
|
|
450
|
+
return !!this.buttonClicked;
|
|
451
|
+
},
|
|
452
|
+
canDelete() {
|
|
453
|
+
if (this.readonly) return false;
|
|
454
|
+
if (this.$mapo.$auth.routeMiddlewares.includes("permissions")) {
|
|
455
|
+
return this.$mapo.$auth.user.permissions.includes("delete");
|
|
456
|
+
}
|
|
457
|
+
return true;
|
|
458
|
+
},
|
|
339
459
|
mainFields() {
|
|
340
|
-
return this.
|
|
341
|
-
this.fields instanceof Array ? this.fields : this.fields.main || []
|
|
342
|
-
);
|
|
460
|
+
return this.fields instanceof Array ? this.fields : this.fields.main || [];
|
|
343
461
|
},
|
|
344
462
|
sideFields() {
|
|
345
|
-
return this.
|
|
346
|
-
(this.fields instanceof Object && this.fields.sidenav) || []
|
|
347
|
-
);
|
|
463
|
+
return (this.fields instanceof Object && this.fields.sidenav) || [];
|
|
348
464
|
},
|
|
349
465
|
isNew() {
|
|
350
466
|
return this.identifier && this.identifier == "new";
|
|
@@ -356,13 +472,14 @@ export default {
|
|
|
356
472
|
return !Object.keys(this.model).length;
|
|
357
473
|
},
|
|
358
474
|
langs() {
|
|
359
|
-
return (
|
|
360
|
-
|
|
361
|
-
|
|
475
|
+
return !this.forceLanguages && (this.modelLanguages || []).length
|
|
476
|
+
? this.modelLanguages
|
|
477
|
+
: this.languages;
|
|
362
478
|
},
|
|
363
479
|
slotBindings() {
|
|
364
480
|
return {
|
|
365
481
|
model: this.model,
|
|
482
|
+
errors: this.errors,
|
|
366
483
|
currentLang: this.currentLang,
|
|
367
484
|
crud: this.crud,
|
|
368
485
|
isNew: this.isNew,
|
|
@@ -370,26 +487,48 @@ export default {
|
|
|
370
487
|
loading: this.loading,
|
|
371
488
|
form: this.$refs.form,
|
|
372
489
|
saveItem: this.saveItem,
|
|
373
|
-
deleteItem: this.deleteItem
|
|
490
|
+
deleteItem: this.deleteItem,
|
|
374
491
|
};
|
|
375
492
|
},
|
|
376
493
|
stickySide() {
|
|
377
494
|
return this.sticky
|
|
378
495
|
? {
|
|
379
496
|
position: "sticky",
|
|
380
|
-
top: "60px"
|
|
497
|
+
top: "60px",
|
|
381
498
|
}
|
|
382
499
|
: {};
|
|
383
|
-
}
|
|
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
|
+
},
|
|
384
510
|
},
|
|
385
|
-
mounted() {
|
|
511
|
+
async mounted() {
|
|
386
512
|
if (this.identifier && this.identifier !== "new") {
|
|
387
|
-
|
|
388
|
-
this.model =
|
|
389
|
-
this.
|
|
390
|
-
})
|
|
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);
|
|
391
525
|
}
|
|
392
|
-
|
|
526
|
+
this.modelBkp = deepClone(this.model);
|
|
527
|
+
this.setRouterGuard();
|
|
528
|
+
},
|
|
529
|
+
destroyed() {
|
|
530
|
+
this.unsetRouterGuard();
|
|
531
|
+
},
|
|
393
532
|
};
|
|
394
533
|
</script>
|
|
395
534
|
|
|
@@ -397,7 +536,7 @@ export default {
|
|
|
397
536
|
|
|
398
537
|
## DetailConfiguration
|
|
399
538
|
|
|
400
|
-
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).
|
|
401
540
|
Each field configuration represents a field of the form.
|
|
402
541
|
The configuration can also consist of an object with two keys `{ main sidenav }`.
|
|
403
542
|
Each key is an `Array` of [`FieldConfiguration`](#fieldconfiguration) and will modify a different part of the component:
|
|
@@ -407,7 +546,7 @@ Each key is an `Array` of [`FieldConfiguration`](#fieldconfiguration) and will m
|
|
|
407
546
|
|
|
408
547
|
### FieldConfiguration
|
|
409
548
|
|
|
410
|
-
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.
|
|
411
550
|
So, for example, if we have the payload: `{ image: { name: "...", url: "..." } }` we can modify the image name using the dottedPath `"image.name"`.
|
|
412
551
|
|
|
413
552
|
The default component used to render a field of a form is a [`v-text-field`](https://vuetifyjs.com/en/components/text-fields/).
|
|
@@ -415,12 +554,12 @@ If you want more control over the generated component you can use an `Object` wi
|
|
|
415
554
|
|
|
416
555
|
|Name|Description|Type|Required|Default|
|
|
417
556
|
|---|---|---|---|---|
|
|
418
|
-
|value|The dottedPath of the value we want to modify.|`String`|`true`|-|
|
|
419
|
-
|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`|
|
|
420
|
-
|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`|
|
|
421
|
-
|accessor|[`Accessor`](#accessor) object to specify the setter and the getter of the field.|`Object`|`false`|`{set: x=>x, get: x=>x}`|
|
|
422
|
-
|attrs|The attributes that will be passed to the component.|`Object`|`false`|-|
|
|
423
|
-
|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`|-|
|
|
424
563
|
|
|
425
564
|
#### Accessor
|
|
426
565
|
|
|
@@ -430,19 +569,21 @@ Each function must return the processed value.
|
|
|
430
569
|
|
|
431
570
|
#### Field types
|
|
432
571
|
|
|
433
|
-
Here the list of the FieldConfiguration type association.
|
|
572
|
+
Here the list of the FieldConfiguration type association.
|
|
434
573
|
|
|
435
574
|
- `text` ==> [v-text-field](https://vuetifyjs.com/en/components/text-fields/),
|
|
436
575
|
- `select` ==> [v-select](https://vuetifyjs.com/en/components/selects/),
|
|
437
|
-
- `date` ==> [date-field](/components/fields/DateField/),
|
|
576
|
+
- `date` ==> [date-field](/components/Form/fields/DateField/),
|
|
438
577
|
- `textarea` ==> [v-textarea](https://vuetifyjs.com/en/components/textareas/),
|
|
439
578
|
- `switch` ==> [v-switch](https://vuetifyjs.com/en/components/switches/),
|
|
440
579
|
- `slider` ==> [v-slider](https://vuetifyjs.com/en/components/sliders/),
|
|
441
|
-
- `file` ==> [
|
|
442
|
-
- `editor` ==> [
|
|
443
|
-
- `media` ==> [media-field](/components/fields/MediaField/),
|
|
444
|
-
- `
|
|
445
|
-
- `mediaList` ==> [media-m2m-field](/components/fields/MediaM2mField/)
|
|
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/),
|
|
446
587
|
|
|
447
588
|
|
|
448
589
|
#### Example of a [`FieldConfiguration`](#fieldconfiguration):
|
|
@@ -461,8 +602,8 @@ Here the list of the FieldConfiguration type association.
|
|
|
461
602
|
|
|
462
603
|
### FieldGroup
|
|
463
604
|
|
|
464
|
-
You can use this mixed with `FieldConfiguration` to group multiple fields in one card with a title and an icon.
|
|
465
|
-
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).
|
|
466
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.
|
|
467
608
|
|
|
468
609
|
<br><br>
|
|
@@ -479,8 +620,9 @@ This is an interactive example. You can play with it but remember that all http
|
|
|
479
620
|
::: demo
|
|
480
621
|
<template>
|
|
481
622
|
<v-app>
|
|
623
|
+
<div class="d-flex justify-end"><ThemeToggle/></div>
|
|
482
624
|
<Detail
|
|
483
|
-
endpoint="api/
|
|
625
|
+
endpoint="api/articles"
|
|
484
626
|
identifier="new"
|
|
485
627
|
:fields="fields"
|
|
486
628
|
:languages="['it', 'en', 'de']"
|
|
@@ -496,6 +638,14 @@ export default {
|
|
|
496
638
|
main: [
|
|
497
639
|
{ value: "identifier", synci18n: true },
|
|
498
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
|
+
},
|
|
499
649
|
{
|
|
500
650
|
group: "Seo",
|
|
501
651
|
fields: [
|
|
@@ -543,4 +693,4 @@ export default {
|
|
|
543
693
|
|
|
544
694
|
|
|
545
695
|
|
|
546
|
-
</docs>
|
|
696
|
+
</docs>
|