From 05cc0dd94ad65ced0cd8ff6af1bd0daa63b1ca7c Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Thu, 24 Oct 2024 16:26:55 -0300 Subject: [PATCH] feat: implement order Signed-off-by: Vitor Mattos --- src/store/files.js | 11 +++++++++++ src/views/FilesList/VirtualList.vue | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/store/files.js b/src/store/files.js index 22688be954..dbbc414acb 100644 --- a/src/store/files.js +++ b/src/store/files.js @@ -44,6 +44,7 @@ export const useFilesStore = function(...args) { loading: false, filterActive: 'all', canRequestSign: loadState('libresign', 'can_request_sign', false), + ordered: [], } }, @@ -51,6 +52,7 @@ export const useFilesStore = function(...args) { addFile(file) { set(this.files, file.nodeId, file) this.hydrateFile(file.nodeId) + this.ordered.push(file.nodeId) }, selectFile(nodeId) { this.selectedNodeId = nodeId ?? 0 @@ -229,6 +231,11 @@ export const useFilesStore = function(...args) { })) } del(this.files, file.nodeId) + + const index = this.ordered.indexOf(file.nodeId) + if (index > -1) { + this.ordered.splice(index, 1) + } }, async getAllFiles(filter) { if (!filter) filter = {} @@ -250,11 +257,15 @@ export const useFilesStore = function(...args) { } const response = await axios.get(generateOcsUrl('/apps/libresign/api/v1/file/list'), { params: filter }) this.files = {} + this.ordered = [] response.data.ocs.data.data.forEach(file => { this.addFile(file) }) return this.files }, + filesSorted() { + return this.ordered.map(key => this.files[key]) + }, filter(type) { this.filterActive = type if (type === 'pending') { diff --git a/src/views/FilesList/VirtualList.vue b/src/views/FilesList/VirtualList.vue index 1acf4fc1cd..e3cc011d8c 100644 --- a/src/views/FilesList/VirtualList.vue +++ b/src/views/FilesList/VirtualList.vue @@ -14,7 +14,7 @@ :class="userConfigStore.grid_view ? 'files-list__tbody--grid' : 'files-list__tbody--list'" data-cy-files-list-tbody>