Skip to content

Commit

Permalink
user settings can now display pages on top of tables
Browse files Browse the repository at this point in the history
  • Loading branch information
Kworz committed Mar 19, 2024
1 parent 71960e0 commit 0cb60e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ enum user_settings_keys {
app_language
app_menu_left
app_pages_top_of_table
}

Expand Down
5 changes: 4 additions & 1 deletion src/lib/server/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export const getSettings = (storedAppSettings: Array<app_settings>): typeof defa
const defaultUserSettings = {

app_language: "en",
app_menu_left: true as boolean
app_menu_left: true as boolean,
app_pages_top_of_table: false as boolean

} satisfies Record<user_settings_keys, boolean | string | number>;

Expand All @@ -66,9 +67,11 @@ export type UserSettings = typeof defaultUserSettings;
export const getUserSettings = (storedUserSettings: Array<user_settings>): typeof defaultUserSettings => {

const appLeftMenu = storedUserSettings.find(s => s.key === "app_menu_left")?.value;
const appPagesTopOfTable = storedUserSettings.find(s => s.key === "app_pages_top_of_table")?.value;

return {
app_language: storedUserSettings.find(s => s.key === "app_language")?.value ?? defaultUserSettings.app_language,
app_menu_left: appLeftMenu !== undefined ? (appLeftMenu === "true") : defaultUserSettings.app_menu_left,
app_pages_top_of_table: appPagesTopOfTable !== undefined ? (appPagesTopOfTable === "true") : defaultUserSettings.app_pages_top_of_table
}
}

0 comments on commit 0cb60e0

Please sign in to comment.