From 38480fda3cd1f10652bc1e854207b074921e66b8 Mon Sep 17 00:00:00 2001 From: John Molakvoæ Date: Thu, 13 Jul 2023 09:58:24 +0200 Subject: feat(files_external): migrate to vue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- apps/files/src/components/CustomElementRender.vue | 31 +++++++++++++++-------- apps/files/src/components/FileEntry.vue | 31 ++++++++++++++++------- apps/files/src/services/FileAction.ts | 2 +- apps/files/src/views/FilesList.vue | 27 ++++++++++++-------- 4 files changed, 59 insertions(+), 32 deletions(-) (limited to 'apps/files/src') diff --git a/apps/files/src/components/CustomElementRender.vue b/apps/files/src/components/CustomElementRender.vue index b5bcb8daf2c..62e33b06acf 100644 --- a/apps/files/src/components/CustomElementRender.vue +++ b/apps/files/src/components/CustomElementRender.vue @@ -23,7 +23,7 @@ - diff --git a/apps/files/src/components/FileEntry.vue b/apps/files/src/components/FileEntry.vue index 3257e161046..53928b961c2 100644 --- a/apps/files/src/components/FileEntry.vue +++ b/apps/files/src/components/FileEntry.vue @@ -91,8 +91,12 @@ - - + + action?.inline?.(this.source, this.currentView)) }, + // Enabled action that are displayed inline with a custom render function + enabledRenderActions() { + if (!this.active) { + return [] + } + return this.enabledActions.filter(action => typeof action.renderInline === 'function') + }, + // Default actions enabledDefaultActions() { - return this.enabledActions.filter(action => !!action.default) + return this.enabledActions.filter(action => !!action?.default) }, // Actions shown in the menu @@ -407,7 +420,7 @@ export default Vue.extend({ // Showing inline first for the NcActions inline prop ...this.enabledInlineActions, // Then the rest - ...this.enabledActions.filter(action => action.default !== DefaultType.HIDDEN), + ...this.enabledActions.filter(action => action.default !== DefaultType.HIDDEN && typeof action.renderInline !== 'function'), ].filter((value, index, self) => { // Then we filter duplicates to prevent inline actions to be shown twice return index === self.findIndex(action => action.id === value.id) diff --git a/apps/files/src/services/FileAction.ts b/apps/files/src/services/FileAction.ts index 4798128671c..a4f7e3ddf17 100644 --- a/apps/files/src/services/FileAction.ts +++ b/apps/files/src/services/FileAction.ts @@ -74,7 +74,7 @@ interface FileActionData { * If defined, the returned html element will be * appended before the actions menu. */ - renderInline?: (file: Node, view: Navigation) => HTMLElement, + renderInline?: (file: Node, view: Navigation) => Promise, } export class FileAction { diff --git a/apps/files/src/views/FilesList.vue b/apps/files/src/views/FilesList.vue index b14e3287939..99d7767ebc7 100644 --- a/apps/files/src/views/FilesList.vue +++ b/apps/files/src/views/FilesList.vue @@ -183,19 +183,24 @@ export default Vue.extend({ return this.isAscSorting ? results : results.reverse() } + const identifiers = [ + // Sort favorites first if enabled + ...this.userConfig.sort_favorites_first ? [v => v.attributes?.favorite !== 1] : [], + // Sort folders first if sorting by name + ...this.sortingMode === 'basename' ? [v => v.type !== 'folder'] : [], + // Use sorting mode if NOT basename (to be able to use displayName too) + ...this.sortingMode !== 'basename' ? [v => v[this.sortingMode]] : [], + // Use displayName if available, fallback to name + v => v.attributes?.displayName || v.basename, + // Finally, use basename if all previous sorting methods failed + v => v.basename, + ] + const orders = new Array(identifiers.length).fill(this.isAscSorting ? 'asc' : 'desc') + return orderBy( [...(this.currentFolder?._children || []).map(this.getNode).filter(file => file)], - [ - // Sort favorites first if enabled - ...this.userConfig.sort_favorites_first ? [v => v.attributes?.favorite !== 1] : [], - // Sort folders first if sorting by name - ...this.sortingMode === 'basename' ? [v => v.type !== 'folder'] : [], - // Use sorting mode - v => v[this.sortingMode], - // Finally, fallback to name - v => v.basename, - ], - this.isAscSorting ? ['asc', 'asc', 'asc'] : ['desc', 'desc', 'desc'], + identifiers, + orders, ) }, -- cgit v1.2.3