mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-26 14:34:42 +00:00
file preview fix
This commit is contained in:
@@ -97,29 +97,9 @@ export default {
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
files() {
|
||||
if (this.files.length === 0) events.$emit('file-preview-wrapper:hide')
|
||||
},
|
||||
currentFile() {
|
||||
if (this.clipboard[0]) {
|
||||
this.$store.commit('CLIPBOARD_CLEAR')
|
||||
this.$store.commit('ADD_ITEM_TO_CLIPBOARD', this.currentFile)
|
||||
}
|
||||
},
|
||||
clipboard() {
|
||||
if (!this.clipboard[0]) {
|
||||
this.currentIndex -= 1
|
||||
|
||||
this.$store.commit('ADD_ITEM_TO_CLIPBOARD', this.currentFile)
|
||||
|
||||
this.files = []
|
||||
}
|
||||
},
|
||||
data(newValue, oldValue) {
|
||||
if (newValue !== oldValue) {
|
||||
this.files = []
|
||||
}
|
||||
},
|
||||
currentIndex() {
|
||||
this.$store.commit('CLIPBOARD_REPLACE', this.currentFile)
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
checkGroupInView: _.debounce(function () {
|
||||
@@ -186,11 +166,24 @@ export default {
|
||||
}
|
||||
},
|
||||
},
|
||||
created() {
|
||||
mounted() {
|
||||
events.$on('file-preview:next', () => this.next())
|
||||
events.$on('file-preview:prev', () => this.prev())
|
||||
|
||||
this.getFilesForView()
|
||||
|
||||
events.$on('file:deleted', id => {
|
||||
this.files = this.files.filter(item => item.data.id !== id)
|
||||
|
||||
if (this.files.length === 0) {
|
||||
events.$emit('file-preview:hide')
|
||||
} else {
|
||||
this.$store.commit('CLIPBOARD_REPLACE', this.currentFile)
|
||||
}
|
||||
})
|
||||
},
|
||||
destroyed() {
|
||||
events.$off('file:deleted')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -124,7 +124,7 @@ export default {
|
||||
if ((e.ctrlKey || e.metaKey) && !e.shiftKey) {
|
||||
// Click + Ctrl
|
||||
if (this.clipboard.some((item) => item.data.id === this.item.data.id)) {
|
||||
this.$store.commit('REMOVE_ITEM_FROM_CLIPBOARD', this.item)
|
||||
this.$store.commit('REMOVE_ITEM_FROM_CLIPBOARD', this.item.data.id)
|
||||
} else {
|
||||
this.$store.commit('ADD_ITEM_TO_CLIPBOARD', this.item)
|
||||
}
|
||||
@@ -171,7 +171,7 @@ export default {
|
||||
|
||||
if (this.isMultiSelectMode && this.$isMobile()) {
|
||||
if (this.clipboard.some((item) => item.data.id === this.item.data.id)) {
|
||||
this.$store.commit('REMOVE_ITEM_FROM_CLIPBOARD', this.item)
|
||||
this.$store.commit('REMOVE_ITEM_FROM_CLIPBOARD', this.item.data.id)
|
||||
} else {
|
||||
this.$store.commit('ADD_ITEM_TO_CLIPBOARD', this.item)
|
||||
}
|
||||
|
||||
+5
-2
@@ -178,12 +178,15 @@ const mutations = {
|
||||
if (el.data.id && el.data.id === id) el.data.attributes.items++
|
||||
})
|
||||
},
|
||||
REMOVE_ITEM_FROM_CLIPBOARD(state, item) {
|
||||
state.clipboard = state.clipboard.filter((element) => element.data.id !== item.data.id)
|
||||
REMOVE_ITEM_FROM_CLIPBOARD(state, id) {
|
||||
state.clipboard = state.clipboard.filter((element) => element.data.id !== id)
|
||||
},
|
||||
ADD_ALL_ITEMS_TO_CLIPBOARD(state) {
|
||||
state.clipboard = state.entries
|
||||
},
|
||||
CLIPBOARD_REPLACE(state, item) {
|
||||
state.clipboard = [item]
|
||||
},
|
||||
ADD_ITEM_TO_CLIPBOARD(state, item) {
|
||||
let selectedItem = state.entries.find((el) => el.data.id === item.data.id)
|
||||
|
||||
|
||||
+2
-5
@@ -311,6 +311,8 @@ const actions = {
|
||||
|
||||
// Remove file
|
||||
commit('REMOVE_ITEM', data.data.id)
|
||||
commit('REMOVE_ITEM_FROM_CLIPBOARD', data.data.id)
|
||||
events.$emit('file:deleted', data.data.id)
|
||||
|
||||
// Remove item from sidebar
|
||||
if (! ['Public', 'RequestUpload'].includes(router.currentRoute.name)) {
|
||||
@@ -318,11 +320,6 @@ const actions = {
|
||||
}
|
||||
})
|
||||
|
||||
// Remove file preview
|
||||
if (!noSelectedItem) {
|
||||
commit('CLIPBOARD_CLEAR')
|
||||
}
|
||||
|
||||
// Get route
|
||||
let route = {
|
||||
RequestUpload: `/api/upload-request/${router.currentRoute.params.token}/remove`,
|
||||
|
||||
Reference in New Issue
Block a user