Added File Sorting
This commit is contained in:
@@ -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]
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user