From c81affcc30df5b6046472617bb71ff0ed523a072 Mon Sep 17 00:00:00 2001 From: Laurent Chauvin Date: Thu, 24 Oct 2024 14:58:08 -0400 Subject: [PATCH] feat(View): Save active view id --- src/components/LayoutGrid.vue | 8 ++++++++ src/store/views.ts | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/components/LayoutGrid.vue b/src/components/LayoutGrid.vue index ea161001..e748adf1 100644 --- a/src/components/LayoutGrid.vue +++ b/src/components/LayoutGrid.vue @@ -13,6 +13,7 @@ :id="item.id" :type="item.viewType" v-bind="item.props" + @focus="onFocusView(item.id!, item.viewType!)" /> @@ -28,6 +29,13 @@ import { useViewStore } from '../store/views'; export default defineComponent({ name: 'LayoutGrid', + methods: { + onFocusView(id: string, type: string) { + if (type === '2D') { + useViewStore().setActiveViewID(id); + } + }, + }, props: { layout: { type: Object as PropType, diff --git a/src/store/views.ts b/src/store/views.ts index d4513e73..18c435a6 100644 --- a/src/store/views.ts +++ b/src/store/views.ts @@ -12,6 +12,7 @@ import { interface State { layout: Layout; viewSpecs: Record; + activeViewID: string; } export const useViewStore = defineStore('view', { @@ -21,6 +22,7 @@ export const useViewStore = defineStore('view', { items: [], }, viewSpecs: structuredClone(InitViewSpecs), + activeViewID: '', }), getters: { viewIDs(state) { @@ -28,6 +30,9 @@ export const useViewStore = defineStore('view', { }, }, actions: { + setActiveViewID(id: string) { + this.activeViewID = id; + }, addView(id: string) { if (!(id in this.viewSpecs)) { this.viewSpecs[id] = structuredClone(DefaultViewSpec);