Skip to content

Commit

Permalink
add multi_file_selected option
Browse files Browse the repository at this point in the history
  • Loading branch information
ctf0 committed Apr 18, 2018
1 parent d47f53b commit 55b84d4
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 16 deletions.
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,20 @@ new Vue({

- events

| type | event-name | description |
|-----------------|---------------------------------------|--------------------------------------------------|
| [JS][js] | | |
| | modal-show | when modal is showen |
| | modal-hide | when modal is hidden |
| | file_selected *(when inside modal)* | get selected file url |
| | folder_selected *(when inside modal)* | get selected folder path |
| [Laravel][lara] | | |
| | MMFileUploaded($file_path) | get uploaded file full [path][path] |
| | [MMFileSaved][event]($file_path) | get saved(edited/link) image full [path][path] |
| | MMFileDeleted($file_path, $is_folder) | get deleted file/folder full [path][path] |
| | MMFileRenamed($old_path, $new_path) | get renamed file/folder "old & new" [path][path] |
| | MMFileMoved($old_path, $new_path) | get moved file/folder "old & new" [path][path] |
| type | event-name | description |
|-----------------|-------------------------------------------|--------------------------------------------------|
| [JS][js] | | |
| | modal-show | when modal is showen |
| | modal-hide | when modal is hidden |
| | file_selected *(when inside modal)* | get selected file url |
| | multi_file_selected *(when inside modal)* | get bulk selected files url |
| | folder_selected *(when inside modal)* | get selected folder path |
| [Laravel][lara] | | |
| | MMFileUploaded($file_path) | get uploaded file full [path][path] |
| | [MMFileSaved][event]($file_path) | get saved(edited/link) image full [path][path] |
| | MMFileDeleted($file_path, $is_folder) | get deleted file/folder full [path][path] |
| | MMFileRenamed($old_path, $new_path) | get renamed file/folder "old & new" [path][path] |
| | MMFileMoved($old_path, $new_path) | get moved file/folder "old & new" [path][path] |

[js]: https://github.com/gocanto/vuemit
[lara]: https://laravel.com/docs/5.5/events#manually-registering-events
Expand Down
34 changes: 32 additions & 2 deletions src/resources/assets/js/mixins/media-modal.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,48 @@
<script>
export default {
name: 'image-modal',
props: ['old', 'item', 'name', 'type'],
props: {
'item': {
type: String,
required: true
},
'name': {
type: String,
required: true
},
'old': {
type: String,
required: false,
default: ''
},
'type': {
type: String,
required: false,
default: ''
},
'multi': {
type: Boolean,
required: false,
default: false
}
},
mounted() {
if (this.old) {
this.$parent[this.item] = this.old
}
EventHub.listen('file_selected', (path) => {
if (this.item == this.name && this.type !== 'folder') {
if (this.item == this.name && this.type !== 'folder' && !this.multi) {
this.$parent[this.item] = path
}
})
EventHub.listen('multi_file_selected', (paths) => {
if (this.item == this.name && this.type !== 'folder' && this.multi) {
this.$parent[this.item] = paths
}
})
EventHub.listen('folder_selected', (path) => {
if (this.item == this.name && this.type == 'folder') {
this.$parent[this.item] = path
Expand Down
7 changes: 6 additions & 1 deletion src/resources/assets/js/modules/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
},
selectedFile(val) {
if (val) {
if (this.inModal) {
if (this.inModal && !this.isBulkSelecting()) {
this.selectedFileIs('folder')
? EventHub.fire('folder_selected', `${this.files.path}/${val.name}`)
: EventHub.fire('file_selected', val.path)
Expand Down Expand Up @@ -40,6 +40,11 @@ export default {
}
},
bulkItemsCount(val) {
if (val > 0 && this.inModal && !this.selectedFileIs('folder')) {
let links = this.bulkList.map((e) => e.path)
EventHub.fire('multi_file_selected', links)
}

if (val > 1 && !this.bulkSelectAll) {
this.bulkSelectAll = true
}
Expand Down

0 comments on commit 55b84d4

Please sign in to comment.