Skip to content

Commit 478f651

Browse files
authored
[4.0] Select image/audio/video/document file from Media Manager (#34634)
1 parent 5a23ae2 commit 478f651

File tree

37 files changed

+2327
-10594
lines changed

37 files changed

+2327
-10594
lines changed

administrator/components/com_media/config.xml

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@
33
<fieldset
44
name="component"
55
label="COM_MEDIA_FIELDSET_OPTIONS_LABEL">
6-
<field
7-
name="upload_extensions"
8-
type="text"
9-
label="COM_MEDIA_FIELD_LEGAL_EXTENSIONS_LABEL"
10-
description="COM_MEDIA_FIELD_LEGAL_EXTENSIONS_DESC"
11-
size="50"
12-
default="bmp,csv,doc,gif,ico,jpg,jpeg,odg,odp,ods,odt,pdf,png,ppt,txt,xcf,xls,BMP,CSV,DOC,GIF,ICO,JPG,JPEG,ODG,ODP,ODS,ODT,PDF,PNG,PPT,TXT,XCF,XLS"
13-
/>
146

157
<field
168
name="upload_maxsize"
@@ -56,6 +48,16 @@
5648
<option value="1">JYES</option>
5749
</field>
5850

51+
<field
52+
name="restrict_uploads_extensions"
53+
type="text"
54+
label="COM_MEDIA_FIELD_RESTRICT_UPLOADS_EXTENSIONS_LABEL"
55+
description="COM_MEDIA_FIELD_RESTRICT_UPLOADS_EXTENSIONS_DESC"
56+
size="50"
57+
default="bmp,gif,jpg,jpeg,png,ico,mp3,mp4,odg,odp,ods,odt,pdf,png,ppt,txt,xcf,xls,csv"
58+
showon="restrict_uploads:1"
59+
/>
60+
5961
<field
6062
name="check_mime"
6163
type="radio"
@@ -75,8 +77,34 @@
7577
label="COM_MEDIA_FIELD_LEGAL_IMAGE_EXTENSIONS_LABEL"
7678
description="COM_MEDIA_FIELD_LEGAL_IMAGE_EXTENSIONS_DESC"
7779
size="50"
78-
default="bmp,gif,jpg,jpeg,png"
79-
showon="restrict_uploads:1"
80+
default="bmp,gif,jpg,jpeg,png,webp"
81+
/>
82+
83+
<field
84+
name="audio_extensions"
85+
type="text"
86+
label="COM_MEDIA_FIELD_LEGAL_AUDIO_EXTENSIONS_LABEL"
87+
description="COM_MEDIA_FIELD_LEGAL_AUDIO_EXTENSIONS_DESC"
88+
size="50"
89+
default="mp3,m4a,mp4a,ogg"
90+
/>
91+
92+
<field
93+
name="video_extensions"
94+
type="text"
95+
label="COM_MEDIA_FIELD_LEGAL_VIDEO_EXTENSIONS_LABEL"
96+
description="COM_MEDIA_FIELD_LEGAL_VIDEO_EXTENSIONS_DESC"
97+
size="50"
98+
default="mp4,mp4v,mpeg,mov,webm"
99+
/>
100+
101+
<field
102+
name="doc_extensions"
103+
type="text"
104+
label="COM_MEDIA_FIELD_LEGAL_DOCUMENT_EXTENSIONS_LABEL"
105+
description="COM_MEDIA_FIELD_LEGAL_DOCUMENT_EXTENSIONS_DESC"
106+
size="50"
107+
default="doc,odg,odp,ods,odt,pdf,png,ppt,txt,xcf,xls,csv"
80108
/>
81109

82110
<field
@@ -93,7 +121,7 @@
93121
label="COM_MEDIA_FIELD_LEGAL_MIME_TYPES_LABEL"
94122
description="COM_MEDIA_FIELD_LEGAL_MIME_TYPES_DESC"
95123
size="50"
96-
default="image/jpeg,image/gif,image/png,image/bmp,application/msword,application/excel,application/pdf,application/powerpoint,text/plain,application/x-zip"
124+
default="image/jpeg,image/gif,image/png,image/bmp,image/webp,audio/ogg,audio/mpeg,audio/mp4,video/mp4,video/mpeg,video/quicktime,video/webm,application/msword,application/excel,application/pdf,application/powerpoint,text/plain,application/x-zip"
97125
showon="restrict_uploads:1"
98126
/>
99127

administrator/components/com_media/resources/scripts/app/Api.es6.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class Api {
2323
this._csrfToken = Joomla.getOptions('csrf.token');
2424

2525
this.imagesExtensions = options.imagesExtensions;
26+
this.audioExtensions = options.audioExtensions;
27+
this.videoExtensions = options.videoExtensions;
28+
this.documentExtensions = options.documentExtensions;
2629
}
2730

2831
/**

administrator/components/com_media/resources/scripts/components/breadcrumb/breadcrumb.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ export default {
6262
/* Handle the on crumb click event */
6363
onCrumbClick(crumb) {
6464
this.navigateTo(crumb.path);
65+
window.parent.document.dispatchEvent(
66+
new CustomEvent(
67+
'onMediaFileSelected',
68+
{
69+
bubbles: true,
70+
cancelable: false,
71+
detail: {},
72+
},
73+
),
74+
);
6575
},
6676
findDrive(adapter) {
6777
let driveObject = null;
Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
<template>
2+
<div
3+
class="media-browser-audio"
4+
@dblclick="openPreview()"
5+
@mouseleave="hideActions()"
6+
>
7+
<div class="media-browser-item-preview">
8+
<div class="file-background">
9+
<div class="file-icon">
10+
<span class="fas fa-file-audio" />
11+
</div>
12+
</div>
13+
</div>
14+
<div class="media-browser-item-info">
15+
{{ item.name }} {{ item.filetype }}
16+
</div>
17+
<span
18+
class="media-browser-select"
19+
:aria-label="translate('COM_MEDIA_TOGGLE_SELECT_ITEM')"
20+
:title="translate('COM_MEDIA_TOGGLE_SELECT_ITEM')"
21+
/>
22+
<div
23+
class="media-browser-actions"
24+
:class="{'active': showActions}"
25+
>
26+
<button
27+
ref="actionToggle"
28+
type="button"
29+
class="action-toggle"
30+
:aria-label="translate('COM_MEDIA_OPEN_ITEM_ACTIONS')"
31+
:title="translate('COM_MEDIA_OPEN_ITEM_ACTIONS')"
32+
@keyup.enter="openActions()"
33+
@focus="focused(true)"
34+
@blur="focused(false)"
35+
@keyup.space="openActions()"
36+
@keyup.down="openActions()"
37+
@keyup.up="openLastActions()"
38+
>
39+
<span
40+
class="image-browser-action icon-ellipsis-h"
41+
aria-hidden="true"
42+
@click.stop="openActions()"
43+
/>
44+
</button>
45+
<div
46+
v-if="showActions"
47+
class="media-browser-actions-list"
48+
>
49+
<ul>
50+
<li>
51+
<button
52+
ref="actionPreview"
53+
type="button"
54+
class="action-preview"
55+
:aria-label="translate('COM_MEDIA_ACTION_PREVIEW')"
56+
:title="translate('COM_MEDIA_ACTION_PREVIEW')"
57+
@keyup.enter="openPreview()"
58+
@keyup.space="openPreview()"
59+
@focus="focused(true)"
60+
@blur="focused(false)"
61+
@keyup.esc="hideActions()"
62+
@keyup.up="$refs.actionDelete.focus()"
63+
@keyup.down="$refs.actionDownload.focus()"
64+
>
65+
<span
66+
class="image-browser-action icon-search-plus"
67+
aria-hidden="true"
68+
@click.stop="openPreview()"
69+
/>
70+
</button>
71+
</li>
72+
<li>
73+
<button
74+
ref="actionDownload"
75+
type="button"
76+
class="action-download"
77+
:aria-label="translate('COM_MEDIA_ACTION_DOWNLOAD')"
78+
:title="translate('COM_MEDIA_ACTION_DOWNLOAD')"
79+
@keyup.enter="download()"
80+
@keyup.space="download()"
81+
@focus="focused(true)"
82+
@blur="focused(false)"
83+
@keyup.esc="hideActions()"
84+
@keyup.up="$refs.actionPreview.focus()"
85+
@keyup.down="$refs.actionRename.focus()"
86+
>
87+
<span
88+
class="image-browser-action icon-download"
89+
aria-hidden="true"
90+
@click.stop="download()"
91+
/>
92+
</button>
93+
</li>
94+
<li>
95+
<button
96+
ref="actionRename"
97+
type="button"
98+
class="action-rename"
99+
:aria-label="translate('COM_MEDIA_ACTION_RENAME')"
100+
:title="translate('COM_MEDIA_ACTION_RENAME')"
101+
@keyup.enter="openRenameModal()"
102+
@keyup.space="openRenameModal()"
103+
@focus="focused(true)"
104+
@blur="focused(false)"
105+
@keyup.esc="hideActions()"
106+
@keyup.up="$refs.actionDownload.focus()"
107+
@keyup.down="$refs.actionShare.focus()"
108+
>
109+
<span
110+
class="image-browser-action icon-text-width"
111+
aria-hidden="true"
112+
@click.stop="openRenameModal()"
113+
/>
114+
</button>
115+
</li>
116+
<li>
117+
<button
118+
ref="actionShare"
119+
type="button"
120+
class="action-url"
121+
:aria-label="translate('COM_MEDIA_ACTION_SHARE')"
122+
:title="translate('COM_MEDIA_ACTION_SHARE')"
123+
@keyup.enter="openShareUrlModal()"
124+
@keyup.space="openShareUrlModal()"
125+
@focus="focused(true)"
126+
@blur="focused(false)"
127+
@keyup.esc="hideActions()"
128+
@keyup.up="$refs.actionRename.focus()"
129+
@keyup.down="$refs.actionDelete.focus()"
130+
>
131+
<span
132+
class="image-browser-action icon-link"
133+
aria-hidden="true"
134+
@click.stop="openShareUrlModal()"
135+
/>
136+
</button>
137+
</li>
138+
<li>
139+
<button
140+
ref="actionDelete"
141+
type="button"
142+
class="action-delete"
143+
:aria-label="translate('COM_MEDIA_ACTION_DELETE')"
144+
:title="translate('COM_MEDIA_ACTION_DELETE')"
145+
@keyup.enter="openConfirmDeleteModal()"
146+
@keyup.space="openConfirmDeleteModal()"
147+
@focus="focused(true)"
148+
@blur="focused(false)"
149+
@keyup.esc="hideActions()"
150+
@keyup.up="$refs.actionShare.focus()"
151+
@keyup.down="$refs.actionPreview.focus()"
152+
>
153+
<span
154+
class="image-browser-action icon-trash"
155+
aria-hidden="true"
156+
@click.stop="openConfirmDeleteModal()"
157+
/>
158+
</button>
159+
</li>
160+
</ul>
161+
</div>
162+
</div>
163+
</div>
164+
</template>
165+
166+
<script>
167+
import * as types from '../../../store/mutation-types.es6';
168+
169+
export default {
170+
name: 'MediaBrowserItemAudio',
171+
// eslint-disable-next-line vue/require-prop-types
172+
props: ['item', 'focused'],
173+
data() {
174+
return {
175+
showActions: false,
176+
};
177+
},
178+
methods: {
179+
/* Preview an item */
180+
openPreview() {
181+
this.$store.commit(types.SHOW_PREVIEW_MODAL);
182+
this.$store.dispatch('getFullContents', this.item);
183+
},
184+
/* Preview an item */
185+
download() {
186+
this.$store.dispatch('download', this.item);
187+
},
188+
/* Opening confirm delete modal */
189+
openConfirmDeleteModal() {
190+
this.$store.commit(types.UNSELECT_ALL_BROWSER_ITEMS);
191+
this.$store.commit(types.SELECT_BROWSER_ITEM, this.item);
192+
this.$store.commit(types.SHOW_CONFIRM_DELETE_MODAL);
193+
},
194+
/* Rename an item */
195+
openRenameModal() {
196+
this.$store.commit(types.SELECT_BROWSER_ITEM, this.item);
197+
this.$store.commit(types.SHOW_RENAME_MODAL);
198+
},
199+
/* Open modal for share url */
200+
openShareUrlModal() {
201+
this.$store.commit(types.SELECT_BROWSER_ITEM, this.item);
202+
this.$store.commit(types.SHOW_SHARE_MODAL);
203+
},
204+
/* Open actions dropdown */
205+
openActions() {
206+
this.showActions = true;
207+
this.$nextTick(() => this.$refs.actionPreview.focus());
208+
},
209+
/* Open actions dropdown and focus on last element */
210+
openLastActions() {
211+
this.showActions = true;
212+
this.$nextTick(() => this.$refs.actionDelete.focus());
213+
},
214+
/* Hide actions dropdown */
215+
hideActions() {
216+
this.showActions = false;
217+
this.$nextTick(() => this.$refs.actionToggle.focus());
218+
},
219+
},
220+
};
221+
</script>

0 commit comments

Comments
 (0)