@mapomodule/uikit 1.0.0-alpha.9 → 2.0.0-beta.1
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/README.md +167 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +18 -0
- package/dist/module.d.cts +2 -0
- package/dist/module.d.mts +2 -0
- package/dist/module.d.ts +2 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +18 -0
- package/dist/types.d.mts +13 -0
- package/package.json +63 -10
- package/src/index.ts +10 -0
- package/src/module.ts +181 -0
- package/src/runtime/assets/main.css +59 -0
- package/src/runtime/components/MapoConfirmDialog.vue +34 -0
- package/src/runtime/components/MapoDetail.vue +861 -0
- package/src/runtime/components/MapoDetailLangSwitch.vue +166 -0
- package/src/runtime/components/MapoList.vue +339 -0
- package/src/runtime/components/MapoListActions.vue +152 -0
- package/src/runtime/components/MapoListFilters.vue +289 -0
- package/src/runtime/components/MapoListHead.vue +12 -0
- package/src/runtime/components/MapoListQuickEdit.vue +163 -0
- package/src/runtime/components/MapoListTable.vue +926 -0
- package/src/runtime/components/MapoListTabs.vue +48 -0
- package/src/runtime/components/MapoLogin.vue +209 -0
- package/src/runtime/components/MapoLogoutButton.vue +46 -0
- package/src/runtime/components/MapoRootComponents.vue +9 -0
- package/src/runtime/components/MapoSidebar.vue +112 -0
- package/src/runtime/components/MapoSidebarList.vue +35 -0
- package/src/runtime/components/MapoSidebarListItem.vue +79 -0
- package/src/runtime/components/MapoSidebarProfile.vue +57 -0
- package/src/runtime/components/MapoSnackBar.vue +42 -0
- package/src/runtime/components/MapoThemeToggle.vue +23 -0
- package/src/runtime/components/MapoTopbar.vue +36 -0
- package/src/runtime/layouts/default.vue +53 -0
- package/src/runtime/layouts/empty.vue +9 -0
- package/src/runtime/page-meta.nuxt.d.ts +45 -0
- package/src/runtime/pages/index.vue +14 -0
- package/src/runtime/pages/login.vue +7 -0
- package/src/runtime/types/list.ts +64 -0
- package/CHANGELOG.md +0 -177
- package/LICENSE.md +0 -20
- package/assets/mixins.scss +0 -22
- package/assets/variables.scss +0 -18
- package/components/ConfirmDialog.vue +0 -152
- package/components/Detail/Detail.vue +0 -566
- package/components/Detail/DetailField.vue +0 -142
- package/components/Detail/DetailLangSwitch.vue +0 -72
- package/components/Detail/defaults.js +0 -57
- package/components/DropArea.vue +0 -250
- package/components/List/List.vue +0 -254
- package/components/List/ListActions.vue +0 -164
- package/components/List/ListFilters.vue +0 -334
- package/components/List/ListHead.vue +0 -67
- package/components/List/ListQuickEdit.vue +0 -302
- package/components/List/ListTable.vue +0 -406
- package/components/List/ListTabs.vue +0 -65
- package/components/Login.vue +0 -124
- package/components/Logo.vue +0 -79
- package/components/LogoutButton.vue +0 -39
- package/components/MediaManager/MediaEditor.vue +0 -309
- package/components/MediaManager/MediaFolders.vue +0 -263
- package/components/MediaManager/MediaGallery.vue +0 -206
- package/components/MediaManager/MediaManager.vue +0 -233
- package/components/MediaManager/MediaManagerDialog.vue +0 -96
- package/components/MediaManager/MediaPreview.vue +0 -180
- package/components/MediaManager/MediaUploader.vue +0 -165
- package/components/RootComponents.vue +0 -25
- package/components/SnackBar.vue +0 -70
- package/components/fields/DateField.vue +0 -74
- package/components/fields/FksField.vue +0 -60
- package/components/fields/MediaField.vue +0 -213
- package/components/fields/MediaM2mField.vue +0 -243
- package/components/fields/SeoPreview.vue +0 -89
- package/components/fields/wygEditor/defaults.js +0 -55
- package/components/fields/wygEditor/utils/events.js +0 -64
- package/components/fields/wygEditor/utils/mapomedia.plugin.js +0 -31
- package/components/fields/wygEditor/utils/script.injector.js +0 -29
- package/components/fields/wygEditor/wygEditor.vue +0 -196
- package/components/layout/Sidebar/Sidebar.vue +0 -80
- package/components/layout/Sidebar/SidebarFooter.vue +0 -71
- package/components/layout/Sidebar/SidebarList.vue +0 -44
- package/components/layout/Sidebar/SidebarListItem.vue +0 -144
- package/components/layout/Topbar/Topbar.vue +0 -27
- package/components/layout/routebuilder.js +0 -48
- package/defaults.js +0 -29
- package/layouts/default.vue +0 -21
- package/layouts/empty.vue +0 -6
- package/layouts/error.vue +0 -45
- package/module.js +0 -78
- package/pages/index.vue +0 -35
- package/pages/login.vue +0 -10
- package/static/favicon.ico +0 -0
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<v-container>
|
|
3
|
-
<drop-area @change="updateMediaList($event)" multiple>
|
|
4
|
-
<template v-slot:actions="{ clearList }">
|
|
5
|
-
<div v-if="mediaList && mediaList.length">
|
|
6
|
-
<v-btn @click="clearList" icon>
|
|
7
|
-
<v-icon ref="closeButton">mdi-close</v-icon>
|
|
8
|
-
</v-btn>
|
|
9
|
-
<v-btn @click="updateAll" icon>
|
|
10
|
-
<v-icon>mdi-upload</v-icon>
|
|
11
|
-
</v-btn>
|
|
12
|
-
</div>
|
|
13
|
-
</template>
|
|
14
|
-
<template v-slot:editContent="{ editedItem }">
|
|
15
|
-
<v-container>
|
|
16
|
-
<v-row>
|
|
17
|
-
<v-col cols="12">
|
|
18
|
-
<v-select
|
|
19
|
-
v-model="editedItem.folder"
|
|
20
|
-
:items="folderOptions"
|
|
21
|
-
label="Folder"
|
|
22
|
-
></v-select>
|
|
23
|
-
</v-col>
|
|
24
|
-
<v-col cols="12">
|
|
25
|
-
<v-text-field
|
|
26
|
-
v-model="editedItem.name"
|
|
27
|
-
label="Name"
|
|
28
|
-
></v-text-field>
|
|
29
|
-
</v-col>
|
|
30
|
-
<v-col cols="12">
|
|
31
|
-
<v-text-field
|
|
32
|
-
v-model="editedItem.title"
|
|
33
|
-
label="Title"
|
|
34
|
-
></v-text-field>
|
|
35
|
-
</v-col>
|
|
36
|
-
<v-col cols="12">
|
|
37
|
-
<v-text-field
|
|
38
|
-
v-model="editedItem.description"
|
|
39
|
-
label="Description"
|
|
40
|
-
></v-text-field>
|
|
41
|
-
</v-col>
|
|
42
|
-
<v-col cols="12">
|
|
43
|
-
<v-text-field
|
|
44
|
-
v-model="editedItem.alt_text"
|
|
45
|
-
label="Alt name"
|
|
46
|
-
></v-text-field>
|
|
47
|
-
</v-col>
|
|
48
|
-
</v-row>
|
|
49
|
-
</v-container>
|
|
50
|
-
</template>
|
|
51
|
-
</drop-area>
|
|
52
|
-
<div v-if="mediaList.length" class="mt-3">
|
|
53
|
-
<p class="text-right mr-3 mb-2">{{ completed }}</p>
|
|
54
|
-
<v-progress-linear :value="progress"></v-progress-linear>
|
|
55
|
-
</div>
|
|
56
|
-
</v-container>
|
|
57
|
-
</template>
|
|
58
|
-
|
|
59
|
-
<script>
|
|
60
|
-
export default {
|
|
61
|
-
name: "MediaUploader",
|
|
62
|
-
data() {
|
|
63
|
-
return {
|
|
64
|
-
count: 0,
|
|
65
|
-
progress: 0,
|
|
66
|
-
mediaList: [],
|
|
67
|
-
_mediaFileCrud: null
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
props: {
|
|
71
|
-
parentFolder: {
|
|
72
|
-
type: Object
|
|
73
|
-
},
|
|
74
|
-
folders: {
|
|
75
|
-
type: Array,
|
|
76
|
-
default: () => []
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
computed: {
|
|
80
|
-
mediaFileCrud() {
|
|
81
|
-
this._mediaFileCrud =
|
|
82
|
-
this._mediaFileCrud ||
|
|
83
|
-
this.$mapo.$api.crud("api/camomilla/media");
|
|
84
|
-
return this._mediaFileCrud;
|
|
85
|
-
},
|
|
86
|
-
completed() {
|
|
87
|
-
return `${this.count}/${this.mediaList.length}`;
|
|
88
|
-
},
|
|
89
|
-
folderOptions() {
|
|
90
|
-
return [
|
|
91
|
-
{
|
|
92
|
-
text: (this.parentFolder && this.parentFolder.path) || "/",
|
|
93
|
-
value: (this.parentFolder && this.parentFolder.id) || null
|
|
94
|
-
},
|
|
95
|
-
...this.folders.map(folder => ({
|
|
96
|
-
text: folder.path,
|
|
97
|
-
value: folder.id
|
|
98
|
-
}))
|
|
99
|
-
];
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
methods: {
|
|
103
|
-
updateMediaList(mediaList) {
|
|
104
|
-
this.mediaList = mediaList;
|
|
105
|
-
this.mediaList.forEach(media => {
|
|
106
|
-
media.info.title = media.info.title || media.info.name;
|
|
107
|
-
media.info.alt_text = media.info.alt_text || media.info.name;
|
|
108
|
-
media.info.description = media.info.description || media.info.name;
|
|
109
|
-
media.info.folder =
|
|
110
|
-
media.info.folder ||
|
|
111
|
-
(this.parentFolder && this.parentFolder.id) ||
|
|
112
|
-
null;
|
|
113
|
-
});
|
|
114
|
-
this.count = 0;
|
|
115
|
-
this.progress = 0;
|
|
116
|
-
},
|
|
117
|
-
updateAll() {
|
|
118
|
-
return Promise.all(
|
|
119
|
-
this.mediaList.map(media =>
|
|
120
|
-
this.uploadMedia(
|
|
121
|
-
Object.assign(
|
|
122
|
-
{ file: media.blob },
|
|
123
|
-
{
|
|
124
|
-
title: media.info.title,
|
|
125
|
-
alt_text: media.info.alt_text,
|
|
126
|
-
description: media.info.description,
|
|
127
|
-
folder: media.info.folder
|
|
128
|
-
}
|
|
129
|
-
)
|
|
130
|
-
)
|
|
131
|
-
)
|
|
132
|
-
).then(response => {
|
|
133
|
-
if (this.mediaList && this.mediaList.length) {
|
|
134
|
-
this.$mapo.$snack.open({
|
|
135
|
-
message: `${response.length ||
|
|
136
|
-
this.mediaList.length} files succesfully uploaded`
|
|
137
|
-
});
|
|
138
|
-
this.$emit("Upload", (response.length && response) || this.mediaList);
|
|
139
|
-
this.$refs.closeButton.$el.click();
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
},
|
|
143
|
-
uploadMedia(media) {
|
|
144
|
-
const index = this.mediaList.findIndex(el => el.blob === media.file);
|
|
145
|
-
const payload = this.$mapo.$api.multipart(media, ["file"]);
|
|
146
|
-
const conf = {
|
|
147
|
-
headers: { "Content-Type": "multipart/form-data" },
|
|
148
|
-
onUploadProgress: function(event) {
|
|
149
|
-
this.mediaList[index].progress = Math.ceil(
|
|
150
|
-
(event.loaded / event.total) * 100
|
|
151
|
-
);
|
|
152
|
-
this.progress =
|
|
153
|
-
this.mediaList.reduce((acc, media) => acc + media.progress, 0) /
|
|
154
|
-
this.mediaList.length;
|
|
155
|
-
this.count = this.mediaList.reduce(
|
|
156
|
-
(acc, media) => acc + (media.progress === 100),
|
|
157
|
-
0
|
|
158
|
-
);
|
|
159
|
-
}.bind(this)
|
|
160
|
-
};
|
|
161
|
-
return this.mediaFileCrud.create(payload, conf);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
</script>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<SnackBar />
|
|
4
|
-
<ConfirmDialog ref="rootConfirmDialog" />
|
|
5
|
-
</div>
|
|
6
|
-
</template>
|
|
7
|
-
|
|
8
|
-
<script>
|
|
9
|
-
export default {
|
|
10
|
-
methods: {
|
|
11
|
-
initConfirmDialog(count = 10) {
|
|
12
|
-
this.$nextTick(() => {
|
|
13
|
-
if (this.$refs.rootConfirmDialog) {
|
|
14
|
-
this.$mapo.$confirm = this.$refs.rootConfirmDialog;
|
|
15
|
-
} else if (count > 0) {
|
|
16
|
-
this.initConfirmDialog(count - 1);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
mounted: function() {
|
|
22
|
-
this.initConfirmDialog();
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
</script>
|
package/components/SnackBar.vue
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<v-snackbar v-model="snackbar">
|
|
3
|
-
{{ message }}
|
|
4
|
-
<template v-slot:action="{ attrs }">
|
|
5
|
-
<v-btn :color="color" text v-bind="attrs" @click="closeSnack">
|
|
6
|
-
Close
|
|
7
|
-
</v-btn>
|
|
8
|
-
</template>
|
|
9
|
-
</v-snackbar>
|
|
10
|
-
</template>
|
|
11
|
-
|
|
12
|
-
<script>
|
|
13
|
-
import { mapGetters } from "vuex";
|
|
14
|
-
/**
|
|
15
|
-
* @vuese
|
|
16
|
-
* This component is embedded in the default layout.
|
|
17
|
-
* It remains hidden watching for changes in vuex status 'mapo/app/snackbar'.
|
|
18
|
-
* If a message is gained from the vuex getter, it shows up revealing the message.<br><br>
|
|
19
|
-
* To open the snakbar from wherever you want, you can refer to [this.$mapo.$snack.open](/core/#snack);
|
|
20
|
-
*/
|
|
21
|
-
export default {
|
|
22
|
-
name: "SnackBar",
|
|
23
|
-
data: () => ({
|
|
24
|
-
snackbar: false,
|
|
25
|
-
message: null,
|
|
26
|
-
color: "primary",
|
|
27
|
-
}),
|
|
28
|
-
computed: {
|
|
29
|
-
...mapGetters({
|
|
30
|
-
snackbarMessage: "mapo/app/snackbar",
|
|
31
|
-
}),
|
|
32
|
-
},
|
|
33
|
-
methods: {
|
|
34
|
-
closeSnack() {
|
|
35
|
-
this.snackbar = false;
|
|
36
|
-
this.message = null;
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
watch: {
|
|
41
|
-
snackbar(val) {
|
|
42
|
-
if (!val) {
|
|
43
|
-
this.$mapo.$snack.close();
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
snackbarMessage(val) {
|
|
47
|
-
if (val) {
|
|
48
|
-
this.snackbar = true;
|
|
49
|
-
this.message = val.message;
|
|
50
|
-
this.color = val.color || "primary";
|
|
51
|
-
} else {
|
|
52
|
-
this.closeSnack();
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
</script>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
<docs>
|
|
61
|
-
### Example usage:
|
|
62
|
-
|
|
63
|
-
```js
|
|
64
|
-
this.$mapo.$snack.open({
|
|
65
|
-
message: "Only one file can be uploaded at a time..",
|
|
66
|
-
color: "error",
|
|
67
|
-
});
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
</docs>
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<v-menu
|
|
4
|
-
ref="menu"
|
|
5
|
-
v-model="menu"
|
|
6
|
-
:close-on-content-click="false"
|
|
7
|
-
:return-value.sync="model"
|
|
8
|
-
transition="scale-transition"
|
|
9
|
-
offset-y
|
|
10
|
-
min-width="auto"
|
|
11
|
-
>
|
|
12
|
-
<template v-slot:activator="{ on, attrs }">
|
|
13
|
-
<v-text-field
|
|
14
|
-
v-model="model"
|
|
15
|
-
prepend-inner-icon="mdi-calendar"
|
|
16
|
-
readonly
|
|
17
|
-
v-bind="{ ...$attrs, ...attrs }"
|
|
18
|
-
v-on="readonly ? undefined : on"
|
|
19
|
-
:clearable="!readonly"
|
|
20
|
-
class="rounded-0"
|
|
21
|
-
></v-text-field>
|
|
22
|
-
</template>
|
|
23
|
-
<v-date-picker v-model="model" :range="range" no-title>
|
|
24
|
-
<v-btn text color="primary" @click="menu = false"> Cancel </v-btn>
|
|
25
|
-
<v-btn text color="primary" @click="$refs.menu.save(model)"> OK </v-btn>
|
|
26
|
-
</v-date-picker>
|
|
27
|
-
</v-menu>
|
|
28
|
-
</div>
|
|
29
|
-
</template>
|
|
30
|
-
|
|
31
|
-
<script>
|
|
32
|
-
/**
|
|
33
|
-
* This component is used to edit a date in iso format. It is a combination of "v-text-field" and "v-date-picker".
|
|
34
|
-
*/
|
|
35
|
-
export default {
|
|
36
|
-
name: "DateField",
|
|
37
|
-
data() {
|
|
38
|
-
return {
|
|
39
|
-
model: null,
|
|
40
|
-
menu: null,
|
|
41
|
-
};
|
|
42
|
-
},
|
|
43
|
-
props: {
|
|
44
|
-
// V-model property. Is the date to be modified. It can be also array in case of date range.
|
|
45
|
-
value: {
|
|
46
|
-
// `String|Array`
|
|
47
|
-
type: String | Array,
|
|
48
|
-
},
|
|
49
|
-
// Determines if we need to work with date ranges.
|
|
50
|
-
range: {
|
|
51
|
-
type: Boolean,
|
|
52
|
-
default: false
|
|
53
|
-
},
|
|
54
|
-
// This set the component status to readonly, stopping the user interaction.
|
|
55
|
-
readonly: {
|
|
56
|
-
type: Boolean,
|
|
57
|
-
default: false,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
watch: {
|
|
61
|
-
value(val) {
|
|
62
|
-
if (this.model !== val) this.model = val;
|
|
63
|
-
},
|
|
64
|
-
model(val) {
|
|
65
|
-
// Fired when the v-model changes
|
|
66
|
-
//@arg Emits the date or the date range edited.
|
|
67
|
-
this.$emit("input", val);
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
mounted() {
|
|
71
|
-
this.model = this.value;
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
</script>
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<v-autocomplete v-bind="fieldAttrs" v-model="model" :items="options"></v-autocomplete>
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script>
|
|
6
|
-
/**
|
|
7
|
-
* 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.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
name: "FksField",
|
|
12
|
-
data() {
|
|
13
|
-
return {
|
|
14
|
-
model: null,
|
|
15
|
-
options: [],
|
|
16
|
-
};
|
|
17
|
-
},
|
|
18
|
-
props: {
|
|
19
|
-
// V-model property. It is the array to be modified.
|
|
20
|
-
value: {
|
|
21
|
-
type: Object | Array | null,
|
|
22
|
-
required: true,
|
|
23
|
-
},
|
|
24
|
-
// This is the array of options from which you can choose.
|
|
25
|
-
items: {
|
|
26
|
-
type: Array,
|
|
27
|
-
default: () => [],
|
|
28
|
-
},
|
|
29
|
-
endpoint: String,
|
|
30
|
-
},
|
|
31
|
-
computed: {
|
|
32
|
-
fieldAttrs() {
|
|
33
|
-
return {
|
|
34
|
-
chips: this.$attrs.multiple === false ? false : true,
|
|
35
|
-
multiple: true,
|
|
36
|
-
...this.$attrs,
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
watch: {
|
|
41
|
-
items(val) {
|
|
42
|
-
this.options = val || [];
|
|
43
|
-
},
|
|
44
|
-
value(val) {
|
|
45
|
-
this.model = val;
|
|
46
|
-
},
|
|
47
|
-
model(val) {
|
|
48
|
-
this.$emit("input", val);
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
mounted() {
|
|
52
|
-
if (this.endpoint) {
|
|
53
|
-
this.$mapo.$api
|
|
54
|
-
.crud(this.endpoint)
|
|
55
|
-
.list()
|
|
56
|
-
.then((res) => (this.options = res));
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
</script>
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<v-text-field
|
|
4
|
-
v-if="title"
|
|
5
|
-
v-model="title"
|
|
6
|
-
class="mb-n8 pb-0"
|
|
7
|
-
solo
|
|
8
|
-
readonly
|
|
9
|
-
v-bind="$attrs"
|
|
10
|
-
></v-text-field>
|
|
11
|
-
<v-hover v-model="isHovered">
|
|
12
|
-
<div style="position: relative">
|
|
13
|
-
<v-img
|
|
14
|
-
v-if="mediaExists"
|
|
15
|
-
:src="internalValue.is_image && internalValue.file || null"
|
|
16
|
-
:lazy-src="internalValue.is_image && internalValue.thumbnail || null"
|
|
17
|
-
|
|
18
|
-
:class="{'grey lighten-2': !internalValue.is_image}"
|
|
19
|
-
v-bind="{
|
|
20
|
-
aspectRatio,
|
|
21
|
-
contain,
|
|
22
|
-
height,
|
|
23
|
-
width,
|
|
24
|
-
maxWidth,
|
|
25
|
-
maxHeight,
|
|
26
|
-
minWidth,
|
|
27
|
-
minHeight,
|
|
28
|
-
}"
|
|
29
|
-
>
|
|
30
|
-
<template v-slot:placeholder>
|
|
31
|
-
<v-row
|
|
32
|
-
v-if="internalValue"
|
|
33
|
-
class="fill-height ma-0"
|
|
34
|
-
align="center"
|
|
35
|
-
justify="center"
|
|
36
|
-
>
|
|
37
|
-
<v-progress-circular
|
|
38
|
-
v-if="internalValue.is_image"
|
|
39
|
-
indeterminate
|
|
40
|
-
color="grey"
|
|
41
|
-
></v-progress-circular>
|
|
42
|
-
<div class="d-flex flex-column align-center justify-space-between fill-height" style="width: 100%" v-else>
|
|
43
|
-
<div></div>
|
|
44
|
-
<v-icon size="70px" color="grey">mdi-file</v-icon>
|
|
45
|
-
<span class="grey--text text--darken-3 text-truncate pl-1 pr-8" style="width: 100%">{{fileName}}</span>
|
|
46
|
-
</div>
|
|
47
|
-
</v-row>
|
|
48
|
-
</template>
|
|
49
|
-
</v-img>
|
|
50
|
-
|
|
51
|
-
<!-- If the media is not avaible, it shows a btn to add new media -->
|
|
52
|
-
<v-card
|
|
53
|
-
v-else-if="!rmAddBtn"
|
|
54
|
-
class="rounded-0"
|
|
55
|
-
v-bind="{
|
|
56
|
-
height,
|
|
57
|
-
width,
|
|
58
|
-
maxWidth,
|
|
59
|
-
maxHeight,
|
|
60
|
-
minWidth,
|
|
61
|
-
minHeight,
|
|
62
|
-
...$attrs,
|
|
63
|
-
}"
|
|
64
|
-
>
|
|
65
|
-
<v-card-title>{{ label }}</v-card-title>
|
|
66
|
-
|
|
67
|
-
<v-card-actions>
|
|
68
|
-
<v-btn tile :disabled="readonly" @click="editing = true" block :min-height="minHeight">
|
|
69
|
-
<v-icon size="80"> mdi-plus-circle-outline </v-icon>
|
|
70
|
-
</v-btn>
|
|
71
|
-
</v-card-actions>
|
|
72
|
-
</v-card>
|
|
73
|
-
|
|
74
|
-
<!-- Shows darkening overlay on image with buttons on top while hovered -->
|
|
75
|
-
<v-overlay opacity="0.3" absolute :value="overlay">
|
|
76
|
-
<v-row>
|
|
77
|
-
<v-col cols="12">
|
|
78
|
-
<h3>{{ label }}</h3>
|
|
79
|
-
</v-col>
|
|
80
|
-
</v-row>
|
|
81
|
-
<v-row>
|
|
82
|
-
<v-col cols="6">
|
|
83
|
-
<v-btn :disabled="readonly" @click="editing = true" fab v-bind="$attrs">
|
|
84
|
-
<v-icon>mdi-pencil</v-icon>
|
|
85
|
-
</v-btn>
|
|
86
|
-
</v-col>
|
|
87
|
-
|
|
88
|
-
<v-col cols="6">
|
|
89
|
-
<v-btn :disabled="readonly" @click="confirmDelete" fab v-bind="$attrs">
|
|
90
|
-
<v-icon>mdi-delete</v-icon>
|
|
91
|
-
</v-btn>
|
|
92
|
-
</v-col>
|
|
93
|
-
</v-row>
|
|
94
|
-
</v-overlay>
|
|
95
|
-
|
|
96
|
-
<!-- Select media dialog -->
|
|
97
|
-
<media-manager-dialog
|
|
98
|
-
v-model="editing"
|
|
99
|
-
select="single"
|
|
100
|
-
v-on:selectionChange="update"
|
|
101
|
-
v-bind="$attrs"
|
|
102
|
-
>
|
|
103
|
-
</media-manager-dialog>
|
|
104
|
-
|
|
105
|
-
</div>
|
|
106
|
-
</v-hover>
|
|
107
|
-
</div>
|
|
108
|
-
</template>
|
|
109
|
-
|
|
110
|
-
<style scoped>
|
|
111
|
-
</style>
|
|
112
|
-
|
|
113
|
-
<script>
|
|
114
|
-
export default {
|
|
115
|
-
name: "MediaField",
|
|
116
|
-
data() {
|
|
117
|
-
return {
|
|
118
|
-
internalValue: null,
|
|
119
|
-
editing: false,
|
|
120
|
-
isHovered: false,
|
|
121
|
-
};
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
props: {
|
|
125
|
-
value: Object,
|
|
126
|
-
label: String,
|
|
127
|
-
title: {
|
|
128
|
-
type: String,
|
|
129
|
-
default: () => "",
|
|
130
|
-
},
|
|
131
|
-
rmAddBtn: {
|
|
132
|
-
type: Boolean,
|
|
133
|
-
default: false,
|
|
134
|
-
},
|
|
135
|
-
//image reflections
|
|
136
|
-
aspectRatio: {
|
|
137
|
-
type: String | Number,
|
|
138
|
-
default: undefined,
|
|
139
|
-
},
|
|
140
|
-
contain: {
|
|
141
|
-
type: Boolean,
|
|
142
|
-
default: false,
|
|
143
|
-
},
|
|
144
|
-
height: {
|
|
145
|
-
type: String | Number,
|
|
146
|
-
default: "100%",
|
|
147
|
-
},
|
|
148
|
-
width: {
|
|
149
|
-
type: String | Number,
|
|
150
|
-
default: "100%",
|
|
151
|
-
},
|
|
152
|
-
maxWidth: {
|
|
153
|
-
type: String | Number,
|
|
154
|
-
default: undefined,
|
|
155
|
-
},
|
|
156
|
-
maxHeight: {
|
|
157
|
-
type: String | Number,
|
|
158
|
-
default: undefined,
|
|
159
|
-
},
|
|
160
|
-
minWidth: {
|
|
161
|
-
type: String | Number,
|
|
162
|
-
default: undefined,
|
|
163
|
-
},
|
|
164
|
-
minHeight: {
|
|
165
|
-
type: String | Number,
|
|
166
|
-
default: 300,
|
|
167
|
-
},
|
|
168
|
-
// This set the component status to readonly, stopping the user interaction.
|
|
169
|
-
readonly: {
|
|
170
|
-
type: Boolean,
|
|
171
|
-
default: false,
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
computed: {
|
|
176
|
-
mediaExists() {
|
|
177
|
-
return !!this.internalValue?.file;
|
|
178
|
-
},
|
|
179
|
-
overlay() {
|
|
180
|
-
return this.isHovered && this.mediaExists;
|
|
181
|
-
},
|
|
182
|
-
fileName() {
|
|
183
|
-
return this.internalValue && this.internalValue.file && this.internalValue.file.split("/").pop();
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
|
|
187
|
-
methods: {
|
|
188
|
-
update(val) {
|
|
189
|
-
this.internalValue = val;
|
|
190
|
-
},
|
|
191
|
-
confirmDelete() {
|
|
192
|
-
this.$mapo.$confirm
|
|
193
|
-
.open({
|
|
194
|
-
title: "Remove",
|
|
195
|
-
question: "Are you sure to want to remove this media?",
|
|
196
|
-
approveButton: { text: "Remove", attrs: { color: "red", text: true } }
|
|
197
|
-
})
|
|
198
|
-
.then((res) => (res ? (this.internalValue = null) : null));
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
|
|
202
|
-
watch: {
|
|
203
|
-
value(val) {
|
|
204
|
-
if (val !== this.internalValue) {
|
|
205
|
-
this.internalValue = val;
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
internalValue(val) {
|
|
209
|
-
this.$emit("input", val);
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
};
|
|
213
|
-
</script>
|