Skip to content

Commit

Permalink
Merge pull request #676 from lchauvin/store-active-view-id
Browse files Browse the repository at this point in the history
feat(View): Save active view id
  • Loading branch information
floryst authored Dec 2, 2024
2 parents 9d5eeab + c81affc commit 06a4282
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/LayoutGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
:id="item.id"
:type="item.viewType"
v-bind="item.props"
@focus="onFocusView(item.id!, item.viewType!)"
/>
</div>
</div>
Expand All @@ -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<Layout>,
Expand Down
5 changes: 5 additions & 0 deletions src/store/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
interface State {
layout: Layout;
viewSpecs: Record<string, ViewSpec>;
activeViewID: string;
}

export const useViewStore = defineStore('view', {
Expand All @@ -21,13 +22,17 @@ export const useViewStore = defineStore('view', {
items: [],
},
viewSpecs: structuredClone(InitViewSpecs),
activeViewID: '',
}),
getters: {
viewIDs(state) {
return Object.keys(state.viewSpecs);
},
},
actions: {
setActiveViewID(id: string) {
this.activeViewID = id;
},
addView(id: string) {
if (!(id in this.viewSpecs)) {
this.viewSpecs[id] = structuredClone(DefaultViewSpec);
Expand Down

0 comments on commit 06a4282

Please sign in to comment.