@mapomodule/uikit 1.0.0-alpha.4 → 1.0.0-alpha.40
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 +730 -0
- package/components/ConfirmDialog.vue +12 -16
- package/components/Detail/Detail.vue +406 -272
- package/components/Detail/DetailLangSwitch.vue +7 -2
- package/components/DropArea.vue +63 -56
- package/components/Form/Form.vue +218 -0
- package/components/Form/FormField.vue +213 -0
- package/components/Form/FormGroup.vue +146 -0
- package/components/Form/FormTabs.vue +188 -0
- package/components/Form/defaults.js +91 -0
- package/components/Form/fields/ColorField.vue +79 -0
- package/components/{fields → Form/fields}/DateField.vue +20 -11
- 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 +593 -0
- package/components/Form/fields/SeoPreview.vue +89 -0
- package/components/Form/fields/wygEditor/defaults.js +25 -0
- package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/events.js +0 -0
- package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/mapomedia.plugin.js +7 -6
- package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/script.injector.js +0 -0
- package/components/Form/fields/wygEditor/wygEditor.vue +285 -0
- package/components/LangSwitcher.vue +44 -0
- package/components/List/List.vue +119 -42
- package/components/List/ListActions.vue +60 -21
- 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 +292 -80
- package/components/Login.vue +17 -7
- package/components/LogoutButton.vue +42 -28
- package/components/MediaManager/MediaBreadcrumbs.vue +45 -0
- package/components/MediaManager/MediaEditor.vue +282 -121
- package/components/MediaManager/MediaFolders.vue +169 -116
- package/components/MediaManager/MediaGallery.vue +151 -146
- package/components/MediaManager/MediaManager.vue +117 -159
- package/components/MediaManager/MediaManagerDialog.vue +36 -31
- package/components/MediaManager/MediaPreview.vue +203 -0
- package/components/MediaManager/MediaUploader.vue +55 -43
- 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 +111 -39
- 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/{favicon.ico → mapo/favicon.ico} +0 -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 +134 -0
- package/translations/it-IT.js +136 -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
|
@@ -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,203 @@
|
|
|
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
|
+
:title="media.title || media.name"
|
|
14
|
+
>
|
|
15
|
+
<template v-slot:placeholder>
|
|
16
|
+
<v-row class="fill-height ma-0" align="center" justify="center">
|
|
17
|
+
<v-progress-circular
|
|
18
|
+
v-if="isImage"
|
|
19
|
+
indeterminate
|
|
20
|
+
color="grey lighten-5"
|
|
21
|
+
></v-progress-circular>
|
|
22
|
+
<div
|
|
23
|
+
class="d-flex justify-center align-center"
|
|
24
|
+
:class="{ playing }"
|
|
25
|
+
style="width: 100%; height: 100%"
|
|
26
|
+
v-else-if="isVideo"
|
|
27
|
+
>
|
|
28
|
+
<video
|
|
29
|
+
:width="$attrs.contain && '100%'"
|
|
30
|
+
height="100%"
|
|
31
|
+
ref="video"
|
|
32
|
+
:controls="mediaControls"
|
|
33
|
+
>
|
|
34
|
+
<source :src="media.file" :type="media.mime_type" />
|
|
35
|
+
</video>
|
|
36
|
+
<v-icon
|
|
37
|
+
v-if="!mediaControls"
|
|
38
|
+
:size="size"
|
|
39
|
+
color="grey darken-4"
|
|
40
|
+
class="grey lighten-2 rounded-circle video-preview-icon"
|
|
41
|
+
>mdi-play</v-icon
|
|
42
|
+
>
|
|
43
|
+
</div>
|
|
44
|
+
<div
|
|
45
|
+
class="
|
|
46
|
+
d-flex
|
|
47
|
+
flex-column
|
|
48
|
+
align-center
|
|
49
|
+
justify-space-between
|
|
50
|
+
fill-height
|
|
51
|
+
"
|
|
52
|
+
style="width: 100%"
|
|
53
|
+
v-else
|
|
54
|
+
>
|
|
55
|
+
<div></div>
|
|
56
|
+
<v-icon :size="size" color="grey darken-2">
|
|
57
|
+
{{ isAudio ? "mdi-headphones" : "mdi-file" }}
|
|
58
|
+
</v-icon>
|
|
59
|
+
<audio v-if="isAudio && mediaControls" controls>
|
|
60
|
+
<source :src="media.file" :type="media.mime_type" />
|
|
61
|
+
</audio>
|
|
62
|
+
<span
|
|
63
|
+
class="grey--text text--darken-3 text-truncate pl-1 pr-8"
|
|
64
|
+
style="width: 100%"
|
|
65
|
+
>{{ (filename && name) || undefined }}</span
|
|
66
|
+
>
|
|
67
|
+
</div>
|
|
68
|
+
</v-row>
|
|
69
|
+
</template>
|
|
70
|
+
</v-img>
|
|
71
|
+
</template>
|
|
72
|
+
|
|
73
|
+
<style lang="scss">
|
|
74
|
+
.v-image.media-controls {
|
|
75
|
+
.v-image__placeholder {
|
|
76
|
+
z-index: 0;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
.v-image.video-preview {
|
|
80
|
+
.v-image__placeholder {
|
|
81
|
+
height: calc(100% + 1px);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
.video-preview-icon.v-icon.v-icon {
|
|
85
|
+
position: absolute;
|
|
86
|
+
opacity: 0.5;
|
|
87
|
+
transition: transform 0.3s ease-out, opacity 0.3s ease-out;
|
|
88
|
+
}
|
|
89
|
+
.playing .video-preview-icon.v-icon.v-icon {
|
|
90
|
+
opacity: 0;
|
|
91
|
+
transform: scale(1.2);
|
|
92
|
+
}
|
|
93
|
+
</style>
|
|
94
|
+
|
|
95
|
+
<script>
|
|
96
|
+
|
|
97
|
+
const extensions = {
|
|
98
|
+
image: ["png", "jpg", "jpeg", "avif", "webp"],
|
|
99
|
+
audio: ["mp3", "ogg", "flac"],
|
|
100
|
+
video: ["mp4", "webm", "avi", "mov", "wmv"]
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export default {
|
|
104
|
+
data() {
|
|
105
|
+
return {
|
|
106
|
+
playing: false,
|
|
107
|
+
playPromise: null,
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
props: {
|
|
111
|
+
media: {
|
|
112
|
+
type: Object,
|
|
113
|
+
default: () => ({}),
|
|
114
|
+
},
|
|
115
|
+
filename: {
|
|
116
|
+
type: Boolean,
|
|
117
|
+
default: false,
|
|
118
|
+
},
|
|
119
|
+
iconSize: {
|
|
120
|
+
type: String || Number,
|
|
121
|
+
default: "70px",
|
|
122
|
+
},
|
|
123
|
+
videoPreview: {
|
|
124
|
+
type: Boolean,
|
|
125
|
+
default: false,
|
|
126
|
+
},
|
|
127
|
+
mediaControls: {
|
|
128
|
+
type: Boolean,
|
|
129
|
+
default: false,
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
computed: {
|
|
133
|
+
name() {
|
|
134
|
+
return this.media && this.media.file && this.media.file.split("/").pop();
|
|
135
|
+
},
|
|
136
|
+
size() {
|
|
137
|
+
return (
|
|
138
|
+
(this.iconSize &&
|
|
139
|
+
(typeof this.iconSize == "string"
|
|
140
|
+
? this.iconSize
|
|
141
|
+
: this.iconSize + "px")) ||
|
|
142
|
+
"70px"
|
|
143
|
+
);
|
|
144
|
+
},
|
|
145
|
+
isImage() {
|
|
146
|
+
if (this.media?.mime_type)
|
|
147
|
+
return this.media.mime_type.startsWith("image/");
|
|
148
|
+
return extensions.image.includes(this.media?.file?.split(".").pop()?.toLowerCase())
|
|
149
|
+
},
|
|
150
|
+
isVideo() {
|
|
151
|
+
if (this.media?.mime_type)
|
|
152
|
+
return this.media.mime_type.startsWith("video/");
|
|
153
|
+
return extensions.video.includes(this.media?.file?.split(".").pop()?.toLowerCase())
|
|
154
|
+
},
|
|
155
|
+
isAudio() {
|
|
156
|
+
if (this.media?.mime_type)
|
|
157
|
+
return this.media.mime_type.startsWith("audio/");
|
|
158
|
+
return extensions.audio.includes(this.media?.file?.split(".").pop()?.toLowerCase())
|
|
159
|
+
},
|
|
160
|
+
videoListeners() {
|
|
161
|
+
if (this.isVideo && this.videoPreview) {
|
|
162
|
+
return {
|
|
163
|
+
mouseenter: this.startVideoPreview,
|
|
164
|
+
mouseleave: this.stopVideoPreview,
|
|
165
|
+
touchstart: this.handleTouch
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
methods: {
|
|
171
|
+
handleTouch(event){
|
|
172
|
+
const video = this.$refs.video;
|
|
173
|
+
if (video && !this.playing) {
|
|
174
|
+
this.startVideoPreview()
|
|
175
|
+
event.preventDefault()
|
|
176
|
+
event.stopPropagation()
|
|
177
|
+
} else {
|
|
178
|
+
this.stopVideoPreview()
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
startVideoPreview() {
|
|
182
|
+
const video = this.$refs.video;
|
|
183
|
+
if (video && !this.playing) {
|
|
184
|
+
video.loop = true;
|
|
185
|
+
video.muted = true;
|
|
186
|
+
video.currentTime = 1;
|
|
187
|
+
this.playPromise = video.play().then(() => (this.playing = true));
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
async stopVideoPreview() {
|
|
191
|
+
if (this.playPromise) {
|
|
192
|
+
await this.playPromise;
|
|
193
|
+
}
|
|
194
|
+
const video = this.$refs.video;
|
|
195
|
+
if (video && this.playing) {
|
|
196
|
+
video.currentTime = 0;
|
|
197
|
+
video.pause();
|
|
198
|
+
this.playing = false;
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
</script>
|
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
<v-container>
|
|
3
3
|
<drop-area @change="updateMediaList($event)" multiple>
|
|
4
4
|
<template v-slot:actions="{ clearList }">
|
|
5
|
-
<v-
|
|
6
|
-
<v-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<v-icon>
|
|
10
|
-
|
|
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:list-item.content.after="{ item }">
|
|
15
|
+
<v-chip dense v-if="isTooLarge(item)" color="error">{{$t("mapo.mediaUploader.tooLarge")}}</v-chip>
|
|
11
16
|
</template>
|
|
12
17
|
<template v-slot:editContent="{ editedItem }">
|
|
13
18
|
<v-container>
|
|
@@ -16,31 +21,31 @@
|
|
|
16
21
|
<v-select
|
|
17
22
|
v-model="editedItem.folder"
|
|
18
23
|
:items="folderOptions"
|
|
19
|
-
label="
|
|
24
|
+
:label="$t('mapo.folder')"
|
|
20
25
|
></v-select>
|
|
21
26
|
</v-col>
|
|
22
27
|
<v-col cols="12">
|
|
23
28
|
<v-text-field
|
|
24
29
|
v-model="editedItem.name"
|
|
25
|
-
label="
|
|
30
|
+
:label="$t('mapo.name')"
|
|
26
31
|
></v-text-field>
|
|
27
32
|
</v-col>
|
|
28
33
|
<v-col cols="12">
|
|
29
34
|
<v-text-field
|
|
30
35
|
v-model="editedItem.title"
|
|
31
|
-
label="
|
|
36
|
+
:label="$t('titleTag')"
|
|
32
37
|
></v-text-field>
|
|
33
38
|
</v-col>
|
|
34
39
|
<v-col cols="12">
|
|
35
40
|
<v-text-field
|
|
36
41
|
v-model="editedItem.description"
|
|
37
|
-
label="
|
|
42
|
+
:label="$t('mapo.description')"
|
|
38
43
|
></v-text-field>
|
|
39
44
|
</v-col>
|
|
40
45
|
<v-col cols="12">
|
|
41
46
|
<v-text-field
|
|
42
47
|
v-model="editedItem.alt_text"
|
|
43
|
-
label="
|
|
48
|
+
:label="$t('mapo.altTag')"
|
|
44
49
|
></v-text-field>
|
|
45
50
|
</v-col>
|
|
46
51
|
</v-row>
|
|
@@ -55,6 +60,10 @@
|
|
|
55
60
|
</template>
|
|
56
61
|
|
|
57
62
|
<script>
|
|
63
|
+
import { mapGetters } from "vuex"
|
|
64
|
+
const MAX_IMAGE_SIZE = 1000000 // 1mb
|
|
65
|
+
const MAX_VIDEO_SIZE = 100000000 // 100mb
|
|
66
|
+
|
|
58
67
|
export default {
|
|
59
68
|
name: "MediaUploader",
|
|
60
69
|
data() {
|
|
@@ -62,23 +71,15 @@ export default {
|
|
|
62
71
|
count: 0,
|
|
63
72
|
progress: 0,
|
|
64
73
|
mediaList: [],
|
|
65
|
-
_mediaFileCrud: null
|
|
74
|
+
_mediaFileCrud: null
|
|
66
75
|
};
|
|
67
76
|
},
|
|
68
|
-
props: {
|
|
69
|
-
parentFolder: {
|
|
70
|
-
type: Object,
|
|
71
|
-
},
|
|
72
|
-
folders: {
|
|
73
|
-
type: Array,
|
|
74
|
-
default: () => [],
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
77
|
computed: {
|
|
78
|
+
...mapGetters("mapo/media", ["parentFolder", "folders"]),
|
|
78
79
|
mediaFileCrud() {
|
|
79
80
|
this._mediaFileCrud =
|
|
80
81
|
this._mediaFileCrud ||
|
|
81
|
-
this.$mapo.$api.crud("api/
|
|
82
|
+
this.$mapo.$api.crud("api/media");
|
|
82
83
|
return this._mediaFileCrud;
|
|
83
84
|
},
|
|
84
85
|
completed() {
|
|
@@ -88,19 +89,30 @@ export default {
|
|
|
88
89
|
return [
|
|
89
90
|
{
|
|
90
91
|
text: (this.parentFolder && this.parentFolder.path) || "/",
|
|
91
|
-
value: (this.parentFolder && this.parentFolder.id) || null
|
|
92
|
+
value: (this.parentFolder && this.parentFolder.id) || null
|
|
92
93
|
},
|
|
93
|
-
...this.folders.map(
|
|
94
|
+
...this.folders.map(folder => ({
|
|
94
95
|
text: folder.path,
|
|
95
|
-
value: folder.id
|
|
96
|
-
}))
|
|
96
|
+
value: folder.id
|
|
97
|
+
}))
|
|
97
98
|
];
|
|
98
|
-
}
|
|
99
|
+
}
|
|
99
100
|
},
|
|
100
101
|
methods: {
|
|
102
|
+
isTooLarge({ info }){
|
|
103
|
+
const {type} = info;
|
|
104
|
+
switch (type.split("/")[0]) {
|
|
105
|
+
case "image":
|
|
106
|
+
return info.rawsize > MAX_IMAGE_SIZE;
|
|
107
|
+
case "video":
|
|
108
|
+
return info.rawsize > MAX_VIDEO_SIZE;
|
|
109
|
+
default:
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
},
|
|
101
113
|
updateMediaList(mediaList) {
|
|
102
114
|
this.mediaList = mediaList;
|
|
103
|
-
this.mediaList.forEach(
|
|
115
|
+
this.mediaList.forEach(media => {
|
|
104
116
|
media.info.title = media.info.title || media.info.name;
|
|
105
117
|
media.info.alt_text = media.info.alt_text || media.info.name;
|
|
106
118
|
media.info.description = media.info.description || media.info.name;
|
|
@@ -114,7 +126,7 @@ export default {
|
|
|
114
126
|
},
|
|
115
127
|
updateAll() {
|
|
116
128
|
return Promise.all(
|
|
117
|
-
this.mediaList.map(
|
|
129
|
+
this.mediaList.map(media =>
|
|
118
130
|
this.uploadMedia(
|
|
119
131
|
Object.assign(
|
|
120
132
|
{ file: media.blob },
|
|
@@ -122,27 +134,27 @@ export default {
|
|
|
122
134
|
title: media.info.title,
|
|
123
135
|
alt_text: media.info.alt_text,
|
|
124
136
|
description: media.info.description,
|
|
125
|
-
folder: media.info.folder
|
|
137
|
+
folder: media.info.folder
|
|
126
138
|
}
|
|
127
139
|
)
|
|
128
140
|
)
|
|
129
141
|
)
|
|
130
|
-
).then(
|
|
131
|
-
this
|
|
132
|
-
|
|
133
|
-
response.length || this.mediaList.length
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
142
|
+
).then(response => {
|
|
143
|
+
if (this.mediaList && this.mediaList.length) {
|
|
144
|
+
this.$mapo.$snack.open({
|
|
145
|
+
message: this.$t("mapo.mediaUploader.success", {numberFiles: response.length || this.mediaList.length})
|
|
146
|
+
});
|
|
147
|
+
this.$emit("Upload", (response.length && response) || this.mediaList);
|
|
148
|
+
this.$refs.closeButton.$el.click();
|
|
149
|
+
}
|
|
138
150
|
});
|
|
139
151
|
},
|
|
140
152
|
uploadMedia(media) {
|
|
141
|
-
const index = this.mediaList.findIndex(
|
|
153
|
+
const index = this.mediaList.findIndex(el => el.blob === media.file);
|
|
142
154
|
const payload = this.$mapo.$api.multipart(media, ["file"]);
|
|
143
155
|
const conf = {
|
|
144
156
|
headers: { "Content-Type": "multipart/form-data" },
|
|
145
|
-
onUploadProgress: function
|
|
157
|
+
onUploadProgress: function(event) {
|
|
146
158
|
this.mediaList[index].progress = Math.ceil(
|
|
147
159
|
(event.loaded / event.total) * 100
|
|
148
160
|
);
|
|
@@ -153,10 +165,10 @@ export default {
|
|
|
153
165
|
(acc, media) => acc + (media.progress === 100),
|
|
154
166
|
0
|
|
155
167
|
);
|
|
156
|
-
}.bind(this)
|
|
168
|
+
}.bind(this)
|
|
157
169
|
};
|
|
158
170
|
return this.mediaFileCrud.create(payload, conf);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
161
173
|
};
|
|
162
174
|
</script>
|
package/components/SnackBar.vue
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
<v-snackbar v-model="snackbar">
|
|
3
3
|
{{ message }}
|
|
4
4
|
<template v-slot:action="{ attrs }">
|
|
5
|
-
<v-btn color="
|
|
6
|
-
|
|
5
|
+
<v-btn :color="color" text v-bind="attrs" @click="closeSnack">
|
|
6
|
+
{{ $t("mapo.close") }}
|
|
7
7
|
</v-btn>
|
|
8
8
|
</template>
|
|
9
9
|
</v-snackbar>
|
|
@@ -23,7 +23,7 @@ export default {
|
|
|
23
23
|
data: () => ({
|
|
24
24
|
snackbar: false,
|
|
25
25
|
message: null,
|
|
26
|
-
color: "
|
|
26
|
+
color: "primary",
|
|
27
27
|
}),
|
|
28
28
|
computed: {
|
|
29
29
|
...mapGetters({
|
|
@@ -34,7 +34,6 @@ export default {
|
|
|
34
34
|
closeSnack() {
|
|
35
35
|
this.snackbar = false;
|
|
36
36
|
this.message = null;
|
|
37
|
-
this.color = "green";
|
|
38
37
|
},
|
|
39
38
|
},
|
|
40
39
|
|
|
@@ -48,7 +47,7 @@ export default {
|
|
|
48
47
|
if (val) {
|
|
49
48
|
this.snackbar = true;
|
|
50
49
|
this.message = val.message;
|
|
51
|
-
this.color = val.color ||
|
|
50
|
+
this.color = val.color || "primary";
|
|
52
51
|
} else {
|
|
53
52
|
this.closeSnack();
|
|
54
53
|
}
|
|
@@ -57,7 +56,6 @@ export default {
|
|
|
57
56
|
};
|
|
58
57
|
</script>
|
|
59
58
|
|
|
60
|
-
|
|
61
59
|
<docs>
|
|
62
60
|
### Example usage:
|
|
63
61
|
|
|
@@ -68,4 +66,4 @@ this.$mapo.$snack.open({
|
|
|
68
66
|
});
|
|
69
67
|
```
|
|
70
68
|
|
|
71
|
-
</docs>
|
|
69
|
+
</docs>
|