diff --git a/resources/assets/scripts/components/server/components/filemanager/FileContextMenu.vue b/resources/assets/scripts/components/server/components/filemanager/FileContextMenu.vue index d224f6fae..b0c16be8b 100644 --- a/resources/assets/scripts/components/server/components/filemanager/FileContextMenu.vue +++ b/resources/assets/scripts/components/server/components/filemanager/FileContextMenu.vue @@ -74,12 +74,11 @@ }, openRenameModal: function () { - window.events.$emit('server:files:rename', this.object); - this.$emit('close'); + this.$emit('action:rename'); }, openDeleteModal: function () { - this.$emit('action:delete', this.object); + this.$emit('action:delete'); } } }); diff --git a/resources/assets/scripts/components/server/components/filemanager/FileRow.vue b/resources/assets/scripts/components/server/components/filemanager/FileRow.vue index 3beda908a..11c6cb097 100644 --- a/resources/assets/scripts/components/server/components/filemanager/FileRow.vue +++ b/resources/assets/scripts/components/server/components/filemanager/FileRow.vue @@ -31,10 +31,12 @@ :object="file" v-show="contextMenuVisible" v-on:close="contextMenuVisible = false" - v-on:action:delete="showDeleteFileModal" + v-on:action:delete="showModal('delete')" + v-on:action:rename="showModal('rename')" ref="contextMenu" /> - + + @@ -46,10 +48,17 @@ import FileContextMenu from "./FileContextMenu.vue"; import {DirectoryContentObject} from "@/api/server/types"; import DeleteFileModal from "@/components/server/components/filemanager/modals/DeleteFileModal.vue"; + import RenameModal from "@/components/server/components/filemanager/modals/RenameModal.vue"; + + type DataStructure = { + currentDirectory: string, + contextMenuVisible: boolean, + modals: { [key: string]: boolean }, + }; export default Vue.extend({ name: 'FileRow', - components: {DeleteFileModal, Icon, FileContextMenu}, + components: {DeleteFileModal, Icon, FileContextMenu, RenameModal}, props: { file: { @@ -63,11 +72,14 @@ }, }, - data: function () { + data: function (): DataStructure { return { currentDirectory: this.$route.params.path || '/', contextMenuVisible: false, - deleteModalVisible: false, + modals: { + rename: false, + delete: false, + }, }; }, @@ -89,9 +101,13 @@ }, methods: { - showDeleteFileModal: function () { + showModal: function (name: string) { + console.warn('showModal', name); this.contextMenuVisible = false; - this.deleteModalVisible = true; + + Object.keys(this.modals).forEach(k => { + this.modals[k] = k === name; + }); }, /** diff --git a/resources/assets/scripts/components/server/components/filemanager/modals/DeleteFileModal.vue b/resources/assets/scripts/components/server/components/filemanager/modals/DeleteFileModal.vue index 344dc01c3..ac161721f 100644 --- a/resources/assets/scripts/components/server/components/filemanager/modals/DeleteFileModal.vue +++ b/resources/assets/scripts/components/server/components/filemanager/modals/DeleteFileModal.vue @@ -1,5 +1,5 @@ @@ -61,7 +63,6 @@ import getDirectoryContents from "@/api/server/getDirectoryContents"; import FileRow from "@/components/server/components/filemanager/FileRow.vue"; import CreateFolderModal from '../components/filemanager/modals/CreateFolderModal.vue'; - import RenameModal from '../components/filemanager/modals/RenameModal.vue'; import DeleteFileModal from '../components/filemanager/modals/DeleteFileModal.vue'; import {DirectoryContentObject} from "@/api/server/types"; @@ -76,11 +77,9 @@ export default Vue.extend({ name: 'FileManager', - components: {CreateFolderModal, DeleteFileModal, FileRow, RenameModal}, - computed: { - ...mapState('server', ['server', 'credentials']), - ...mapState('socket', ['connected']), + components: {CreateFolderModal, DeleteFileModal, FileRow}, + computed: { /** * Configure the breadcrumbs that display on the filemanager based on the directory that the * user is currently in. @@ -180,12 +179,12 @@ window.events.$emit('server:files:open-directory-modal'); }, - fileRowDeleted: function (file: DirectoryContentObject) { - this.files = this.files.filter(data => data !== file); - }, - - folderRowDeleted: function (file: DirectoryContentObject) { - this.directories = this.directories.filter(data => data !== file); + fileRowDeleted: function (file: DirectoryContentObject, directory: boolean) { + if (directory) { + this.directories = this.directories.filter(data => data !== file); + } else { + this.files = this.files.filter(data => data !== file); + } }, directoryCreated: function (directory: string) {