mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-06 09:47:43 +02:00
Remember viewOptions (#2120)
Signed-off-by: Dvinyanin Alexandr <dvinyanin.alexandr@gmail.com>
This commit is contained in:
@@ -82,7 +82,9 @@ export {
|
||||
getObjectPresenter,
|
||||
LoadingProps,
|
||||
setActiveViewletId,
|
||||
getActiveViewletId
|
||||
getActiveViewletId,
|
||||
setViewOptions,
|
||||
getViewOptions
|
||||
} from './utils'
|
||||
export {
|
||||
HTMLPresenter,
|
||||
|
||||
@@ -422,3 +422,24 @@ export function getActiveViewletId (): Ref<Viewlet> | null {
|
||||
const key = makeViewletKey()
|
||||
return localStorage.getItem(key) as Ref<Viewlet> | null
|
||||
}
|
||||
|
||||
function makeViewOptionsKey (viewletId: Ref<Viewlet>): string {
|
||||
const loc = getCurrentLocation()
|
||||
loc.fragment = undefined
|
||||
loc.query = undefined
|
||||
return `viewOptions:${viewletId}:${locationToUrl(loc)}`
|
||||
}
|
||||
|
||||
export function setViewOptions (viewletId: Ref<Viewlet>, options: string | null): void {
|
||||
const key = makeViewOptionsKey(viewletId)
|
||||
if (options !== null) {
|
||||
localStorage.setItem(key, options)
|
||||
} else {
|
||||
localStorage.removeItem(key)
|
||||
}
|
||||
}
|
||||
|
||||
export function getViewOptions (viewletId: Ref<Viewlet>): string | null {
|
||||
const key = makeViewOptionsKey(viewletId)
|
||||
return localStorage.getItem(key)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user