Skip to content

Commit

Permalink
feat: implement order
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Mattos <[email protected]>
  • Loading branch information
vitormattos committed Oct 24, 2024
1 parent 4a41eda commit 933046a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/store/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ export const useFilesStore = function(...args) {
loading: false,
filterActive: 'all',
canRequestSign: loadState('libresign', 'can_request_sign', false),
ordered: [],
}
},

actions: {
addFile(file) {
set(this.files, file.nodeId, file)
this.hydrateFile(file.nodeId)
this.ordered.push(file.nodeId)
},
selectFile(nodeId) {
this.selectedNodeId = nodeId ?? 0
Expand Down Expand Up @@ -213,6 +215,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 = {}
Expand All @@ -234,11 +241,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') {
Expand Down
2 changes: 1 addition & 1 deletion src/views/FilesList/VirtualList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
:class="userConfigStore.grid_view ? 'files-list__tbody--grid' : 'files-list__tbody--list'"
data-cy-files-list-tbody>
<component :is="dataComponent"
v-for="(item) in filesStore.files"
v-for="(item) in filesStore.filesSorted()"
:key="item.nodeId"
:source="item"
:loading="loading" />
Expand Down

0 comments on commit 933046a

Please sign in to comment.