Skip to content

Commit 2c62f2c

Browse files
committed
vuex update
1 parent 179f971 commit 2c62f2c

File tree

3 files changed

+55
-24
lines changed

3 files changed

+55
-24
lines changed

src/components/ComponentDetails.vue

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="container">
3-
<q-card id="store-cards" v-if="active">
3+
<q-card id="store-cards" v-if="this.activeComponentObj">
44
<q-tabs
55
v-model="tab"
66
dense
@@ -14,30 +14,30 @@
1414
<q-tab name="props" label="Component Props" id="label-text" />
1515
</q-tabs>
1616
<q-tab-panels v-model="tab" animated class="html-bg text-white">
17-
<q-tab-panel name="state">
17+
<q-tab-panel name="state" v-model="compoent">
1818
<ul id="stateList">
19-
<li v-for="state in stateOptions" :key="state">
20-
{{ state }}
19+
<li v-for="comp in activeState" :key="comp">
20+
{{ comp }}
2121
</li>
2222
</ul>
2323
</q-tab-panel>
2424
<q-tab-panel name="actions">
2525
<ul id="actionList">
26-
<li v-for="action in actionOptions" :key="action">
27-
{{ action }}
26+
<li v-for="comp in activeActions" :key="comp">
27+
{{ comp }}
2828
</li>
2929
</ul>
3030
</q-tab-panel>
3131
<q-tab-panel name="props">
32-
<ul id="actionList">
33-
<li v-for="prop in propsOptions" :key="prop">
34-
{{ prop }}
32+
<ul id="propsList">
33+
<li v-for="comp in activeProps" :key="comp">
34+
{{ comp }}
3535
</li>
3636
</ul>
3737
</q-tab-panel>
3838
</q-tab-panels>
3939
</q-card>
40-
<h v-else>Select a component to show details</h>
40+
<q-card v-else>Select a component to show details</q-card>
4141
</div>
4242
</template>
4343

@@ -47,22 +47,45 @@ import { mapState } from "vuex";
4747
export default {
4848
name: "ComponentDetails",
4949
computed: {
50-
...mapState(["activeRoute", "routes", "activeComponent"]),
51-
active() {
52-
// this returns active component
53-
return this.routes[this.activeRoute].filter((comp) => {
54-
return comp.componentName === this.activeComponent;
55-
})[0];
56-
},
57-
actionOptions() {
58-
return this.active.actions;
59-
},
60-
stateOptions() {
61-
return this.active.state;
50+
...mapState(["activeComponentObj"]),
51+
// component: {
52+
// get(){
53+
// return this.activeComponentObj
54+
// }
55+
// },
56+
activeState: {
57+
get(){
58+
if (this.activeComponentObj) return this.activeComponentObj.state;
59+
return []
60+
}
6261
},
63-
propsOptions() {
64-
return this.active.props;
62+
activeProps: {
63+
get(){
64+
if (this.activeComponentObj) return this.activeComponentObj.props;
65+
return []
66+
}
6567
},
68+
activeActions: {
69+
get(){
70+
if (this.activeComponentObj) return this.activeComponentObj.actions;
71+
return []
72+
}
73+
}
74+
// componentActions: {
75+
// get() {
76+
// return this.$store.state.activeComponentObj.actions;
77+
// },
78+
// },
79+
// componentState: {
80+
// get() {
81+
// return this.$store.state.activeComponentObj.state;
82+
// },
83+
// },
84+
// componentProps: {
85+
// get() {
86+
// return this.$store.state.activeComponentObj.props;
87+
// },
88+
// },
6689
},
6790
data() {
6891
return {

src/store/mutations.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ const mutations = {
104104
}
105105
}
106106
state.selectedActions = []
107+
state.activeComponentObj = active
107108
},
108109

109110
[types.CREATE_PROP]: (state, payload) => {
@@ -129,6 +130,7 @@ const mutations = {
129130
}
130131
}
131132
state.selectedProps = []
133+
state.activeComponentObj = active
132134
},
133135

134136
[types.CREATE_STATE]: (state, payload) => {
@@ -154,6 +156,7 @@ const mutations = {
154156
}
155157
}
156158
state.selectedState = []
159+
state.activeComponentObj = active
157160
},
158161
// *** HTML ELEMENTS *** //////////////////////////////////////////////
159162

@@ -370,6 +373,9 @@ const mutations = {
370373

371374
[types.SET_ACTIVE_COMPONENT]: (state, payload) => {
372375
state.activeComponent = payload
376+
state.activeComponentObj = state.routes[state.activeRoute].filter((comp) => {
377+
return comp.componentName === state.activeComponent;
378+
})[0];
373379
state.activeHTML = ''
374380
state.activeLayer = {
375381
id: '',

src/store/state/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ const newState = {
3232
projects: [{ filename: 'Untitled-1', lastSavedLocation: '' }],
3333

3434
activeRoute: 'HomeView',
35+
// need to change to activeComponentName
3536
activeComponent: '',
37+
activeComponentObj: undefined,
3638
activeHTML: '',
3739
activeLayer: {
3840
id: '',

0 commit comments

Comments
 (0)