Added File Sorting

This commit is contained in:
2025-04-22 14:37:41 +02:00
parent 3998c997d4
commit e6c9942d7d
3 changed files with 70 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ import {useSupabaseSelectSingle} from "~/composables/useSupabase.js";
import DocumentDisplayModal from "~/components/DocumentDisplayModal.vue";
import DocumentUploadModal from "~/components/DocumentUploadModal.vue";
import dayjs from "dayjs";
import arraySort from "array-sort";
definePageMeta({
middleware: "auth"
@@ -291,6 +292,20 @@ const renderedFileList = computed(() => {
type: "file"
}
})
console.log(currentFolders.value)
arraySort(files, (a,b) => {
let aVal = a.path ? a.path.split("/")[a.path.split("/").length -1] : null
let bVal = b.path ? b.path.split("/")[b.path.split("/").length -1] : null
if(aVal && bVal) {
return aVal.localeCompare(bVal)
} else if(!aVal && bVal) {
return 1
} else {
return -1
}
}, {reverse: true})
let folders = currentFolders.value.map(i => {
return {
@@ -300,6 +315,15 @@ const renderedFileList = computed(() => {
}
})
arraySort(folders, "label")
/*folders.sort(function(a, b) {
// Compare the 2 dates
if (a.name < b.name) return -1;
if (a.name > b.name) return 1;
return 0;
});*/
return [...folders,...files]
})