Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 40f219d

Browse files
committed
fixes
1 parent a47bb1d commit 40f219d

File tree

9 files changed

+65
-53
lines changed

9 files changed

+65
-53
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
- delete
3939
- bulk selection.
4040
- restrict access to [folders](https://github.com/ctf0/Laravel-Media-Manager/wiki/Folder-Restriction)
41-
- restrict access to [files](https://github.com/ctf0/Laravel-Media-Manager/wiki/File-Extension-Restriction)
41+
- restrict access to [files](https://github.com/ctf0/Laravel-Media-Manager/wiki/Hide-Files-With-Extension)
4242
- download selected ***"including bulk selection"***
4343
- directly copy selected file link.
4444
- use manager [from modal with ease](https://github.com/ctf0/Laravel-Media-Manager/wiki/Use-The-Manager-From-A-Modal)
@@ -158,7 +158,7 @@ return [
158158
/**
159159
* hide file extension in files list
160160
*/
161-
'hide_ext' => true
161+
'hide_files_ext' => true
162162
];
163163
```
164164

src/MediaManagerServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected function viewComp()
7777

7878
view()->composer('MediaManager::_manager', function ($view) use ($url) {
7979
$view->with([
80-
'base_url' => preg_replace('/\/+/', '/', $url),
80+
'base_url' => $url,
8181
]);
8282
});
8383
}

src/config/mediaManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@
4646
/*
4747
* hide file extension in files list
4848
*/
49-
'hide_ext' => true,
49+
'hide_files_ext' => true,
5050
];

src/resources/assets/js/components/media.vue

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ export default {
2525
props: [
2626
'baseUrl',
2727
'inModal',
28-
'hideExt',
28+
'hideFilesExt',
2929
'mediaTrans',
3030
'filesRoute',
3131
'dirsRoute',
3232
'lockFileRoute',
3333
'restrictPath',
34-
'restrictExt'
34+
'hideExt'
3535
],
3636
data() {
3737
return {
@@ -62,11 +62,7 @@ export default {
6262
}
6363
},
6464
created() {
65-
if (this.checkForRestrictedPath()) {
66-
return this.restrictAccess()
67-
}
68-
69-
this.getFiles('/')
65+
this.loadFiles()
7066
},
7167
mounted() {
7268
this.fileUpload()
@@ -111,7 +107,7 @@ export default {
111107
}
112108
})
113109
114-
manager.getFiles(manager.folders)
110+
manager.loadFiles(manager.folders)
115111
},
116112
errormultiple(files, res) {
117113
this.showNotif(res, 'danger')
@@ -174,7 +170,7 @@ export default {
174170
175171
// refresh
176172
if (keycode(e) == 'r') {
177-
this.getFiles(this.folders)
173+
this.loadFiles(this.folders)
178174
}
179175
180176
// file upload
@@ -192,27 +188,37 @@ export default {
192188
return
193189
}
194190
195-
this.$refs.bulkSelect.click()
191+
if (this.$refs.bulkSelect) {
192+
this.$refs.bulkSelect.click()
193+
}
196194
}
197195
198196
// add all to bulk list
199197
if (this.isBulkSelecting() && keycode(e) == 'a') {
200-
this.$refs.bulkSelectAll.click()
198+
if (this.$refs.bulkSelectAll) {
199+
this.$refs.bulkSelectAll.click()
200+
}
201201
}
202202
203203
// delete file
204204
if (keycode(e) == 'delete' || keycode(e) == 'd') {
205-
this.$refs.delete.click()
205+
if (this.$refs.delete) {
206+
this.$refs.delete.click()
207+
}
206208
}
207209
208210
// move file
209211
if (this.checkForFolders && keycode(e) == 'm') {
210-
this.$refs.move.click()
212+
if (this.$refs.move) {
213+
this.$refs.move.click()
214+
}
211215
}
212216
213217
// lock files
214218
if (keycode(e) == 'l') {
215-
this.$refs.lock.click()
219+
if (this.$refs.lock) {
220+
this.$refs.lock.click()
221+
}
216222
}
217223
}
218224
/* end of with or without bulk selection */

src/resources/assets/js/components/mixins/form.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
export default {
22
methods: {
3+
loadFiles(folders = '/', prev = null) {
4+
if (this.checkForRestrictedPath()) {
5+
return this.restrictAccess()
6+
}
7+
8+
this.getFiles(folders, prev)
9+
},
310
/* Main */
411
getFiles(folders, select_prev = null) {
512

@@ -10,15 +17,13 @@ export default {
1017
this.loadingFiles('show')
1118
this.resetInput(['searchFor', 'sortBy', 'currentFilterName'])
1219

13-
let folder_location = '/'
14-
1520
if (folders !== '/') {
16-
folder_location = '/' + folders.join('/')
21+
folders = '/' + folders.join('/')
1722
}
1823

1924
// files list
2025
$.post(this.filesRoute, {
21-
folder: folder_location
26+
folder: folders
2227
}, (res) => {
2328

2429
// folder doesnt exist
@@ -52,8 +57,8 @@ export default {
5257
this.selectFirst()
5358
}
5459

55-
// check for restricted extensions
56-
if (this.restrictExt.length) {
60+
// check for hidden extensions
61+
if (this.hideExt.length) {
5762
this.files.items = this.files.items.filter((e) => {
5863
return !this.checkForRestrictedExt(e)
5964
})
@@ -116,7 +121,7 @@ export default {
116121
}
117122

118123
this.showNotif(`Successfully Created "${data.new_folder_name}" at "${data.full_path}"`)
119-
this.getFiles(this.folders)
124+
this.loadFiles(this.folders)
120125

121126
}).fail(() => {
122127
this.ajaxError()
@@ -134,12 +139,11 @@ export default {
134139
this.toggleLoading()
135140

136141
let filename = this.selectedFile.name
137-
138142
let ext = this.getExtension(filename)
139143
let new_filename = ext == null ? changed : `${changed}.${ext}`
140144

141145
$.post(event.target.action, {
142-
folder_location: this.folders,
146+
folder_location: this.files.path,
143147
filename: filename,
144148
new_filename: new_filename
145149
}, (data) => {
@@ -182,7 +186,7 @@ export default {
182186
let destination = this.moveToPath
183187

184188
$.post(routeUrl, {
185-
folder_location: this.folders,
189+
folder_location: this.files.path,
186190
destination: destination,
187191
moved_files: files
188192
}, (res) => {
@@ -234,7 +238,7 @@ export default {
234238
this.toggleLoading()
235239

236240
$.post(routeUrl, {
237-
folder_location: this.folders,
241+
folder_location: this.files.path,
238242
deleted_files: files
239243
}, (res) => {
240244
this.toggleLoading()
@@ -257,6 +261,7 @@ export default {
257261
})
258262
},
259263

264+
// lock / unlock
260265
lockForm(path, state) {
261266
$.post(this.lockFileRoute, {
262267
path: path,

src/resources/assets/js/components/mixins/restriction.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ export default {
99
this.getFiles(arr)
1010

1111
// show folders if we have something
12-
EventHub.listenOnce('get-folders', (data) => {
13-
if (data) {
14-
return this.folders.push(...arr)
12+
EventHub.listenOnce('get-folders', (check) => {
13+
if (check) {
14+
return this.folders = arr.length > 1 ? [arr[arr.length - 1]] : arr
1515
}
1616
})
1717
},
1818
restrictAndLast() {
1919
return this.checkForRestrictedPath() && this.folders.length < 2
2020
},
2121
checkForRestrictedExt(file) {
22-
return this.restrictExt.includes(this.getExtension(file.name))
22+
return this.hideExt.includes(this.getExtension(file.name))
2323
}
2424
}
2525
}

src/resources/assets/js/components/mixins/selected.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,38 +33,39 @@ export default {
3333
},
3434

3535
/* Folder */
36-
openFolder(file) {
37-
if (!this.isBulkSelecting()) {
38-
if (!this.fileTypeIs(file, 'folder')) {
39-
return false
40-
}
41-
42-
this.folders.push(file.name)
43-
this.getFiles(this.folders)
44-
}
45-
46-
this.resetInput('currentFilterName')
47-
},
4836
goToFolder(index) {
4937
if (!this.isBulkSelecting()) {
5038
this.noFiles('hide')
5139
this.resetInput('currentFilterName')
5240

5341
if (this.checkForRestrictedPath() && index == 0) {
54-
return false
42+
return
5543
}
5644

5745
let prev_folder_name = this.folders[index]
5846

5947
this.folders = this.folders.splice(0, index)
60-
this.getFiles(this.folders, prev_folder_name)
48+
this.loadFiles(this.folders, prev_folder_name)
6149
}
6250
},
51+
openFolder(file) {
52+
if (!this.isBulkSelecting()) {
53+
if (!this.fileTypeIs(file, 'folder')) {
54+
return
55+
}
56+
57+
this.folders.push(file.name)
58+
this.loadFiles(this.folders)
59+
}
60+
61+
this.resetInput('currentFilterName')
62+
},
6363
goToPrevFolder() {
64-
let newSelected = parseInt(this.folders.length) - 1
64+
let length = this.folders.length
65+
let newSelected = length - 1
6566

66-
if (newSelected < 0) {
67-
return false
67+
if (length == 0 || this.restrictPath && this.files.path == `/${this.restrictPath}`) {
68+
return
6869
}
6970

7071
this.goToFolder(newSelected)

src/resources/assets/js/components/mixins/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default {
5757

5858
/* Resolve */
5959
getFileName(name) {
60-
if (!this.hideExt) {
60+
if (!this.hideFilesExt) {
6161
return name
6262
}
6363

src/resources/views/_manager.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
<media-manager inline-template
66
base-url="{{ $base_url }}"
77
:in-modal="{{ isset($modal) ? 'true' : 'false' }}"
8-
:hide-ext="{{ config('mediaManager.hide_ext') ? 'true' : 'false' }}"
8+
:hide-files-ext="{{ config('mediaManager.hide_files_ext') ? 'true' : 'false' }}"
99
:media-trans="{{ json_encode(['no_val' => trans('MediaManager::messages.no_val')]) }}"
1010
files-route="{{ route('media.files') }}"
1111
dirs-route="{{ route('media.directories') }}"
1212
lock-file-route="{{ route('media.lock_file') }}"
1313
restrict-path="{{ isset($path) ? $path : null }}"
14-
restrict-ext="{{ isset($ext) ? json_encode($ext) : null }}">
14+
hide-ext="{{ isset($ext) ? json_encode($ext) : null }}">
1515

1616
<v-touch @swiperight="lightBoxIsActive() ? goToPrev() : false"
1717
@swipeleft="lightBoxIsActive() ? goToNext() : false">

0 commit comments

Comments
 (0)