@mapomodule/uikit 1.0.0-alpha.5 → 1.0.0-alpha.50
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 +873 -0
- package/components/ConfirmDialog.vue +58 -37
- package/components/Detail/Detail.vue +450 -243
- 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 +214 -0
- package/components/Form/FormGroup.vue +146 -0
- package/components/Form/FormTabs.vue +188 -0
- package/components/Form/defaults.js +97 -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 +88 -0
- package/components/Form/fields/MediaField.vue +159 -0
- package/components/Form/fields/MediaM2mField.vue +149 -0
- package/components/Form/fields/Repeater.vue +596 -0
- package/components/Form/fields/SeoPreview.vue +89 -0
- 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 +348 -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/LangSwitcher.vue +44 -0
- package/components/List/List.vue +103 -51
- package/components/List/ListActions.vue +23 -5
- package/components/List/ListFilters.vue +166 -114
- package/components/List/ListHead.vue +30 -12
- package/components/List/ListQuickEdit.vue +130 -61
- package/components/List/ListTable.vue +210 -66
- 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 +255 -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 +61 -30
- package/components/layout/Sidebar/SidebarList.vue +19 -15
- package/components/layout/Sidebar/SidebarListItem.vue +122 -38
- package/components/layout/Sidebar/SidebarProfile.vue +42 -0
- package/components/layout/Sidebar/SidebarTitle.vue +45 -0
- package/components/layout/Topbar/Topbar.vue +11 -42
- package/components/layout/routebuilder.js +3 -3
- package/defaults/i18n.js +37 -0
- package/defaults/vuetify.js +34 -0
- package/layouts/default.vue +33 -18
- package/layouts/empty.vue +10 -0
- package/module.js +7 -5
- package/package.json +6 -4
- package/pages/index.vue +19 -18
- 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/components/Detail/DetailField.vue +0 -129
- package/components/Detail/defaults.js +0 -50
- 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 -177
- package/components/fields/TinyMce/defaults.js +0 -55
- package/components/layout/Sidebar/SidebarFooter.vue +0 -75
- 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,193 +1,159 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
<div class="media-manager--wrapper">
|
|
3
|
+
<MediaFolders v-show="!editMedia" v-if="!noFolders" :mime="mime" />
|
|
4
|
+
<v-card elevation="0" class="media-manager--v-card" :class="{ transparent: !fillBackgroud, editing:editMedia }">
|
|
5
|
+
<v-card-title class="d-flex flex-wrap pa-0">
|
|
6
|
+
<div class="d-flex flex-grow-1">
|
|
7
|
+
<v-tabs v-model="tab" background-color="transparent" :show-arrows="false">
|
|
8
|
+
<v-tab>{{ $t("mapo.mediaManager.gallery") }}</v-tab>
|
|
9
|
+
<v-tab>{{ $t("mapo.mediaManager.uploader") }}</v-tab>
|
|
10
|
+
</v-tabs>
|
|
11
|
+
<v-spacer></v-spacer>
|
|
12
|
+
<v-btn v-show="$vuetify.breakpoint.xs" class="ma-2 ml-auto" @click="getRoot" icon>
|
|
6
13
|
<v-icon>mdi-update</v-icon>
|
|
7
14
|
</v-btn>
|
|
8
|
-
<v-btn
|
|
9
|
-
v-if="parentFolder"
|
|
10
|
-
class="ma-2"
|
|
11
|
-
@click="getRoot({ folder: { id: parentFolder.updir } })"
|
|
12
|
-
icon
|
|
13
|
-
>
|
|
14
|
-
<v-icon>mdi-arrow-left</v-icon>
|
|
15
|
-
</v-btn>
|
|
16
|
-
<span class="ma-2 d-flex align-center">{{
|
|
17
|
-
parentFolder ? parentFolder.path : "/"
|
|
18
|
-
}}</span>
|
|
19
15
|
</div>
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
</div>
|
|
28
|
-
|
|
29
|
-
<div v-if="!editMedia">
|
|
30
|
-
<MediaFolders
|
|
31
|
-
v-if="!noFolders"
|
|
32
|
-
v-bind="{ folders, parentFolder }"
|
|
33
|
-
@updateFolder="updateOrCreateFolder($event)"
|
|
34
|
-
@deleteFolder="deleteFolder($event)"
|
|
35
|
-
@goToFolder="
|
|
36
|
-
parentFolder = $event;
|
|
37
|
-
getRoot();
|
|
16
|
+
<div class="d-flex ma-auto mr-0 pb-2 pb-sm-0" :style="$vuetify.breakpoint.xs ? 'width: 100%' : ''">
|
|
17
|
+
<v-text-field
|
|
18
|
+
v-show="!editMedia && tab == 0"
|
|
19
|
+
v-model="searchValue"
|
|
20
|
+
@input="
|
|
21
|
+
loadingSearch = true;
|
|
22
|
+
search();
|
|
38
23
|
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
24
|
+
prepend-inner-icon="mdi-magnify"
|
|
25
|
+
:label="$t('mapo.search')"
|
|
26
|
+
single-line
|
|
27
|
+
hide-details
|
|
28
|
+
outlined
|
|
29
|
+
dense
|
|
30
|
+
clearable
|
|
31
|
+
:loading="loadingSearch"
|
|
32
|
+
class="mx-2 mt-2 rounded-0"
|
|
33
|
+
></v-text-field>
|
|
34
|
+
<v-btn v-show="!$vuetify.breakpoint.xs" class="ma-2 ml-0" @click="getRoot" icon>
|
|
35
|
+
<v-icon>mdi-update</v-icon>
|
|
36
|
+
</v-btn>
|
|
37
|
+
</div>
|
|
38
|
+
</v-card-title>
|
|
39
|
+
<v-progress-linear v-if="loading" indeterminate></v-progress-linear>
|
|
40
|
+
<MediaBreadcrumbs/>
|
|
41
|
+
<v-card-text class="media-manager--card-text pa-0">
|
|
42
|
+
<v-tabs-items touchless v-model="tab" class="transparent fill-height">
|
|
43
|
+
<v-tab-item class="fill-height">
|
|
44
|
+
<MediaGallery v-show="!editMedia"/>
|
|
45
|
+
<MediaEditor/>
|
|
50
46
|
</v-tab-item>
|
|
51
|
-
<v-tab-item>
|
|
47
|
+
<v-tab-item class="fill-height">
|
|
52
48
|
<MediaUploader
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
@Upload="
|
|
50
|
+
tab = 0;
|
|
51
|
+
getRoot({ page: 1 });
|
|
52
|
+
"
|
|
55
53
|
/>
|
|
56
54
|
</v-tab-item>
|
|
57
55
|
</v-tabs-items>
|
|
58
|
-
</
|
|
59
|
-
<
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
/>
|
|
56
|
+
</v-card-text>
|
|
57
|
+
<v-card-actions class="pa-0">
|
|
58
|
+
<!-- Slot to provide custom button actions inside the media manager -->
|
|
59
|
+
<slot name="actions"></slot>
|
|
60
|
+
</v-card-actions>
|
|
64
61
|
</v-card>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
65
64
|
</template>
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
<style lang="scss">
|
|
66
|
+
.v-card.media-manager--v-card{
|
|
67
|
+
display: flex;
|
|
68
|
+
flex-direction: column;
|
|
69
|
+
flex-grow: 1;
|
|
70
|
+
border-radius: 0px;
|
|
71
|
+
max-width: calc(100% - 56px);
|
|
72
|
+
&.editing{
|
|
73
|
+
max-width: 100%;
|
|
74
|
+
}
|
|
75
|
+
@media (max-width: 600px){
|
|
76
|
+
max-width: 100%;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
.v-slide-group__next--disabled, .v-slide-group__prev--disabled{
|
|
80
|
+
display: none !important;
|
|
81
|
+
}
|
|
82
|
+
.media-manager--card-text{
|
|
83
|
+
max-height: calc(100vh - 100px);
|
|
84
|
+
min-height: 400px;
|
|
85
|
+
flex-grow: 1;
|
|
86
|
+
@media (max-width: 600px){
|
|
87
|
+
max-height: calc(100vh - 195px);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
.v-dialog .media-manager--card-text{
|
|
91
|
+
max-height: calc(100vh - 300px);
|
|
92
|
+
}
|
|
93
|
+
.media-manager--wrapper{
|
|
94
|
+
display: flex;
|
|
95
|
+
height: inherit;
|
|
96
|
+
flex-direction: column-reverse;
|
|
97
|
+
position: relative;
|
|
98
|
+
justify-content: flex-end;
|
|
99
|
+
@media (min-width: 600px){
|
|
100
|
+
flex-direction: row;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
68
103
|
</style>
|
|
69
104
|
|
|
70
105
|
<script>
|
|
71
|
-
import
|
|
106
|
+
import { debounce } from "@mapomodule/utils/helpers/debounce";
|
|
107
|
+
import { mapGetters, mapActions } from "vuex"
|
|
108
|
+
|
|
109
|
+
|
|
72
110
|
export default {
|
|
73
111
|
name: "MediaManager",
|
|
74
|
-
|
|
75
|
-
data() {
|
|
112
|
+
data(){
|
|
76
113
|
return {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
parentFolder: null,
|
|
82
|
-
page: 1,
|
|
83
|
-
pages: 1,
|
|
84
|
-
tab: null,
|
|
85
|
-
editMedia: null,
|
|
86
|
-
};
|
|
114
|
+
tab: 0,
|
|
115
|
+
searchValue: "",
|
|
116
|
+
loadingSearch: false,
|
|
117
|
+
}
|
|
87
118
|
},
|
|
88
119
|
props: {
|
|
89
|
-
select: {
|
|
90
|
-
type: String,
|
|
91
|
-
default: "none",
|
|
92
|
-
validator(val) {
|
|
93
|
-
return ["none", "single", "multi"].indexOf(val) !== -1;
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
120
|
noFolders: {
|
|
97
121
|
type: Boolean,
|
|
98
122
|
default: false,
|
|
99
123
|
},
|
|
100
|
-
|
|
101
|
-
type:
|
|
102
|
-
|
|
103
|
-
},
|
|
104
|
-
dark: {
|
|
105
|
-
type: Boolean,
|
|
106
|
-
default: false,
|
|
107
|
-
},
|
|
108
|
-
elevation: {
|
|
109
|
-
type: Number | String,
|
|
110
|
-
default: undefined,
|
|
124
|
+
mime: {
|
|
125
|
+
type: String,
|
|
126
|
+
required: false,
|
|
111
127
|
},
|
|
128
|
+
fillBackgroud: Boolean
|
|
112
129
|
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
this.
|
|
116
|
-
this.
|
|
117
|
-
|
|
118
|
-
return this._mediaFolderCrud;
|
|
119
|
-
},
|
|
120
|
-
mediaFileCrud() {
|
|
121
|
-
this._mediaFileCrud =
|
|
122
|
-
this._mediaFileCrud || this.$mapo.$api.crud("api/camomilla/media");
|
|
123
|
-
return this._mediaFileCrud;
|
|
124
|
-
},
|
|
130
|
+
watch: {
|
|
131
|
+
'$i18n.locale': async function(locale) {
|
|
132
|
+
if (this.editMedia)
|
|
133
|
+
this.openEditor(this.editMedia);
|
|
134
|
+
}
|
|
125
135
|
},
|
|
136
|
+
computed: mapGetters("mapo/media", ["parentFolder", "medias", "folders", "parentFolders", "page", "pages", "loading", "editMedia" ]),
|
|
126
137
|
methods: {
|
|
127
|
-
getRoot
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
this.page = page || this.page;
|
|
132
|
-
const params = { page: this.page };
|
|
133
|
-
if (id) {
|
|
134
|
-
response = await this.mediaFolderCrud.detail(id, {
|
|
135
|
-
params,
|
|
136
|
-
});
|
|
137
|
-
} else {
|
|
138
|
-
response = await this.mediaFolderCrud.list({ params });
|
|
139
|
-
}
|
|
140
|
-
this.processResponse(response);
|
|
141
|
-
},
|
|
142
|
-
|
|
143
|
-
updateOrCreateFolder(folder) {
|
|
144
|
-
return this.mediaFolderCrud
|
|
145
|
-
.updateOrCreate(folder)
|
|
146
|
-
.then(() => this.getRoot());
|
|
147
|
-
},
|
|
148
|
-
|
|
149
|
-
deleteFolder(folder) {
|
|
150
|
-
return this.mediaFolderCrud.delete(folder.id).then(() => this.getRoot());
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
deleteMedia(media) {
|
|
154
|
-
return this.mediaFileCrud.delete(media.id).then(() => {
|
|
155
|
-
(this.editMedia = null), this.getRoot();
|
|
156
|
-
});
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
detailMedia(media_id) {
|
|
160
|
-
return this.mediaFileCrud.detail(media_id);
|
|
161
|
-
},
|
|
162
|
-
|
|
163
|
-
updateMedia(media) {
|
|
164
|
-
const files = ["file", "objectURL", "thumbnail"];
|
|
165
|
-
const payload = this.$mapo.$api.multipart(media, files);
|
|
166
|
-
const conf = { headers: { "Content-Type": "multipart/form-data" } };
|
|
167
|
-
return this.mediaFileCrud
|
|
168
|
-
.partialUpdate(media.id, payload, conf)
|
|
169
|
-
.then(() =>
|
|
170
|
-
this.$mapo.$snack.open({
|
|
171
|
-
message: "file info succesfully updated.",
|
|
172
|
-
})
|
|
173
|
-
);
|
|
174
|
-
},
|
|
175
|
-
processResponse(resp) {
|
|
176
|
-
this.medias = resp?.media?.items || [];
|
|
177
|
-
this.folders = resp?.folders || [];
|
|
178
|
-
this.parentFolder = resp?.parent_folder;
|
|
179
|
-
this.page = resp?.media?.paginator?.page;
|
|
180
|
-
this.pages = resp?.media?.paginator?.pages;
|
|
181
|
-
},
|
|
182
|
-
selectionChange(event) {
|
|
183
|
-
this.$emit("selectionChange", event);
|
|
184
|
-
},
|
|
185
|
-
async openEditor(event) {
|
|
186
|
-
this.editMedia = await this.detailMedia(event.id);
|
|
187
|
-
},
|
|
138
|
+
...mapActions("mapo/media", ["getRoot", "openEditor", "updateMedia", "updateOrCreateFolder", "deleteFolder", "deleteMedia", "reset"]),
|
|
139
|
+
search: debounce(function () {
|
|
140
|
+
this.getRoot({search: this.searchValue, all: true}).then(() => (this.loadingSearch = false));
|
|
141
|
+
}, 500),
|
|
188
142
|
},
|
|
189
143
|
async fetch() {
|
|
144
|
+
this.$store.commit("mapo/media/SET_MIME_TYPE", this.mime || null);
|
|
190
145
|
await this.getRoot();
|
|
191
146
|
},
|
|
147
|
+
mounted(){
|
|
148
|
+
this.storeUnsubscribe = this.$store.subscribeAction((action) => {
|
|
149
|
+
if (action.type == "mapo/media/getRoot" && this.searchValue != action.payload?.search) {
|
|
150
|
+
this.searchValue = action.payload?.search;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
destroyed(){
|
|
155
|
+
this.reset();
|
|
156
|
+
this.storeUnsubscribe && this.storeUnsubscribe()
|
|
157
|
+
}
|
|
192
158
|
};
|
|
193
159
|
</script>
|
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<slot v-bind="{ on, attrs }" name="activator"></slot>
|
|
4
|
-
<v-dialog v-model="dialog" width="800">
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<v-
|
|
3
|
+
<slot v-bind="{ on, $attrs }" name="activator"></slot>
|
|
4
|
+
<v-dialog v-model="dialog" max-width="100%" width="800" scrollable>
|
|
5
|
+
<media-manager
|
|
6
|
+
v-if="dialog"
|
|
7
|
+
v-bind="{ noFolders, mime }"
|
|
8
|
+
elevation="0"
|
|
9
|
+
fill-backgroud
|
|
10
|
+
>
|
|
11
|
+
<template v-slot:actions>
|
|
12
12
|
<v-spacer></v-spacer>
|
|
13
|
-
<v-btn color="primary" text @click="done">
|
|
14
|
-
</
|
|
15
|
-
</
|
|
13
|
+
<v-btn v-if="select == 'multi'" color="primary" text tile @click="done">{{ $t("mapo.confirm") }}</v-btn>
|
|
14
|
+
</template>
|
|
15
|
+
</media-manager>
|
|
16
16
|
</v-dialog>
|
|
17
17
|
</div>
|
|
18
18
|
</template>
|
|
19
|
+
|
|
19
20
|
<script>
|
|
21
|
+
import { mapGetters, mapActions } from "vuex"
|
|
22
|
+
|
|
20
23
|
export default {
|
|
21
24
|
name: "MediaManagerDialog",
|
|
22
25
|
data() {
|
|
23
26
|
return {
|
|
24
|
-
selection: [],
|
|
25
27
|
dialog: false,
|
|
26
|
-
attrs: { ...this.$attrs },
|
|
27
28
|
on: {
|
|
28
29
|
click: (event) => {
|
|
29
30
|
event.preventDefault();
|
|
@@ -48,24 +49,30 @@ export default {
|
|
|
48
49
|
return ["none", "single", "multi"].indexOf(val) !== -1;
|
|
49
50
|
},
|
|
50
51
|
},
|
|
51
|
-
|
|
52
|
-
type:
|
|
53
|
-
default: false,
|
|
52
|
+
selected: {
|
|
53
|
+
type: Object | Array | null,
|
|
54
54
|
},
|
|
55
|
-
|
|
56
|
-
type:
|
|
57
|
-
|
|
58
|
-
},
|
|
59
|
-
elevation: {
|
|
60
|
-
type: Number | String,
|
|
61
|
-
default: undefined,
|
|
55
|
+
mime: {
|
|
56
|
+
type: String,
|
|
57
|
+
required: false
|
|
62
58
|
},
|
|
63
59
|
},
|
|
64
60
|
watch: {
|
|
65
61
|
value(val) {
|
|
66
62
|
this.dialog = val;
|
|
67
63
|
},
|
|
64
|
+
selected(val){
|
|
65
|
+
this.dialog && this.setSelection(val);
|
|
66
|
+
},
|
|
67
|
+
selection(val){
|
|
68
|
+
if (this.dialog && !(val?.id == this.selected?.id)){
|
|
69
|
+
this.done()
|
|
70
|
+
}
|
|
71
|
+
},
|
|
68
72
|
dialog(val) {
|
|
73
|
+
if(val){
|
|
74
|
+
this.setSelectionMode(this.select).then(() => this.setSelection(this.selected));
|
|
75
|
+
}
|
|
69
76
|
this.$emit("input", val);
|
|
70
77
|
this.$emit(val ? "open" : "close");
|
|
71
78
|
if (!val && this.reject) {
|
|
@@ -73,7 +80,11 @@ export default {
|
|
|
73
80
|
}
|
|
74
81
|
},
|
|
75
82
|
},
|
|
83
|
+
computed:{
|
|
84
|
+
...mapGetters("mapo/media", ["selection", "selectMode"])
|
|
85
|
+
},
|
|
76
86
|
methods: {
|
|
87
|
+
...mapActions("mapo/media", ["setSelection", "setSelectionMode"]),
|
|
77
88
|
open() {
|
|
78
89
|
this.dialog = true;
|
|
79
90
|
return new Promise((resolve, reject) => {
|
|
@@ -81,18 +92,12 @@ export default {
|
|
|
81
92
|
this.reject = reject;
|
|
82
93
|
});
|
|
83
94
|
},
|
|
84
|
-
selectionChange(event) {
|
|
85
|
-
this.selection = event;
|
|
86
|
-
if (this.select == "single") {
|
|
87
|
-
this.done();
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
95
|
done() {
|
|
91
96
|
if (this.resolve) {
|
|
92
97
|
this.resolve(this.selection);
|
|
93
98
|
}
|
|
94
99
|
this.dialog = false;
|
|
95
|
-
this.$emit("
|
|
100
|
+
this.$emit("update:selected", this.selection);
|
|
96
101
|
},
|
|
97
102
|
},
|
|
98
103
|
};
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-img
|
|
3
|
+
:src="(isImage && media.file) || null"
|
|
4
|
+
:lazy-src="(isImage && media.thumbnail) || null"
|
|
5
|
+
aspect-ratio="1"
|
|
6
|
+
class="grey lighten-2"
|
|
7
|
+
:class="{
|
|
8
|
+
'media-controls': mediaControls,
|
|
9
|
+
'video-preview': videoPreview,
|
|
10
|
+
}"
|
|
11
|
+
v-bind="$attrs"
|
|
12
|
+
v-on="videoListeners"
|
|
13
|
+
@mouseover.native="hover = true"
|
|
14
|
+
@mouseleave.native="hover = false; showInfo = false"
|
|
15
|
+
:title="media.title || media.name"
|
|
16
|
+
>
|
|
17
|
+
<template v-slot:placeholder>
|
|
18
|
+
<v-row class="fill-height ma-0" align="center" justify="center">
|
|
19
|
+
<v-progress-circular
|
|
20
|
+
v-if="isImage"
|
|
21
|
+
indeterminate
|
|
22
|
+
color="grey lighten-5"
|
|
23
|
+
></v-progress-circular>
|
|
24
|
+
<div
|
|
25
|
+
class="d-flex justify-center align-center"
|
|
26
|
+
:class="{ playing }"
|
|
27
|
+
style="width: 100%; height: 100%"
|
|
28
|
+
v-else-if="isVideo"
|
|
29
|
+
>
|
|
30
|
+
<video
|
|
31
|
+
:width="$attrs.contain && '100%'"
|
|
32
|
+
height="100%"
|
|
33
|
+
ref="video"
|
|
34
|
+
:controls="mediaControls"
|
|
35
|
+
>
|
|
36
|
+
<source :src="media.file" :type="media.mime_type" />
|
|
37
|
+
</video>
|
|
38
|
+
<v-icon
|
|
39
|
+
v-if="!mediaControls"
|
|
40
|
+
:size="size"
|
|
41
|
+
color="grey darken-4"
|
|
42
|
+
class="grey lighten-2 rounded-circle video-preview-icon"
|
|
43
|
+
>mdi-play</v-icon
|
|
44
|
+
>
|
|
45
|
+
</div>
|
|
46
|
+
<div
|
|
47
|
+
class="
|
|
48
|
+
d-flex
|
|
49
|
+
flex-column
|
|
50
|
+
align-center
|
|
51
|
+
justify-space-between
|
|
52
|
+
fill-height
|
|
53
|
+
"
|
|
54
|
+
style="width: 100%"
|
|
55
|
+
v-else
|
|
56
|
+
>
|
|
57
|
+
<div></div>
|
|
58
|
+
<v-icon :size="size" color="grey darken-2">
|
|
59
|
+
{{ isAudio ? "mdi-headphones" : "mdi-file" }}
|
|
60
|
+
</v-icon>
|
|
61
|
+
<audio v-if="isAudio && mediaControls" controls>
|
|
62
|
+
<source :src="media.file" :type="media.mime_type" />
|
|
63
|
+
</audio>
|
|
64
|
+
<span
|
|
65
|
+
class="grey--text text--darken-3 text-truncate pl-1 pr-8"
|
|
66
|
+
style="width: 100%"
|
|
67
|
+
>{{ (filename && name) || undefined }}</span
|
|
68
|
+
>
|
|
69
|
+
</div>
|
|
70
|
+
</v-row>
|
|
71
|
+
</template>
|
|
72
|
+
<template>
|
|
73
|
+
<div @click.stop="showInfo=true" class="file-info text-right" :class="{hover, showInfo}">
|
|
74
|
+
<span class="file-name text-truncate">{{ (filename && name) || undefined }}</span>
|
|
75
|
+
<span class="file-details text-caption " :class="{showInfo}">
|
|
76
|
+
<span>{{ dateCreated }}</span><br>
|
|
77
|
+
<span>{{ fileSize }}</span>
|
|
78
|
+
</span>
|
|
79
|
+
</div>
|
|
80
|
+
</template>
|
|
81
|
+
</v-img>
|
|
82
|
+
</template>
|
|
83
|
+
|
|
84
|
+
<style lang="scss">
|
|
85
|
+
.file-info{
|
|
86
|
+
position: absolute;
|
|
87
|
+
bottom: 0;
|
|
88
|
+
padding: 0.2em 1em;
|
|
89
|
+
background: #1f1f1f;
|
|
90
|
+
opacity: 0;
|
|
91
|
+
transition: opacity .5s;
|
|
92
|
+
width: 100%;
|
|
93
|
+
display: block;
|
|
94
|
+
max-height: 80%;
|
|
95
|
+
overflow: auto ;
|
|
96
|
+
&.hover{
|
|
97
|
+
opacity: .7;
|
|
98
|
+
}
|
|
99
|
+
&.showInfo{
|
|
100
|
+
opacity: .9;
|
|
101
|
+
padding: 0.2em 0.5em;
|
|
102
|
+
.file-name{
|
|
103
|
+
font-weight: bold;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
.file-name{
|
|
108
|
+
display: block;
|
|
109
|
+
}
|
|
110
|
+
.file-details{
|
|
111
|
+
max-height: 0;
|
|
112
|
+
overflow: hidden;
|
|
113
|
+
transition: all .5s;
|
|
114
|
+
display: block;
|
|
115
|
+
&.showInfo{
|
|
116
|
+
max-height: 500px;
|
|
117
|
+
overflow: auto;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
.v-image.media-controls {
|
|
121
|
+
.v-image__placeholder {
|
|
122
|
+
z-index: 0;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
.v-image.video-preview {
|
|
126
|
+
.v-image__placeholder {
|
|
127
|
+
height: calc(100% + 1px);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
.video-preview-icon.v-icon.v-icon {
|
|
131
|
+
position: absolute;
|
|
132
|
+
opacity: 0.5;
|
|
133
|
+
transition: transform 0.3s ease-out, opacity 0.3s ease-out;
|
|
134
|
+
}
|
|
135
|
+
.playing .video-preview-icon.v-icon.v-icon {
|
|
136
|
+
opacity: 0;
|
|
137
|
+
transform: scale(1.2);
|
|
138
|
+
}
|
|
139
|
+
</style>
|
|
140
|
+
|
|
141
|
+
<script>
|
|
142
|
+
import { humanFileSize } from "@mapomodule/utils/helpers/formatters";
|
|
143
|
+
|
|
144
|
+
const extensions = {
|
|
145
|
+
image: ["png", "jpg", "jpeg", "avif", "webp"],
|
|
146
|
+
audio: ["mp3", "ogg", "flac"],
|
|
147
|
+
video: ["mp4", "webm", "avi", "mov", "wmv"]
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export default {
|
|
151
|
+
data() {
|
|
152
|
+
return {
|
|
153
|
+
playing: false,
|
|
154
|
+
playPromise: null,
|
|
155
|
+
hover: false,
|
|
156
|
+
showInfo: false
|
|
157
|
+
};
|
|
158
|
+
},
|
|
159
|
+
props: {
|
|
160
|
+
media: {
|
|
161
|
+
type: Object,
|
|
162
|
+
default: () => ({}),
|
|
163
|
+
},
|
|
164
|
+
filename: {
|
|
165
|
+
type: Boolean,
|
|
166
|
+
default: false,
|
|
167
|
+
},
|
|
168
|
+
iconSize: {
|
|
169
|
+
type: String || Number,
|
|
170
|
+
default: "70px",
|
|
171
|
+
},
|
|
172
|
+
videoPreview: {
|
|
173
|
+
type: Boolean,
|
|
174
|
+
default: false,
|
|
175
|
+
},
|
|
176
|
+
mediaControls: {
|
|
177
|
+
type: Boolean,
|
|
178
|
+
default: false,
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
computed: {
|
|
182
|
+
name() {
|
|
183
|
+
return this.media && this.media.file && this.media.file.split("/").pop();
|
|
184
|
+
},
|
|
185
|
+
size() {
|
|
186
|
+
return (
|
|
187
|
+
(this.iconSize &&
|
|
188
|
+
(typeof this.iconSize == "string"
|
|
189
|
+
? this.iconSize
|
|
190
|
+
: this.iconSize + "px")) ||
|
|
191
|
+
"70px"
|
|
192
|
+
);
|
|
193
|
+
},
|
|
194
|
+
isImage() {
|
|
195
|
+
if (this.media?.mime_type)
|
|
196
|
+
return this.media.mime_type.startsWith("image/");
|
|
197
|
+
return extensions.image.includes(this.media?.file?.split(".").pop()?.toLowerCase())
|
|
198
|
+
},
|
|
199
|
+
isVideo() {
|
|
200
|
+
if (this.media?.mime_type)
|
|
201
|
+
return this.media.mime_type.startsWith("video/");
|
|
202
|
+
return extensions.video.includes(this.media?.file?.split(".").pop()?.toLowerCase())
|
|
203
|
+
},
|
|
204
|
+
isAudio() {
|
|
205
|
+
if (this.media?.mime_type)
|
|
206
|
+
return this.media.mime_type.startsWith("audio/");
|
|
207
|
+
return extensions.audio.includes(this.media?.file?.split(".").pop()?.toLowerCase())
|
|
208
|
+
},
|
|
209
|
+
videoListeners() {
|
|
210
|
+
if (this.isVideo && this.videoPreview) {
|
|
211
|
+
return {
|
|
212
|
+
mouseenter: this.startVideoPreview,
|
|
213
|
+
mouseleave: this.stopVideoPreview,
|
|
214
|
+
touchstart: this.handleTouch
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
fileSize() {
|
|
219
|
+
return this.media && humanFileSize(this.media.size);
|
|
220
|
+
},
|
|
221
|
+
dateCreated() {
|
|
222
|
+
return this.media && new Date(this.media.created).toLocaleDateString();
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
methods: {
|
|
226
|
+
handleTouch(event){
|
|
227
|
+
const video = this.$refs.video;
|
|
228
|
+
if (video && !this.playing) {
|
|
229
|
+
this.startVideoPreview()
|
|
230
|
+
event.preventDefault()
|
|
231
|
+
event.stopPropagation()
|
|
232
|
+
} else {
|
|
233
|
+
this.stopVideoPreview()
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
startVideoPreview() {
|
|
237
|
+
const video = this.$refs.video;
|
|
238
|
+
if (video && !this.playing) {
|
|
239
|
+
video.loop = true;
|
|
240
|
+
video.muted = true;
|
|
241
|
+
video.currentTime = 1;
|
|
242
|
+
this.playPromise = video.play().then(() => (this.playing = true));
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
async stopVideoPreview() {
|
|
246
|
+
if (this.playPromise) {
|
|
247
|
+
await this.playPromise;
|
|
248
|
+
}
|
|
249
|
+
const video = this.$refs.video;
|
|
250
|
+
if (video && this.playing) {
|
|
251
|
+
video.currentTime = 0;
|
|
252
|
+
video.pause();
|
|
253
|
+
this.playing = false;
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
</script>
|