mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-22 23:06:31 +00:00
3d295b5132
* location tree API * test fixes * initial tree location elements * locations tree page * update meta-data * code-gen * store item display preferences * introduce basic table/card view elements * codegen * set parent location during location creation * add item support for tree query * refactor tree view * wip: location selector improvements * type gen * rename items -> search * remove various log statements * fix markdown rendering for description * update location selectors * fix tests * fix currency tests * formatting
34 lines
996 B
TypeScript
34 lines
996 B
TypeScript
import { Ref } from "vue";
|
|
import { DaisyTheme } from "~~/lib/data/themes";
|
|
|
|
export type ViewType = "table" | "card" | "tree";
|
|
|
|
export type LocationViewPreferences = {
|
|
showDetails: boolean;
|
|
showEmpty: boolean;
|
|
editorAdvancedView: boolean;
|
|
itemDisplayView: ViewType;
|
|
theme: DaisyTheme;
|
|
};
|
|
|
|
/**
|
|
* useViewPreferences loads the view preferences from local storage and hydrates
|
|
* them. These are reactive and will update the local storage when changed.
|
|
*/
|
|
export function useViewPreferences(): Ref<LocationViewPreferences> {
|
|
const results = useLocalStorage(
|
|
"homebox/preferences/location",
|
|
{
|
|
showDetails: true,
|
|
showEmpty: true,
|
|
editorAdvancedView: false,
|
|
itemDisplayView: "card",
|
|
theme: "homebox",
|
|
},
|
|
{ mergeDefaults: true }
|
|
);
|
|
|
|
// casting is required because the type returned is removable, however since we
|
|
// use `mergeDefaults` the result _should_ always be present.
|
|
return results as unknown as Ref<LocationViewPreferences>;
|
|
}
|