Added saved preference for sort order.
This commit is contained in:
parent
f06a83aa1b
commit
9a51266fd3
|
@ -47,7 +47,9 @@ onMounted(async () => {
|
|||
} else if (sortingChoice.value === 'desk') {
|
||||
students.value.sort(sortEntriesByDeskNumber)
|
||||
}
|
||||
saveSortPreference()
|
||||
})
|
||||
attemptSortByStoredPreference()
|
||||
})
|
||||
|
||||
async function loadEntries() {
|
||||
|
@ -84,6 +86,23 @@ function sortEntriesByDeskNumber(a: EntriesResponseStudent, b: EntriesResponseSt
|
|||
return sortEntriesByName(a, b)
|
||||
}
|
||||
|
||||
function attemptSortByStoredPreference() {
|
||||
const storedPreferences = localStorage.getItem(`entries-table.${props.classId}.preferences`)
|
||||
if (storedPreferences !== null) {
|
||||
const preferences: Record<string, string> = JSON.parse(storedPreferences)
|
||||
if ('sort' in preferences) {
|
||||
sortingChoice.value = preferences['sort']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function saveSortPreference() {
|
||||
const preferences = {
|
||||
'sort': sortingChoice.value
|
||||
}
|
||||
localStorage.setItem(`entries-table.${props.classId}.preferences`, JSON.stringify(preferences))
|
||||
}
|
||||
|
||||
function shiftDateRange(days: number) {
|
||||
toDate.value.setDate(toDate.value.getDate() + days)
|
||||
fromDate.value.setDate(fromDate.value.getDate() + days)
|
||||
|
|
Loading…
Reference in New Issue