@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,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<v-tabs v-model="tab">
|
|
2
|
+
<v-tabs v-model="tab" show-arrows>
|
|
3
3
|
<v-tab v-for="lang in langs" :key="lang">
|
|
4
4
|
<v-badge :value="hasErrors(lang)" color="error" dot>
|
|
5
5
|
{{ lang }}
|
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
</v-tabs>
|
|
9
9
|
</template>
|
|
10
10
|
|
|
11
|
+
<style lang="scss">
|
|
12
|
+
.theme--light.mapo-detail--language-tabs.v-tabs > .v-tabs-bar {
|
|
13
|
+
background: #f5f5f5;
|
|
14
|
+
}
|
|
15
|
+
</style>
|
|
11
16
|
<script>
|
|
12
17
|
import { getPointed } from "@mapomodule/utils/helpers/objHelpers";
|
|
13
18
|
/**
|
|
@@ -26,8 +31,9 @@ export default {
|
|
|
26
31
|
// A list of languages into which the payload needs to be translated.
|
|
27
32
|
langs: {
|
|
28
33
|
type: Array,
|
|
29
|
-
default
|
|
34
|
+
default() { return this.$mapo.$options?.content?.languages || []; }
|
|
30
35
|
},
|
|
36
|
+
noRouteChange: Boolean,
|
|
31
37
|
// An object representing all the errors of all fields. This component will find errors in each language and will display a little dot in the tab if there are any errors.
|
|
32
38
|
errors: Object,
|
|
33
39
|
},
|
|
@@ -49,6 +55,7 @@ export default {
|
|
|
49
55
|
},
|
|
50
56
|
methods: {
|
|
51
57
|
saveQparams() {
|
|
58
|
+
if (this.noRouteChange) return;
|
|
52
59
|
const { lang } = this.$route.query;
|
|
53
60
|
if (lang !== this.currentLang) {
|
|
54
61
|
this.$router.replace({
|
package/components/DropArea.vue
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
<v-icon :class="[dragover ? 'mt-2, mb-6' : 'mt-5']" size="60">
|
|
20
20
|
mdi-cloud-upload
|
|
21
21
|
</v-icon>
|
|
22
|
-
<p>
|
|
22
|
+
<p>{{ $t("mapo.dropArea.dropOrClick") }}</p>
|
|
23
23
|
<input
|
|
24
24
|
type="file"
|
|
25
25
|
style="display: none"
|
|
@@ -30,37 +30,45 @@
|
|
|
30
30
|
</v-row>
|
|
31
31
|
<v-virtual-scroll
|
|
32
32
|
:items="uploadedFiles"
|
|
33
|
-
:height="
|
|
34
|
-
uploadedFiles.length * 64 > 256 ? 256 : uploadedFiles.length * 64
|
|
35
|
-
"
|
|
33
|
+
:height="uploadedFiles.length * 64 > 256 ? 256 : uploadedFiles.length * 64"
|
|
36
34
|
item-height="64"
|
|
37
35
|
>
|
|
38
|
-
<template v-slot:default="
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
<template v-slot:default="ctx">
|
|
37
|
+
<slot name="list-item.before" v-bind="{...ctx, editItem, removeItem}"/>
|
|
38
|
+
<slot name="list-item" v-bind="{...ctx, editItem, removeItem}">
|
|
39
|
+
<v-list-item :key="ctx.item.info.name" class="drop-area--item">
|
|
40
|
+
<slot name="list-item.preview.before" v-bind="{...ctx, editItem, removeItem}"/>
|
|
41
|
+
<slot name="list-item.preview" v-bind="{...ctx, editItem, removeItem}">
|
|
42
|
+
<v-list-item-avatar tile v-if="ctx.item.info.objectURL">
|
|
43
|
+
<v-img :src="ctx.item.info.objectURL"></v-img>
|
|
44
|
+
</v-list-item-avatar>
|
|
45
|
+
</slot>
|
|
46
|
+
<slot name="list-item.preview.after" v-bind="{...ctx, editItem, removeItem}"/>
|
|
47
|
+
<slot name="list-item.content.before" v-bind="{...ctx, editItem, removeItem}"/>
|
|
48
|
+
<slot name="list-item.content" v-bind="{...ctx, editItem, removeItem}">
|
|
49
|
+
<v-list-item-content class="cursor-pointer" @click.stop="editItem(ctx.item)">
|
|
50
|
+
<v-list-item-title>
|
|
51
|
+
{{ ctx.item.info.name }}
|
|
52
|
+
</v-list-item-title>
|
|
53
|
+
<v-list-item-subtitle>
|
|
54
|
+
{{ ctx.item.info.type || "type/unknow" }}, {{ ctx.item.info.size }}
|
|
55
|
+
</v-list-item-subtitle>
|
|
56
|
+
</v-list-item-content>
|
|
57
|
+
</slot>
|
|
58
|
+
<slot name="list-item.content.after" v-bind="{...ctx, editItem, removeItem}"/>
|
|
59
|
+
<slot name="list-item.action.before" v-bind="{...ctx, editItem, removeItem}"/>
|
|
60
|
+
<slot name="list-item.action" v-bind="{...ctx, editItem, removeItem}">
|
|
61
|
+
<v-list-item-action>
|
|
62
|
+
<v-btn @click.stop="removeItem(ctx.item.info.name)" icon>
|
|
63
|
+
<v-icon> mdi-close-circle </v-icon>
|
|
64
|
+
</v-btn>
|
|
65
|
+
</v-list-item-action>
|
|
66
|
+
</slot>
|
|
67
|
+
<slot name="list-item.action.after" v-bind="{...ctx, editItem, removeItem}"/>
|
|
43
68
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
>
|
|
48
|
-
<v-list-item-title>
|
|
49
|
-
{{ item.info.name }}
|
|
50
|
-
</v-list-item-title>
|
|
51
|
-
<v-list-item-subtitle>
|
|
52
|
-
{{ item.info.type || "type/unknow" }}, {{ item.info.size }}
|
|
53
|
-
</v-list-item-subtitle>
|
|
54
|
-
</v-list-item-content>
|
|
55
|
-
|
|
56
|
-
<v-list-item-action>
|
|
57
|
-
<v-btn @click.stop="removeFile(item.info.name)" icon>
|
|
58
|
-
<v-icon> mdi-close-circle </v-icon>
|
|
59
|
-
</v-btn>
|
|
60
|
-
</v-list-item-action>
|
|
61
|
-
</v-list-item>
|
|
62
|
-
|
|
63
|
-
<v-divider></v-divider>
|
|
69
|
+
</v-list-item>
|
|
70
|
+
</slot>
|
|
71
|
+
<slot name="list-item.after" v-bind="{...ctx, editItem, removeItem}"/>
|
|
64
72
|
</template>
|
|
65
73
|
</v-virtual-scroll>
|
|
66
74
|
</v-card-text>
|
|
@@ -69,16 +77,12 @@
|
|
|
69
77
|
<!-- Slot to provide custom button actions inside the drop area -->
|
|
70
78
|
<slot v-bind:clearList="clearList" name="actions">
|
|
71
79
|
<!-- `<v-btn @click="clearList" icon><v-icon>mdi-close</v-icon></v-btn>` -->
|
|
72
|
-
<v-btn @click="clearList" icon>
|
|
80
|
+
<v-btn v-if="uploadedFiles && uploadedFiles.length" @click="clearList" icon>
|
|
73
81
|
<v-icon>mdi-close</v-icon>
|
|
74
82
|
</v-btn>
|
|
75
83
|
</slot>
|
|
76
84
|
</v-card-actions>
|
|
77
|
-
<v-dialog
|
|
78
|
-
v-model="editDialog"
|
|
79
|
-
v-bind="{ light, dark, elevation }"
|
|
80
|
-
max-width="500px"
|
|
81
|
-
>
|
|
85
|
+
<v-dialog v-model="editDialog" v-bind="{ light, dark, elevation }" max-width="500px">
|
|
82
86
|
<v-card v-if="editedItem">
|
|
83
87
|
<v-card-title>
|
|
84
88
|
<!-- Slot to provide custom edit card title. Exposes `editedItem`. -->
|
|
@@ -102,7 +106,7 @@
|
|
|
102
106
|
<v-col cols="12">
|
|
103
107
|
<v-text-field
|
|
104
108
|
v-model="editedItem.name"
|
|
105
|
-
label="
|
|
109
|
+
:label="$t('mapo.fileName')"
|
|
106
110
|
></v-text-field>
|
|
107
111
|
</v-col>
|
|
108
112
|
</v-row>
|
|
@@ -112,8 +116,8 @@
|
|
|
112
116
|
|
|
113
117
|
<v-card-actions>
|
|
114
118
|
<v-spacer></v-spacer>
|
|
115
|
-
<v-btn color="
|
|
116
|
-
<v-btn color="
|
|
119
|
+
<v-btn color="primary" text @click="closeEdit">{{ $t("mapo.cancel") }}</v-btn>
|
|
120
|
+
<v-btn color="primary" text @click="saveEdit">{{ $t("mapo.save") }}</v-btn>
|
|
117
121
|
</v-card-actions>
|
|
118
122
|
</v-card>
|
|
119
123
|
</v-dialog>
|
|
@@ -124,6 +128,15 @@
|
|
|
124
128
|
.cursor-pointer {
|
|
125
129
|
cursor: pointer;
|
|
126
130
|
}
|
|
131
|
+
.v-virtual-scroll__item:not(:last-child){
|
|
132
|
+
.drop-area--item{
|
|
133
|
+
border-bottom: 1px solid;
|
|
134
|
+
border-color: rgba(255, 255, 255, 0.12);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
.theme--light .v-virtual-scroll__item .drop-area--item {
|
|
138
|
+
border-color: rgba(0, 0, 0, 0.12);
|
|
139
|
+
}
|
|
127
140
|
</style>
|
|
128
141
|
|
|
129
142
|
<script>
|
|
@@ -133,8 +146,8 @@ import { humanFileSize } from "@mapomodule/utils/helpers/formatters";
|
|
|
133
146
|
* You can drag and drop over the button or click it to load the files.
|
|
134
147
|
* When files are loaded into the component it will emit an event containing all the files.
|
|
135
148
|
* This component will not take care of the actual file upload.
|
|
136
|
-
*
|
|
137
|
-
*/
|
|
149
|
+
*
|
|
150
|
+
*/
|
|
138
151
|
export default {
|
|
139
152
|
name: "DropArea",
|
|
140
153
|
props: {
|
|
@@ -173,10 +186,8 @@ export default {
|
|
|
173
186
|
clearList() {
|
|
174
187
|
this.uploadedFiles = [];
|
|
175
188
|
},
|
|
176
|
-
|
|
177
|
-
const index = this.uploadedFiles.findIndex(
|
|
178
|
-
(file) => file.info.name === fileName
|
|
179
|
-
);
|
|
189
|
+
removeItem(fileName) {
|
|
190
|
+
const index = this.uploadedFiles.findIndex((file) => file.info.name === fileName);
|
|
180
191
|
if (index > -1) this.uploadedFiles.splice(index, 1);
|
|
181
192
|
},
|
|
182
193
|
pickFile() {
|
|
@@ -193,7 +204,7 @@ export default {
|
|
|
193
204
|
if (this.uploadedFiles.length > 0) this.uploadedFiles = [];
|
|
194
205
|
if (!this.multiple && files.length > 1) {
|
|
195
206
|
this.$mapo.$snack.open({
|
|
196
|
-
message: "
|
|
207
|
+
message: this.$t("mapo.dropArea.onlyOneFile"),
|
|
197
208
|
color: "error",
|
|
198
209
|
});
|
|
199
210
|
} else {
|
|
@@ -207,11 +218,10 @@ export default {
|
|
|
207
218
|
processFile(blob) {
|
|
208
219
|
return {
|
|
209
220
|
info: {
|
|
210
|
-
objectURL: blob.type.startsWith("image/")
|
|
211
|
-
? URL.createObjectURL(blob)
|
|
212
|
-
: null,
|
|
221
|
+
objectURL: blob.type.startsWith("image/") ? URL.createObjectURL(blob) : null,
|
|
213
222
|
name: blob.name,
|
|
214
223
|
size: humanFileSize(blob.size, true, 2),
|
|
224
|
+
rawsize: blob.size,
|
|
215
225
|
type: blob.type,
|
|
216
226
|
},
|
|
217
227
|
blob,
|
|
@@ -223,10 +233,7 @@ export default {
|
|
|
223
233
|
this.editDialog = true;
|
|
224
234
|
},
|
|
225
235
|
saveEdit() {
|
|
226
|
-
this.uploadedFiles[this.editedIndex].info = Object.assign(
|
|
227
|
-
{},
|
|
228
|
-
this.editedItem
|
|
229
|
-
);
|
|
236
|
+
this.uploadedFiles[this.editedIndex].info = Object.assign({}, this.editedItem);
|
|
230
237
|
this.closeEdit();
|
|
231
238
|
},
|
|
232
239
|
closeEdit() {
|
|
@@ -240,11 +247,11 @@ export default {
|
|
|
240
247
|
watch: {
|
|
241
248
|
uploadedFiles(val) {
|
|
242
249
|
/** Fires when the list of files loaded changes
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
250
|
+
* @arg This emits a list of files in the format {info, blob} where the blob is a
|
|
251
|
+
* [File](https://developer.mozilla.org/en-US/docs/Web/API/File) and info are some custom info about the file.
|
|
252
|
+
*/
|
|
246
253
|
this.$emit("change", val);
|
|
247
254
|
},
|
|
248
255
|
},
|
|
249
256
|
};
|
|
250
|
-
</script>
|
|
257
|
+
</script>
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="row">
|
|
3
|
+
<div
|
|
4
|
+
class="col-12"
|
|
5
|
+
:class="field.class"
|
|
6
|
+
v-for="(field, index) in computedFields"
|
|
7
|
+
:key="index"
|
|
8
|
+
v-show="show(field)"
|
|
9
|
+
:style="show(field, 'visibility') ? '' : 'opacity: 0; visibility: hidden;'"
|
|
10
|
+
>
|
|
11
|
+
<FormTabs
|
|
12
|
+
v-if="field.tabs"
|
|
13
|
+
v-model="model"
|
|
14
|
+
v-bind="{ currentLang, errors, languages, readonly }"
|
|
15
|
+
:conf="field"
|
|
16
|
+
:moreSlotBindings="slotBindings"
|
|
17
|
+
>
|
|
18
|
+
<template
|
|
19
|
+
v-for="slot in nameSpacedSlots($slots, `group.${field.group.slug}.`)"
|
|
20
|
+
:slot="slot"
|
|
21
|
+
>
|
|
22
|
+
<slot :name="`group.${field.group.slug}.${slot}`"></slot>
|
|
23
|
+
</template>
|
|
24
|
+
<template
|
|
25
|
+
v-for="slot in nameSpacedSlots($scopedSlots, `group.${field.group.slug}.`)"
|
|
26
|
+
v-slot:[slot]="props"
|
|
27
|
+
>
|
|
28
|
+
<slot :name="`group.${field.group.slug}.${slot}`" v-bind="props" />
|
|
29
|
+
</template>
|
|
30
|
+
</FormTabs>
|
|
31
|
+
<FormGroup
|
|
32
|
+
v-else-if="field.group"
|
|
33
|
+
v-model="model"
|
|
34
|
+
v-bind="{ currentLang, errors, languages, readonly }"
|
|
35
|
+
:conf="field"
|
|
36
|
+
:moreSlotBindings="slotBindings"
|
|
37
|
+
>
|
|
38
|
+
<template
|
|
39
|
+
v-for="slot in nameSpacedSlots($slots, `group.${field.group.slug}.`)"
|
|
40
|
+
:slot="slot"
|
|
41
|
+
>
|
|
42
|
+
<slot :name="`group.${field.group.slug}.${slot}`"></slot>
|
|
43
|
+
</template>
|
|
44
|
+
<template
|
|
45
|
+
v-for="slot in nameSpacedSlots($scopedSlots, `group.${field.group.slug}.`)"
|
|
46
|
+
v-slot:[slot]="props"
|
|
47
|
+
>
|
|
48
|
+
<slot :name="`group.${field.group.slug}.${slot}`" v-bind="props" />
|
|
49
|
+
</template>
|
|
50
|
+
</FormGroup>
|
|
51
|
+
|
|
52
|
+
<template v-else>
|
|
53
|
+
<slot :name="field.slotName + '.before'" v-bind="{ conf: field, ...slotBindings, }" />
|
|
54
|
+
<slot
|
|
55
|
+
:name="field.slotName"
|
|
56
|
+
v-bind="{ conf: field, ...slotBindings, }"
|
|
57
|
+
>
|
|
58
|
+
<FormField
|
|
59
|
+
v-model="model"
|
|
60
|
+
v-bind="{ currentLang, errors, readonly }"
|
|
61
|
+
:langs="languages"
|
|
62
|
+
:conf="field"
|
|
63
|
+
>
|
|
64
|
+
<template
|
|
65
|
+
v-for="slot in nameSpacedSlots($slots, `fields.${field.value}.`)"
|
|
66
|
+
:slot="slot"
|
|
67
|
+
>
|
|
68
|
+
<slot :name="`fields.${field.value}.${slot}`"></slot>
|
|
69
|
+
</template>
|
|
70
|
+
<template
|
|
71
|
+
v-for="slot in nameSpacedSlots($scopedSlots, `fields.${field.value}.`)"
|
|
72
|
+
v-slot:[slot]="props"
|
|
73
|
+
>
|
|
74
|
+
<slot :name="`fields.${field.value}.${slot}`" v-bind="props" />
|
|
75
|
+
</template>
|
|
76
|
+
</FormField>
|
|
77
|
+
</slot>
|
|
78
|
+
<slot :name="field.slotName + '.after'" v-bind="{ conf: field, ...slotBindings, }" />
|
|
79
|
+
</template>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
</template>
|
|
83
|
+
<script>
|
|
84
|
+
import { nameSpacedSlots } from "@mapomodule/utils/helpers/slots";
|
|
85
|
+
import { slugify, titleCase } from "@mapomodule/utils/helpers/formatters";
|
|
86
|
+
import { debounce } from "@mapomodule/utils/helpers/debounce";
|
|
87
|
+
|
|
88
|
+
export default {
|
|
89
|
+
name: "Form",
|
|
90
|
+
data() {
|
|
91
|
+
return {
|
|
92
|
+
model: this.value,
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
props: {
|
|
96
|
+
// V-model of the object we are editing.
|
|
97
|
+
value: {
|
|
98
|
+
type: Object,
|
|
99
|
+
required: true,
|
|
100
|
+
},
|
|
101
|
+
// Set the current lang to value.
|
|
102
|
+
currentLang: {
|
|
103
|
+
type: String,
|
|
104
|
+
required: false,
|
|
105
|
+
},
|
|
106
|
+
// Makes all the fields readonly.
|
|
107
|
+
readonly: Boolean,
|
|
108
|
+
// An object representing all the errors of all fields. This means that this component will find the error of its field following the dottedPath of the value in the error dict.
|
|
109
|
+
errors: Object,
|
|
110
|
+
// Additional bindings to indrease slots capabilities
|
|
111
|
+
moreSlotBindings: Object,
|
|
112
|
+
// The main configuration that determines the arrangement of the fields in the detail layout.
|
|
113
|
+
fields: {
|
|
114
|
+
// [`DetailConfiguration`](#detailconfiguration)
|
|
115
|
+
type: Object | Array,
|
|
116
|
+
required: true,
|
|
117
|
+
},
|
|
118
|
+
// A list of languages into which the payload needs to be translated.
|
|
119
|
+
languages: {
|
|
120
|
+
type: Array,
|
|
121
|
+
default() { return this.$mapo.$options?.content?.languages || []; },
|
|
122
|
+
},
|
|
123
|
+
// Removes debounce from the emitter.
|
|
124
|
+
immediate: Boolean
|
|
125
|
+
},
|
|
126
|
+
watch: {
|
|
127
|
+
value(val) {
|
|
128
|
+
if (JSON.stringify(this.model) !== JSON.stringify(val)){
|
|
129
|
+
this.model = val;
|
|
130
|
+
this.initLang();
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
model(val) {
|
|
134
|
+
this.immediate ? this.$emit("input", val) : this.debouncedEmit("input", val);
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
methods: {
|
|
138
|
+
nameSpacedSlots,
|
|
139
|
+
initLang(lang = this.currentLang) {
|
|
140
|
+
if (lang && !this.model.translations) {
|
|
141
|
+
this.$set(this.model, "translations", {});
|
|
142
|
+
}
|
|
143
|
+
if (lang && !this.model.translations[lang]) {
|
|
144
|
+
this.$set(this.model.translations, lang, {});
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
parseConf(field, i) {
|
|
148
|
+
const conf = typeof field === "string" ? { value: field } : { ...field };
|
|
149
|
+
conf.value = conf.value || "";
|
|
150
|
+
conf.slotName = `fields.${conf.value || i}`;
|
|
151
|
+
if (this.isReadonly) {
|
|
152
|
+
conf.attrs = { ...conf.attrs, readonly: true };
|
|
153
|
+
}
|
|
154
|
+
return conf;
|
|
155
|
+
},
|
|
156
|
+
parseGroup(group, icon="mdi-cube-outline") {
|
|
157
|
+
return typeof group === "string"
|
|
158
|
+
? { name: group, slug: slugify && slugify(group), icon }
|
|
159
|
+
: { slug: slugify && slugify(group.name), icon, ...group };
|
|
160
|
+
},
|
|
161
|
+
parseTabs(tabs) {
|
|
162
|
+
return Object.keys(tabs).map(key => {
|
|
163
|
+
const tab = tabs[key]
|
|
164
|
+
return {
|
|
165
|
+
tab: {label: titleCase(key.replace(/_/, " ")), slug: key, ...tab.tab},
|
|
166
|
+
fields: this.mapConf(Array.isArray(tab) && tab || tab.fields || [])
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
},
|
|
170
|
+
parseTagsGroup(field){
|
|
171
|
+
const gType = typeof field.group
|
|
172
|
+
const slug = gType == "string" && slugify(field.group) || gType == "object" && slugify(field.group?.name) || Object.keys(field.tabs).join("-")
|
|
173
|
+
return this.parseGroup(gType == "string" ? { ...this.parseGroup(field.group, null), slug} : { slug,...field.group }, null)
|
|
174
|
+
},
|
|
175
|
+
mapConf(fields) {
|
|
176
|
+
return fields.map((f, i) =>
|
|
177
|
+
f.tabs
|
|
178
|
+
? { ...f, group: this.parseTagsGroup(f), tabs: this.parseTabs(f.tabs) }
|
|
179
|
+
: f.group
|
|
180
|
+
? { ...f, group: this.parseGroup(f.group), fields: this.mapConf(f.fields) }
|
|
181
|
+
: this.parseConf(f, i)
|
|
182
|
+
);
|
|
183
|
+
},
|
|
184
|
+
show(conf, type = "display"){
|
|
185
|
+
const prop = type == "visibility" ? "vVisible" : "vShow"
|
|
186
|
+
if (typeof conf[prop] == "function") {
|
|
187
|
+
return conf[prop]({
|
|
188
|
+
model: this.model,
|
|
189
|
+
errors: this.errors,
|
|
190
|
+
languages: this.languages,
|
|
191
|
+
currentLang: this.currentLang
|
|
192
|
+
})
|
|
193
|
+
}
|
|
194
|
+
return true
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
computed: {
|
|
198
|
+
slotBindings() {
|
|
199
|
+
return {
|
|
200
|
+
model: this.model,
|
|
201
|
+
errors: this.errors,
|
|
202
|
+
currentLang: this.currentLang,
|
|
203
|
+
langs: this.languages,
|
|
204
|
+
...this.moreSlotBindings,
|
|
205
|
+
};
|
|
206
|
+
},
|
|
207
|
+
computedFields() {
|
|
208
|
+
return this.mapConf(this.fields);
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
created(){
|
|
212
|
+
this.debouncedEmit = debounce(function (...args) {
|
|
213
|
+
this.$emit(...args);
|
|
214
|
+
}.bind(this), 300);
|
|
215
|
+
this.initLang();
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
</script>
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component
|
|
3
|
+
class="mapo-field"
|
|
4
|
+
:class="classes"
|
|
5
|
+
:is="is"
|
|
6
|
+
v-model="model"
|
|
7
|
+
v-bind="fieldAttrs"
|
|
8
|
+
>
|
|
9
|
+
<template v-for="(_, slot) in $slots" :slot="slot">
|
|
10
|
+
<!-- @vuese-ignore -->
|
|
11
|
+
<slot :name="slot"></slot>
|
|
12
|
+
</template>
|
|
13
|
+
<template v-for="(_, slot) in $scopedSlots" v-slot:[slot]="props">
|
|
14
|
+
<!-- @vuese-ignore -->
|
|
15
|
+
<slot :name="slot" v-bind="props" />
|
|
16
|
+
</template>
|
|
17
|
+
</component>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script>
|
|
21
|
+
import { getPointed, setPointed } from "@mapomodule/utils/helpers/objHelpers";
|
|
22
|
+
import { titleCase } from "@mapomodule/utils/helpers/formatters";
|
|
23
|
+
|
|
24
|
+
import defaults from "./defaults";
|
|
25
|
+
import { debounce } from "@mapomodule/utils/helpers/debounce";
|
|
26
|
+
const _ = require("lodash");
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* This is mainly an internal component. It is used by the [`DetailComponent`](/components/detail/Detail/) in order to render dinamic fields inside the main form.
|
|
30
|
+
*/
|
|
31
|
+
export default {
|
|
32
|
+
name: "FormField",
|
|
33
|
+
data() { return { model: null, }; },
|
|
34
|
+
props: {
|
|
35
|
+
// V-model of the payload needed to edit the field value in realtime.
|
|
36
|
+
value: {
|
|
37
|
+
type: Object,
|
|
38
|
+
required: true,
|
|
39
|
+
},
|
|
40
|
+
// Makes the field readonly.
|
|
41
|
+
readonly: Boolean,
|
|
42
|
+
// An object representing all the errors of all fields. This means that this component will find the error of its field following the dottedPath of the value in the error dict.
|
|
43
|
+
errors: Object,
|
|
44
|
+
// The main configuration that determines the rendering of the field. See [FieldConfiguration](/components/detail/Detail/#fieldconfiguration).
|
|
45
|
+
conf: {
|
|
46
|
+
// [`FieldConfiguration`](/components/detail/Detail/#fieldconfiguration)
|
|
47
|
+
type: Object,
|
|
48
|
+
required: true,
|
|
49
|
+
},
|
|
50
|
+
langs: {
|
|
51
|
+
type: Array,
|
|
52
|
+
default() { return this.$mapo.$options?.content?.languages || []; },
|
|
53
|
+
},
|
|
54
|
+
currentLang: String,
|
|
55
|
+
},
|
|
56
|
+
watch: {
|
|
57
|
+
value: {
|
|
58
|
+
deep: true,
|
|
59
|
+
handler(val) {
|
|
60
|
+
this.setModel(val);
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
kpointed(newValue, oldValue) {
|
|
64
|
+
if (newValue !== oldValue) {
|
|
65
|
+
this.setModel();
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
model(val) {
|
|
69
|
+
var model = this.extractValue(val);
|
|
70
|
+
if (JSON.stringify(val) !== JSON.stringify(model))
|
|
71
|
+
this.debouncedSetValue(val);
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
created() {
|
|
75
|
+
this.debouncedSetValue = debounce(function (...args) {
|
|
76
|
+
this.setValue(...args);
|
|
77
|
+
}.bind(this), 300);
|
|
78
|
+
},
|
|
79
|
+
methods: {
|
|
80
|
+
setValue(val) {
|
|
81
|
+
const old = this.extractValue(this.value);
|
|
82
|
+
setPointed(this.value, this.kpointed, this.accessor.set({ model: this.value, val }));
|
|
83
|
+
if (typeof this.conf.onChange == "function")
|
|
84
|
+
this.conf.onChange({
|
|
85
|
+
val,
|
|
86
|
+
old,
|
|
87
|
+
model: this.value,
|
|
88
|
+
currentLang: this.currentLang,
|
|
89
|
+
languages: this.langs,
|
|
90
|
+
conf: this.conf,
|
|
91
|
+
kpointed: this.kpointed,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Fired when the v-model changes.
|
|
95
|
+
// @arg Emits the entire payload modified.
|
|
96
|
+
this.$emit("input", this.value);
|
|
97
|
+
},
|
|
98
|
+
extractValue(val = this.value) {
|
|
99
|
+
return this.accessor.get({
|
|
100
|
+
model: { ...val },
|
|
101
|
+
val: getPointed({ ...val }, this.kpointed),
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
setModel(val = this.value) {
|
|
105
|
+
var model = this.extractValue(val);
|
|
106
|
+
if (val && JSON.stringify(this.model) !== JSON.stringify(model))
|
|
107
|
+
this.model = model;
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
computed: {
|
|
111
|
+
componentInfo() {
|
|
112
|
+
const originalName = this.is?.options?.name || this.is?.name || this.is;
|
|
113
|
+
const camelName = originalName.replace(/-./g, (x) => x[1].toUpperCase());
|
|
114
|
+
const kebabName = originalName.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
115
|
+
return { originalName, camelName, kebabName }
|
|
116
|
+
},
|
|
117
|
+
options(){
|
|
118
|
+
return _.merge(defaults, this.$mapo.$options?.ui?.forms?.fields);
|
|
119
|
+
},
|
|
120
|
+
defaultAccess() {
|
|
121
|
+
return this.options.accessor[this.componentInfo.camelName] || this.options.accessor[this.componentInfo.kebabName];
|
|
122
|
+
},
|
|
123
|
+
defaultAttrs() {
|
|
124
|
+
const componentAttrs = this.options.attrs[this.componentInfo.camelName] || this.options.attrs[this.componentInfo.kebabName];
|
|
125
|
+
return {...componentAttrs, ...this.options.attrs.All};
|
|
126
|
+
},
|
|
127
|
+
classes() {
|
|
128
|
+
var upperClasses = this.fieldAttrs.class;
|
|
129
|
+
if (typeof upperClasses == "string") {
|
|
130
|
+
upperClasses = { [upperClasses]: true };
|
|
131
|
+
} else if (Array.isArray(upperClasses)) {
|
|
132
|
+
upperClasses = upperClasses.reduce(
|
|
133
|
+
(acc, next) => ({ ...acc, [next]: true }),
|
|
134
|
+
{}
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
...upperClasses,
|
|
139
|
+
[`mapo-field-${this.conf.value}`]: true,
|
|
140
|
+
"mapo-field--has-errors": this.hasErrors,
|
|
141
|
+
};
|
|
142
|
+
},
|
|
143
|
+
kpointed() {
|
|
144
|
+
let kpointed = this.conf.value;
|
|
145
|
+
if (this.currentLang && !this.conf.synci18n) {
|
|
146
|
+
const base = `translations.${this.currentLang}`;
|
|
147
|
+
kpointed = kpointed ? `${base}.${kpointed}` : base;
|
|
148
|
+
}
|
|
149
|
+
return kpointed;
|
|
150
|
+
},
|
|
151
|
+
accessor() {
|
|
152
|
+
let func = function ({ val }) {
|
|
153
|
+
return val;
|
|
154
|
+
};
|
|
155
|
+
return {
|
|
156
|
+
get: func,
|
|
157
|
+
set: func,
|
|
158
|
+
...this.defaultAccess,
|
|
159
|
+
...this.conf.accessor,
|
|
160
|
+
};
|
|
161
|
+
},
|
|
162
|
+
errorMessages() {
|
|
163
|
+
return this.kpointed
|
|
164
|
+
.split(".")
|
|
165
|
+
.map((_, i, a) => a.slice(0, i + 1).join("."))
|
|
166
|
+
.reduce((acc, next) => {
|
|
167
|
+
const error = getPointed(this.errors || {}, next, []);
|
|
168
|
+
if (Array.isArray(error)) {
|
|
169
|
+
acc = [...acc, ...error];
|
|
170
|
+
} else if (typeof error == "string") {
|
|
171
|
+
acc = [...acc, error];
|
|
172
|
+
}
|
|
173
|
+
return acc;
|
|
174
|
+
}, []);
|
|
175
|
+
},
|
|
176
|
+
hasErrors() {
|
|
177
|
+
return !!this.errorMessages.length;
|
|
178
|
+
},
|
|
179
|
+
fieldAttrs() {
|
|
180
|
+
return {
|
|
181
|
+
label: this.label,
|
|
182
|
+
errorMessages: this.errorMessages,
|
|
183
|
+
hideDetails: !this.hasErrors,
|
|
184
|
+
...this.defaultAttrs,
|
|
185
|
+
readonly: this.readonly,
|
|
186
|
+
...this.conf.attrs,
|
|
187
|
+
currentLang: this.currentLang,
|
|
188
|
+
langs: this.langs,
|
|
189
|
+
};
|
|
190
|
+
},
|
|
191
|
+
label() {
|
|
192
|
+
if (this.conf.label !== undefined) {
|
|
193
|
+
return this.conf.label;
|
|
194
|
+
}
|
|
195
|
+
return titleCase(
|
|
196
|
+
(this.conf.value || "")
|
|
197
|
+
.replace(/^translations\.\w\w\./, "")
|
|
198
|
+
.split(".")
|
|
199
|
+
.join(" ")
|
|
200
|
+
.replace(/_/, " ")
|
|
201
|
+
);
|
|
202
|
+
},
|
|
203
|
+
is() {
|
|
204
|
+
const dynImport = typeof this.conf.is == "string" && this.options.components[this.conf.is.replace(/-./g, (x) => x[1].toUpperCase())];
|
|
205
|
+
return (
|
|
206
|
+
dynImport || this.conf.is ||
|
|
207
|
+
(this.conf.type && this.options.mapping[this.conf.type]) ||
|
|
208
|
+
this.options.mapping.text
|
|
209
|
+
);
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
mounted() {
|
|
213
|
+
this.setModel();
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
</script>
|