@mapomodule/uikit 1.0.0-alpha.0 → 1.0.0-alpha.12
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 +228 -0
- package/LICENSE.md +20 -0
- package/components/Detail/Detail.vue +209 -120
- package/components/Detail/DetailField.vue +57 -30
- package/components/Detail/DetailLangSwitch.vue +1 -1
- package/components/Detail/defaults.js +32 -25
- package/components/DropArea.vue +3 -3
- package/components/List/List.vue +100 -40
- package/components/List/ListActions.vue +56 -17
- package/components/List/ListFilters.vue +127 -113
- package/components/List/ListHead.vue +30 -12
- package/components/List/ListQuickEdit.vue +198 -55
- package/components/List/ListTable.vue +227 -78
- package/components/Login.vue +14 -5
- package/components/MediaManager/MediaEditor.vue +253 -107
- package/components/MediaManager/MediaFolders.vue +125 -41
- package/components/MediaManager/MediaGallery.vue +56 -52
- package/components/MediaManager/MediaManager.vue +114 -74
- package/components/MediaManager/MediaManagerDialog.vue +19 -22
- package/components/MediaManager/MediaPreview.vue +180 -0
- package/components/MediaManager/MediaUploader.vue +35 -32
- package/components/SnackBar.vue +3 -4
- package/components/fields/DateField.vue +9 -3
- package/components/fields/FileField.vue +108 -0
- package/components/fields/FksField.vue +60 -0
- package/components/fields/MediaField.vue +24 -6
- package/components/fields/MediaM2mField.vue +8 -3
- package/components/fields/SeoPreview.vue +89 -0
- package/components/fields/{TinyMce → wygEditor}/defaults.js +6 -4
- package/components/fields/{TinyMce → wygEditor}/utils/events.js +0 -0
- package/components/fields/{TinyMce → wygEditor}/utils/mapomedia.plugin.js +7 -6
- package/components/fields/{TinyMce → wygEditor}/utils/script.injector.js +0 -0
- package/components/fields/{TinyMce/TinyMce.vue → wygEditor/wygEditor.vue} +43 -21
- package/components/layout/Sidebar/Sidebar.vue +46 -24
- package/components/layout/Sidebar/SidebarFooter.vue +42 -46
- package/components/layout/Sidebar/SidebarList.vue +13 -14
- package/components/layout/Sidebar/SidebarListItem.vue +81 -38
- package/components/layout/Topbar/Topbar.vue +3 -36
- package/components/layout/routebuilder.js +1 -1
- package/defaults.js +2 -2
- package/layouts/default.vue +3 -14
- package/package.json +3 -3
- package/pages/index.vue +15 -78
- package/components/fields/M2mField.vue +0 -95
|
@@ -1,37 +1,41 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
<div v-if="userCanSee" :class="{ child, expanded, 'spider-menu': spiderMenu }">
|
|
3
|
+
<v-list-item
|
|
4
|
+
:style="indent"
|
|
5
|
+
:exact-path="expanded"
|
|
6
|
+
:input-value="!expanded && !link && activeChild"
|
|
7
|
+
@click.native="!link && (expanded = !expanded)"
|
|
8
|
+
link
|
|
9
|
+
:to="link"
|
|
10
|
+
>
|
|
11
|
+
<v-list-item-icon v-if="icon">
|
|
12
|
+
<v-icon>{{ icon }}</v-icon>
|
|
13
|
+
</v-list-item-icon>
|
|
14
|
+
<v-list-item-title>
|
|
15
|
+
{{ label }}
|
|
16
|
+
</v-list-item-title>
|
|
6
17
|
<v-icon
|
|
7
18
|
class="expand-icon"
|
|
8
19
|
v-if="childrens.length"
|
|
9
20
|
:style="rotate"
|
|
10
|
-
@click.native.prevent="expanded = !expanded"
|
|
11
|
-
>mdi-chevron-down</v-icon
|
|
12
|
-
>
|
|
13
|
-
</NuxtLink>
|
|
14
|
-
<span
|
|
15
|
-
@click.prevent="expanded = !expanded"
|
|
16
|
-
v-if="!link"
|
|
17
|
-
class="sidebar__link"
|
|
18
|
-
>
|
|
19
|
-
<v-icon v-if="icon" class="sidebar__link__icon">{{ icon }}</v-icon>
|
|
20
|
-
{{ label }}
|
|
21
|
-
<v-icon :style="rotate" class="expand-icon" v-if="childrens.length"
|
|
21
|
+
@click.native.prevent="link && (expanded = !expanded)"
|
|
22
22
|
>mdi-chevron-down</v-icon
|
|
23
23
|
>
|
|
24
|
-
</
|
|
25
|
-
|
|
24
|
+
</v-list-item>
|
|
25
|
+
|
|
26
|
+
<div :style="indent" v-if="childrens.length && expanded && !forceCollapse">
|
|
26
27
|
<SidebarListItem
|
|
27
|
-
class="sidebar__list__item"
|
|
28
28
|
v-for="(item, i) in childrens"
|
|
29
29
|
:key="i"
|
|
30
30
|
:link="item.link"
|
|
31
31
|
:label="item.label"
|
|
32
|
+
:meta="item.meta"
|
|
32
33
|
:childrens="item.childrens"
|
|
33
|
-
:depth="depth || 0 + 1"
|
|
34
|
+
:depth="(depth || 0) + 1"
|
|
34
35
|
:icon="item.icon"
|
|
36
|
+
:force-collapse="forceCollapse"
|
|
37
|
+
:spider-menu="spiderMenu"
|
|
38
|
+
child
|
|
35
39
|
/>
|
|
36
40
|
</div>
|
|
37
41
|
</div>
|
|
@@ -48,24 +52,38 @@
|
|
|
48
52
|
border-radius: 50%;
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
|
-
|
|
52
|
-
.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
.spider-menu.child {
|
|
56
|
+
.v-list-item__icon {
|
|
57
|
+
&::after {
|
|
58
|
+
content: "";
|
|
59
|
+
position: absolute;
|
|
60
|
+
width: 5px;
|
|
61
|
+
height: 30px;
|
|
62
|
+
top: -9px;
|
|
63
|
+
margin-left: -4px;
|
|
64
|
+
border-bottom: solid 3px #acacac;
|
|
65
|
+
border-left: solid 3px #acacac;
|
|
66
|
+
z-index: -1;
|
|
67
|
+
}
|
|
68
|
+
&::before {
|
|
69
|
+
content: "";
|
|
70
|
+
position: absolute;
|
|
71
|
+
width: 5px;
|
|
72
|
+
height: 10px;
|
|
73
|
+
top: 21px;
|
|
74
|
+
margin-left: -4px;
|
|
75
|
+
border-left: solid 3px #acacac;
|
|
76
|
+
z-index: -1;
|
|
66
77
|
}
|
|
67
|
-
|
|
68
|
-
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
.spider-menu.child:last-child {
|
|
81
|
+
.v-list-item__icon {
|
|
82
|
+
&::before {
|
|
83
|
+
height: 0px;
|
|
84
|
+
}
|
|
85
|
+
&::after {
|
|
86
|
+
border-bottom-left-radius: 3px;
|
|
69
87
|
}
|
|
70
88
|
}
|
|
71
89
|
}
|
|
@@ -77,11 +95,15 @@ export default {
|
|
|
77
95
|
data() {
|
|
78
96
|
return {
|
|
79
97
|
expanded: false,
|
|
98
|
+
nestDepth: 14,
|
|
80
99
|
};
|
|
81
100
|
},
|
|
82
101
|
computed: {
|
|
83
102
|
indent() {
|
|
84
|
-
return {
|
|
103
|
+
return {
|
|
104
|
+
paddingLeft: `calc(1rem + ${+this.depth * this.nestDepth}px)`,
|
|
105
|
+
marginLeft: this.depth > 1 && `calc(-1rem - ${(this.depth - 1) * this.nestDepth}px)`,
|
|
106
|
+
};
|
|
85
107
|
},
|
|
86
108
|
rotate() {
|
|
87
109
|
return {
|
|
@@ -89,13 +111,34 @@ export default {
|
|
|
89
111
|
transition: "transform 225ms cubic-bezier(0.4, 0, 0.2, 1)",
|
|
90
112
|
};
|
|
91
113
|
},
|
|
114
|
+
activeChild() {
|
|
115
|
+
return (this.childrens || []).some((child) => this.$nuxt.$route.path.startsWith(child.link));
|
|
116
|
+
},
|
|
117
|
+
userCanSee() {
|
|
118
|
+
const middleware = this.$mapo.$auth.getRouteMiddlewares({ meta: this.meta })
|
|
119
|
+
if (middleware.includes("permissions")){
|
|
120
|
+
const userInfo = this.$mapo.$auth.user.info
|
|
121
|
+
if (userInfo.is_superuser) return true
|
|
122
|
+
const { model } = this.meta?.permissions || {}
|
|
123
|
+
const userPermission = (userInfo.user_permissions || []).filter(perm => perm.codename.endsWith(model)).map(({ codename }) => codename.replace(`_${model}`, ''))
|
|
124
|
+
return userPermission.includes('view')
|
|
125
|
+
}
|
|
126
|
+
if (middleware.includes("auth")){
|
|
127
|
+
return this.$mapo.$auth.user.isLoggedIn
|
|
128
|
+
}
|
|
129
|
+
return true
|
|
130
|
+
},
|
|
92
131
|
},
|
|
93
132
|
props: {
|
|
94
133
|
link: String,
|
|
95
134
|
label: String,
|
|
96
135
|
icon: String,
|
|
97
136
|
childrens: Array,
|
|
137
|
+
meta: Object,
|
|
98
138
|
depth: Number,
|
|
139
|
+
forceCollapse: Boolean,
|
|
140
|
+
child: Boolean,
|
|
141
|
+
spiderMenu: Boolean,
|
|
99
142
|
},
|
|
100
143
|
};
|
|
101
144
|
</script>
|
|
@@ -5,46 +5,13 @@
|
|
|
5
5
|
app
|
|
6
6
|
flat
|
|
7
7
|
dense
|
|
8
|
-
class="topbar__wrapper"
|
|
9
8
|
>
|
|
10
9
|
<v-app-bar-nav-icon @click.stop="drawerReverse()" />
|
|
11
10
|
<v-toolbar-title v-text="title" />
|
|
12
|
-
<v-spacer />
|
|
13
|
-
|
|
14
|
-
<div class="topbar__user">
|
|
15
|
-
<span class="topbar__user__name">
|
|
16
|
-
Ciao, {{ this.$mapo.$auth.user.username }}
|
|
17
|
-
</span>
|
|
18
|
-
<v-btn
|
|
19
|
-
class="topbar__user__btn"
|
|
20
|
-
icon
|
|
21
|
-
>
|
|
22
|
-
<v-icon>mdi-account</v-icon>
|
|
23
|
-
</v-btn>
|
|
24
|
-
</div>
|
|
25
11
|
</v-app-bar>
|
|
26
12
|
</template>
|
|
27
13
|
|
|
28
|
-
<style lang="scss" scoped>
|
|
29
|
-
@import '@mapomodule/uikit/assets/variables.scss';
|
|
30
|
-
|
|
31
|
-
.topbar {
|
|
32
|
-
&__wrapper {
|
|
33
|
-
// background: $black!important;
|
|
34
|
-
// color: $white;
|
|
35
|
-
}
|
|
36
|
-
&__user {
|
|
37
|
-
display: flex;
|
|
38
|
-
align-items: center;
|
|
39
|
-
&__name {
|
|
40
|
-
margin-right: 0.5rem;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
</style>
|
|
45
|
-
|
|
46
14
|
<script>
|
|
47
|
-
import { mapMutations } from 'vuex'
|
|
48
15
|
|
|
49
16
|
export default {
|
|
50
17
|
name: "Topbar",
|
|
@@ -52,9 +19,9 @@ export default {
|
|
|
52
19
|
title: String
|
|
53
20
|
},
|
|
54
21
|
methods: {
|
|
55
|
-
drawerReverse
|
|
22
|
+
drawerReverse() {
|
|
56
23
|
this.$store.dispatch("mapo/app/toggleSidebarDrawer");
|
|
57
|
-
}
|
|
58
|
-
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
59
26
|
};
|
|
60
27
|
</script>
|
|
@@ -13,7 +13,7 @@ function buildRoutes(routes, defaultIcon) {
|
|
|
13
13
|
.map((route) => {
|
|
14
14
|
const { meta, path, name } = route
|
|
15
15
|
const label = (route.meta && route.meta.label) || (path.split("/").pop() || "").replaceAll(':', '').replaceAll('-', ' ') || 'home'
|
|
16
|
-
const icon =
|
|
16
|
+
const icon = route.meta && route.meta.icon !== undefined ? route.meta.icon : getDefaultIcon({ route, label }, defaultIcon)
|
|
17
17
|
return { label, icon, meta, name, link: path, relPath: path.slice(1), childrens: [] };
|
|
18
18
|
}),
|
|
19
19
|
defaultIcon
|
package/defaults.js
CHANGED
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
dark: true,
|
|
7
7
|
themes: {
|
|
8
8
|
dark: {
|
|
9
|
-
primary: '#
|
|
9
|
+
primary: '#51beaa',
|
|
10
10
|
accent: colors.grey.darken3,
|
|
11
11
|
secondary: colors.amber.darken3,
|
|
12
12
|
info: colors.teal.lighten1,
|
|
@@ -15,7 +15,7 @@ export default {
|
|
|
15
15
|
success: colors.green.accent3
|
|
16
16
|
},
|
|
17
17
|
light: {
|
|
18
|
-
primary: '#
|
|
18
|
+
primary: '#51beaa',
|
|
19
19
|
accent: colors.indigo.accent1,
|
|
20
20
|
secondary: colors.amber.accent2,
|
|
21
21
|
info: colors.teal.lighten1,
|
package/layouts/default.vue
CHANGED
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<v-app
|
|
2
|
+
<v-app>
|
|
3
3
|
<Sidebar />
|
|
4
4
|
<Topbar :title="title" :drawer="this.$store.getters['mapo/app/drawer']" />
|
|
5
5
|
<v-main>
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
<root-components />
|
|
9
|
-
</v-container>
|
|
6
|
+
<nuxt />
|
|
7
|
+
<root-components />
|
|
10
8
|
</v-main>
|
|
11
9
|
</v-app>
|
|
12
10
|
</template>
|
|
13
11
|
|
|
14
|
-
<style lang="scss" scoped>
|
|
15
|
-
@import "@mapomodule/uikit/assets/variables.scss";
|
|
16
|
-
|
|
17
|
-
.app {
|
|
18
|
-
&__wrapper {
|
|
19
|
-
// background: $w-1;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
</style>
|
|
23
12
|
|
|
24
13
|
<script>
|
|
25
14
|
export default {
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapomodule/uikit",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.12",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "This is part of Mapo nuxt module. Injects Mapo ui components in the nuxt component discovery system.",
|
|
6
6
|
"author": "bnznamco <gabriele.baldi.01@gmail.com>",
|
|
7
7
|
"repository": "https://github.com/lotrekagency/mapo",
|
|
8
8
|
"main": "./module.js",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@mapomodule/utils": "^1.0.0-alpha.
|
|
10
|
+
"@mapomodule/utils": "^1.0.0-alpha.10",
|
|
11
11
|
"@nuxtjs/vuetify": "^1.12.1"
|
|
12
12
|
},
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "51a40dbe669f634f9338f5eb0861550d1a554776"
|
|
17
17
|
}
|
package/pages/index.vue
CHANGED
|
@@ -1,81 +1,18 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<v-row justify="center" align="center">
|
|
3
3
|
<v-col cols="12" sm="8" md="12">
|
|
4
|
-
|
|
5
|
-
<v-btn
|
|
6
|
-
class="elevation-0 rounded-0"
|
|
7
|
-
color="primary"
|
|
8
|
-
nuxt
|
|
9
|
-
to="/login"
|
|
10
|
-
style="margin-top: 1rem"
|
|
11
|
-
>
|
|
12
|
-
Test Login Page
|
|
13
|
-
</v-btn>
|
|
14
|
-
<hr />
|
|
15
|
-
|
|
16
4
|
<div class="mapo-info">
|
|
17
|
-
<h1 id="mapo">
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
<
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
</
|
|
28
|
-
<p>$ yarn add mapomodule</p>
|
|
29
|
-
<h2 id="working-on-the-project">Working on the project</h2>
|
|
30
|
-
<h3 id="how-to-contribute">How to contribute</h3>
|
|
31
|
-
<p>
|
|
32
|
-
Feel free to contribute to the project by making a
|
|
33
|
-
<a
|
|
34
|
-
href="https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request"
|
|
35
|
-
>Pull Request</a
|
|
36
|
-
>. Here's an example for a branch naming:
|
|
37
|
-
</p>
|
|
38
|
-
<p><code>feature/<branch name></code></p>
|
|
39
|
-
<p>
|
|
40
|
-
Once you're done with your work and are ready to make a Pull
|
|
41
|
-
Request, set the reviewers to Gabriele Baldi (bnznamco) and Andrea
|
|
42
|
-
Morosi (andreamorosi).
|
|
43
|
-
</p>
|
|
44
|
-
<h3 id="documenting-components">Documenting components</h3>
|
|
45
|
-
<p>
|
|
46
|
-
Always write some documentation regarding the components you're
|
|
47
|
-
developing. We are working on a StorybookJS implementation, which is
|
|
48
|
-
going to help in this regard.
|
|
49
|
-
</p>
|
|
50
|
-
<h3 id="how-to-edit-and-add-configurations-and-settings">
|
|
51
|
-
How to edit and add configurations and settings
|
|
52
|
-
</h3>
|
|
53
|
-
<p>
|
|
54
|
-
Our library doesn't have a standard nuxt.config.js file, so in
|
|
55
|
-
order to add the stuff which usually goes there you're going to
|
|
56
|
-
either work on the defaults.js file, for configurations and such, or
|
|
57
|
-
on the module.js file for modules and plugins. Both files are located
|
|
58
|
-
in the root of the project.
|
|
59
|
-
</p>
|
|
60
|
-
<h3 id="urls-and-accessing-resources">URLs and accessing resources</h3>
|
|
61
|
-
<p>
|
|
62
|
-
We are using an alias (mapo) to access resources and files. Here's
|
|
63
|
-
an example featuring a SCSS import in a component file:
|
|
64
|
-
</p>
|
|
65
|
-
<p>
|
|
66
|
-
<code>@import "@mapomodule/uikit/assets/custom-style.scss";</code>
|
|
67
|
-
</p>
|
|
68
|
-
<h2 id="external-resources">External resources</h2>
|
|
69
|
-
<p>
|
|
70
|
-
For detailed explanation on how things work, check out
|
|
71
|
-
<a href="https://nuxtjs.org">Nuxt.js docs</a>.
|
|
72
|
-
</p>
|
|
73
|
-
<p>
|
|
74
|
-
<a
|
|
75
|
-
href="https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request"
|
|
76
|
-
>https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request</a
|
|
77
|
-
>
|
|
78
|
-
</p>
|
|
5
|
+
<h1 id="mapo">
|
|
6
|
+
<code>mapomodule {{ version }}</code>
|
|
7
|
+
</h1>
|
|
8
|
+
<br>
|
|
9
|
+
<br>
|
|
10
|
+
<code>Congratulations!! 🥳 You succesfully installed Mapo! </code>
|
|
11
|
+
<br>
|
|
12
|
+
<br>
|
|
13
|
+
<code>
|
|
14
|
+
## TODO INSERT HERE A LITTLE TUTORIAL.
|
|
15
|
+
</code>
|
|
79
16
|
</div>
|
|
80
17
|
</v-col>
|
|
81
18
|
</v-row>
|
|
@@ -83,16 +20,16 @@
|
|
|
83
20
|
|
|
84
21
|
<style scoped>
|
|
85
22
|
.mapo-info {
|
|
86
|
-
background: #333333;
|
|
87
23
|
border-radius: 8px;
|
|
88
24
|
margin: 10px 5%;
|
|
89
25
|
padding: 10px;
|
|
90
26
|
}
|
|
91
27
|
</style>
|
|
92
28
|
<script>
|
|
29
|
+
import { version } from "mapomodule/package.json";
|
|
93
30
|
export default {
|
|
94
|
-
data() {
|
|
95
|
-
|
|
96
|
-
},
|
|
31
|
+
data: () => ({
|
|
32
|
+
version: version
|
|
33
|
+
}),
|
|
97
34
|
};
|
|
98
35
|
</script>
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<v-checkbox
|
|
4
|
-
v-for="(option, index) in options"
|
|
5
|
-
:key="index"
|
|
6
|
-
:label="option[itemText]"
|
|
7
|
-
:input-value="isSelected(option)"
|
|
8
|
-
@change="changed($event, option)"
|
|
9
|
-
>
|
|
10
|
-
</v-checkbox>
|
|
11
|
-
</div>
|
|
12
|
-
</template>
|
|
13
|
-
|
|
14
|
-
<script>
|
|
15
|
-
/**
|
|
16
|
-
* This component is made to simplify Many To Many associations. With this component you can modify an array selecting items from a list of checkboxes.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
export default {
|
|
20
|
-
name: "M2mField",
|
|
21
|
-
data() {
|
|
22
|
-
return {
|
|
23
|
-
proxyItems: []
|
|
24
|
-
};
|
|
25
|
-
},
|
|
26
|
-
props: {
|
|
27
|
-
// V-model property. It is the array to be modified.
|
|
28
|
-
value: {
|
|
29
|
-
type: Array,
|
|
30
|
-
required: true
|
|
31
|
-
},
|
|
32
|
-
// This is the array of options from which you can choose.
|
|
33
|
-
items: {
|
|
34
|
-
type: Array,
|
|
35
|
-
default: () => []
|
|
36
|
-
},
|
|
37
|
-
itemText: {
|
|
38
|
-
type: String,
|
|
39
|
-
default: "text"
|
|
40
|
-
},
|
|
41
|
-
itemValue: {
|
|
42
|
-
type: String,
|
|
43
|
-
default: "*"
|
|
44
|
-
},
|
|
45
|
-
lookup: {
|
|
46
|
-
type: String,
|
|
47
|
-
default: "id"
|
|
48
|
-
},
|
|
49
|
-
endPoint: String,
|
|
50
|
-
mapping: {
|
|
51
|
-
type: Function,
|
|
52
|
-
default: items => items
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
computed: {
|
|
56
|
-
hasKey() {
|
|
57
|
-
return this.itemValue !== "*";
|
|
58
|
-
},
|
|
59
|
-
options() {
|
|
60
|
-
return this.mapping(this.proxyItems);
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
methods: {
|
|
64
|
-
isSelected(option) {
|
|
65
|
-
return !!(this.value || []).find(
|
|
66
|
-
e => e[this.lookup] == option[this.lookup]
|
|
67
|
-
);
|
|
68
|
-
},
|
|
69
|
-
changed(value, option) {
|
|
70
|
-
let val = this.hasKey ? option[this.itemValue] : option;
|
|
71
|
-
let newArr = [...(this.value || [])];
|
|
72
|
-
if (value) {
|
|
73
|
-
newArr.push(val);
|
|
74
|
-
} else {
|
|
75
|
-
let i = newArr.findIndex(e => e[this.lookup] == option[this.lookup]);
|
|
76
|
-
i !== -1 && newArr.splice(i, 1);
|
|
77
|
-
}
|
|
78
|
-
this.$emit("input", newArr);
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
watch: {
|
|
82
|
-
items(val) {
|
|
83
|
-
this.proxyItems = val;
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
mounted() {
|
|
87
|
-
if (this.endPoint && (!this.items || !this.items.length)) {
|
|
88
|
-
this.$mapo.$api
|
|
89
|
-
.crud(this.endPoint)
|
|
90
|
-
.list()
|
|
91
|
-
.then(res => (this.proxyItems = res));
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
</script>
|