|
|
|
@ -21,8 +21,18 @@ const meta = inject(MetaInj, ref())
|
|
|
|
|
|
|
|
|
|
const activeView = inject(ActiveViewInj, ref()) |
|
|
|
|
|
|
|
|
|
const { activeTab } = useTabs() |
|
|
|
|
|
|
|
|
|
const { views, loadViews, isLoading } = useViews(meta) |
|
|
|
|
|
|
|
|
|
const { lastOpenedViewMap } = useProject() |
|
|
|
|
|
|
|
|
|
const setLastOpenedViewId = (viewId?: string) => { |
|
|
|
|
if (viewId && activeTab.value?.id) { |
|
|
|
|
lastOpenedViewMap.value[activeTab.value?.id] = viewId |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const { isUIAllowed } = useUIPermission() |
|
|
|
|
|
|
|
|
|
const router = useRouter() |
|
|
|
@ -43,10 +53,14 @@ const sidebar = ref()
|
|
|
|
|
watch( |
|
|
|
|
[views, () => route.params.viewTitle], |
|
|
|
|
([nextViews, viewTitle]) => { |
|
|
|
|
const lastOpenedViewId = activeTab.value?.id && lastOpenedViewMap.value[activeTab.value?.id] |
|
|
|
|
const lastOpenedView = nextViews.find((v) => v.id === lastOpenedViewId) |
|
|
|
|
|
|
|
|
|
if (viewTitle) { |
|
|
|
|
let view = nextViews.find((v) => v.title === viewTitle) |
|
|
|
|
if (view) { |
|
|
|
|
activeView.value = view |
|
|
|
|
setLastOpenedViewId(activeView.value?.id) |
|
|
|
|
} else { |
|
|
|
|
/** search with view id and if found replace with title */ |
|
|
|
|
view = nextViews.find((v) => v.id === viewTitle) |
|
|
|
@ -58,6 +72,13 @@ watch(
|
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else if (lastOpenedView) { |
|
|
|
|
/** if active view is not found, set it to last opened view */ |
|
|
|
|
router.replace({ |
|
|
|
|
params: { |
|
|
|
|
viewTitle: lastOpenedView.title, |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
if (nextViews?.length && activeView.value !== nextViews[0]) { |
|
|
|
|
activeView.value = nextViews[0] |
|
|
|
|