From 45f39d65fea0c00ea3b01f0593422d97e791ff16 Mon Sep 17 00:00:00 2001 From: John Molakvoæ Date: Fri, 7 Apr 2023 09:30:13 +0200 Subject: fix(files): fix private variables and share loading marker between header and row MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- apps/files/src/components/FileEntry.vue | 6 ++++++ apps/files/src/components/FilesListHeaderActions.vue | 17 ++++++++++++++++- apps/files/src/views/FilesList.vue | 6 +++--- 3 files changed, 25 insertions(+), 4 deletions(-) (limited to 'apps/files/src') diff --git a/apps/files/src/components/FileEntry.vue b/apps/files/src/components/FileEntry.vue index 130cd12367e..fca83cabbd1 100644 --- a/apps/files/src/components/FileEntry.vue +++ b/apps/files/src/components/FileEntry.vue @@ -63,6 +63,7 @@ this.getNode(fileid)) .filter(node => node) }, + + areSomeNodesLoading() { + return this.nodes.some(node => node._loading) + }, }, methods: { @@ -122,9 +126,16 @@ export default Vue.extend({ const displayName = action.displayName(this.nodes, this.currentView) const selectionIds = this.selectedNodes try { + // Set loading markers this.loading = action.id + this.nodes.forEach(node => { + Vue.set(node, '_loading', true) + }) + + // Dispatch action execution const results = await action.execBatch(this.nodes, this.currentView) + // Handle potential failures if (results.some(result => result !== true)) { // Remove the failed ids from the selection const failedIds = selectionIds @@ -142,7 +153,11 @@ export default Vue.extend({ logger.error('Error while executing action', { action, e }) showError(this.t('files', '"{displayName}" action failed', { displayName })) } finally { + // Remove loading markers this.loading = null + this.nodes.forEach(node => { + Vue.set(node, '_loading', false) + }) } }, diff --git a/apps/files/src/views/FilesList.vue b/apps/files/src/views/FilesList.vue index c8d539113ce..fad161a56ec 100644 --- a/apps/files/src/views/FilesList.vue +++ b/apps/files/src/views/FilesList.vue @@ -175,13 +175,13 @@ export default Vue.extend({ // Custom column must provide their own sorting methods if (customColumn?.sort && typeof customColumn.sort === 'function') { - const results = [...(this.currentFolder?.children || []).map(this.getNode).filter(file => file)] + const results = [...(this.currentFolder?._children || []).map(this.getNode).filter(file => file)] .sort(customColumn.sort) return this.isAscSorting ? results : results.reverse() } return orderBy( - [...(this.currentFolder?.children || []).map(this.getNode).filter(file => file)], + [...(this.currentFolder?._children || []).map(this.getNode).filter(file => file)], [ // Sort folders first if sorting by name ...this.sortingMode === 'basename' ? [v => v.type !== 'folder'] : [], @@ -272,7 +272,7 @@ export default Vue.extend({ this.filesStore.updateNodes(contents) // Define current directory children - folder.children = contents.map(node => node.attributes.fileid) + folder._children = contents.map(node => node.attributes.fileid) // If we're in the root dir, define the root if (dir === '/') { -- cgit v1.2.3