Skip to content

Commit 06a4282

Browse files
authored
Merge pull request #676 from lchauvin/store-active-view-id
feat(View): Save active view id
2 parents 9d5eeab + c81affc commit 06a4282

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/components/LayoutGrid.vue

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
:id="item.id"
1414
:type="item.viewType"
1515
v-bind="item.props"
16+
@focus="onFocusView(item.id!, item.viewType!)"
1617
/>
1718
</div>
1819
</div>
@@ -28,6 +29,13 @@ import { useViewStore } from '../store/views';
2829
2930
export default defineComponent({
3031
name: 'LayoutGrid',
32+
methods: {
33+
onFocusView(id: string, type: string) {
34+
if (type === '2D') {
35+
useViewStore().setActiveViewID(id);
36+
}
37+
},
38+
},
3139
props: {
3240
layout: {
3341
type: Object as PropType<Layout>,

src/store/views.ts

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
interface State {
1313
layout: Layout;
1414
viewSpecs: Record<string, ViewSpec>;
15+
activeViewID: string;
1516
}
1617

1718
export const useViewStore = defineStore('view', {
@@ -21,13 +22,17 @@ export const useViewStore = defineStore('view', {
2122
items: [],
2223
},
2324
viewSpecs: structuredClone(InitViewSpecs),
25+
activeViewID: '',
2426
}),
2527
getters: {
2628
viewIDs(state) {
2729
return Object.keys(state.viewSpecs);
2830
},
2931
},
3032
actions: {
33+
setActiveViewID(id: string) {
34+
this.activeViewID = id;
35+
},
3136
addView(id: string) {
3237
if (!(id in this.viewSpecs)) {
3338
this.viewSpecs[id] = structuredClone(DefaultViewSpec);

0 commit comments

Comments
 (0)