diff --git a/app/src/apps/classroom_compliance/EntriesTable.vue b/app/src/apps/classroom_compliance/EntriesTable.vue index 9b0b9ba..5ce2a53 100644 --- a/app/src/apps/classroom_compliance/EntriesTable.vue +++ b/app/src/apps/classroom_compliance/EntriesTable.vue @@ -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 = 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)