Skip to content

Commit 810f696

Browse files
committed
improved state and actions multiselects in component tab: now use componentmap[activecomponent] which is much more responsive than activecomponentobj that is oddly used. refactored the mutations for state, prop and action changes to use filter method instead of reassigning multiple times and creating multiple new arrays in memory.
1 parent b347cb0 commit 810f696

File tree

6 files changed

+24
-63
lines changed

6 files changed

+24
-63
lines changed

src/components/ComponentDisplay.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ export default {
248248
const val = this.routes[this.activeRoute].map(
249249
(component) => component.componentName
250250
);
251-
console.log(val)
252251
const relatives = [...val]
253252
//also need to filter out any parents
254253
@@ -481,7 +480,7 @@ export default {
481480
482481
.addChild{
483482
width: 25vh;
484-
height: 25vh;
483+
height: 50vh;
485484
display: flex;
486485
flex-direction: column;
487486
align-items: center;

src/components/dashboard_items/CodeSnippet.vue

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export default {
5858
this.code = 'Your component boilerplate will be displayed here.'
5959
}
6060
},
61+
//highlighter does not work: OverVue 6.0;
6162
highlighter(myCode) {
6263
return highlight(myCode, languages.js);
6364
},
@@ -249,13 +250,6 @@ export default {
249250
} else {
250251
output += "};\n<\/script>\n\n<style scoped>\n</style>"
251252
}
252-
// eslint-disable-next-line no-useless-escape
253-
// add props/data
254-
255-
// eslint-disable-next-line no-useless-escape
256-
// return `\n\n<script>\n${str}\nexport default {\n name: '${componentName}',\n
257-
// components: {\n${childrenComponentNames} }\n};\n<\/script>\n\n<style scoped>\n
258-
// </style>`
259253
return output;
260254
},
261255
},
@@ -278,7 +272,7 @@ export default {
278272
mounted() {
279273
// https://vuejs.org/v2/api/#Vue-nextTick
280274
// kinda like a promise, used for the window resize
281-
this.snippetInvoke()
275+
this.snippetInvoke(); //generates the code snippet whenever this is mounted
282276
this.$nextTick(() => {
283277
window.addEventListener("resize", this.getWindowHeight);
284278
@@ -300,15 +294,18 @@ export default {
300294
font-size: 12px;
301295
background: #2d2d2d;
302296
color: #ccc;
303-
max-height: 70vh;
297+
max-height: 100%;
304298
/* you must provide font-family font-size line-height. Example: */
305299
font-family: Fira code, Fira Mono, Consolas, Menlo, Courier, monospace;
306300
line-height: 1.5;
307301
padding: 5px;
308302
}
309303
310304
.codesnippet-container {
311-
margin-bottom: 1rem;
305+
padding-bottom: 1rem;
306+
padding-left: 1rem;
307+
padding-right: 1rem;
308+
height: 95%;
312309
}
313310
314311
.prism-editor__textarea:focus {

src/components/dashboard_items/ComponentDetails.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,6 @@ i {
183183
flex-direction: column;
184184
justify-content: flex-start;
185185
align-content: stretch;
186-
height: 100%;
186+
max-height: 95%;
187187
}
188188
</style>

src/components/home_sidebar_items/ComponentTab/ComponentActions.vue

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
@click="addActionToComp"
3434
/>
3535
</div>
36-
<p v-if="!this.activeComponentObj.actions.length">
36+
<p v-if="!this.componentMap[this.activeComponent].actions.length">
3737
No actions in component
3838
</p>
39-
<a v-else v-for="action in this.activeComponentData.actions" :key="action">
39+
<a v-else v-for="action in this.componentMap[this.activeComponent].actions" :key="action">
4040
<q-list class="list-item" dense bordered separator>
4141
<q-item clickable v-ripple class="list-item">
4242
<q-item-section>
@@ -69,15 +69,7 @@ export default {
6969
VueMultiselect,
7070
},
7171
computed: {
72-
...mapState(["activeComponentObj", "selectedActions", "userActions"]),
73-
activeComponentData() {
74-
return this.activeComponentObj;
75-
},
76-
compObj: {
77-
get() {
78-
return this.activeComponentObj;
79-
},
80-
},
72+
...mapState(["selectedActions", "userActions", "componentMap", "activeComponent"]),
8173
actionOptions() {
8274
return this.userActions;
8375
},

src/components/home_sidebar_items/ComponentTab/ComponentState.vue

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
@click="addStateToComp"
3535
/>
3636
</div>
37-
<p v-if="!this.activeComponentObj.state.length">No state in component</p>
38-
<a v-else v-for="state in this.activeComponentData.state" :key="state">
37+
<p v-if="!this.componentMap[this.activeComponent].state.length">No state in component</p>
38+
<a v-else v-for="state in this.componentMap[this.activeComponent].state" :key="state">
3939
<q-list class="list-item" dense bordered separator>
4040
<q-item clickable v-ripple class="list-item">
4141
<q-item-section>
@@ -65,19 +65,11 @@ import VueMultiselect from "vue-multiselect";
6565
export default {
6666
name: "ComponentState",
6767
components: {
68-
// Multiselect
6968
VueMultiselect,
7069
},
7170
computed: {
72-
...mapState(["activeComponentObj", "selectedState", "userState"]),
73-
activeComponentData() {
74-
return this.activeComponentObj;
75-
},
76-
compObj: {
77-
get() {
78-
return this.activeComponentObj;
79-
},
80-
},
71+
...mapState(["selectedState", "userState", "componentMap", "activeComponent"]),
72+
8173
stateOptions() {
8274
return this.userState;
8375
},

src/store/mutations.js

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -208,37 +208,18 @@ const mutations = {
208208
},
209209

210210
[types.DELETE_ACTION_FROM_COMPONENT]: (state, payload) => {
211-
const temp = state.componentMap[state.activeComponent];
212-
const newArray = [];
213-
temp.actions.forEach((element) => {
214-
if (element !== payload) newArray.push(element);
215-
});
216-
temp.actions = newArray;
217-
state.activeComponentObj = null;
218-
state.activeComponentObj = temp;
211+
state.componentMap[state.activeComponent].actions = state.componentMap[state.activeComponent].actions.filter(
212+
(action) => action !== payload);
219213
},
220214

221215
[types.DELETE_PROPS_FROM_COMPONENT]: (state, payload) => {
222-
const temp = state.componentMap[state.activeComponent];
223-
const newArray = [];
224-
temp.props.forEach((element) => {
225-
if (element !== payload) newArray.push(element);
226-
});
227-
temp.props = newArray;
228-
state.activeComponentObj = null;
229-
state.activeComponentObj = temp;
216+
state.componentMap[state.activeComponent].props = state.componentMap[state.activeComponent].props.filter(
217+
(prop) => prop !== payload);
230218
},
231219

232220
[types.DELETE_STATE_FROM_COMPONENT]: (state, payload) => {
233-
const temp = state.componentMap[state.activeComponent];
234-
const newArray = [];
235-
temp.state.forEach((element) => {
236-
if (element !== payload) newArray.push(element);
237-
});
238-
temp.state = newArray;
239-
state.activeComponentObj = null;
240-
state.activeComponentObj = temp;
241-
console.log(state.componentMap)
221+
state.componentMap[state.activeComponent].state = state.componentMap[state.activeComponent].state.filter(
222+
(state) => state !== payload);
242223
},
243224

244225
[types.DELETE_USER_STATE]: (state, payload) => {
@@ -248,7 +229,7 @@ const mutations = {
248229
if (component === "App" || component === "HomeView") continue;
249230
// splice out if there is a match
250231
state.componentMap[component].state = state.componentMap[component].state.filter(
251-
(action) => action !== payload)
232+
(action) => action !== payload);
252233
}
253234
// remove from userState
254235
let index = state.userState.indexOf(payload);
@@ -261,7 +242,7 @@ const mutations = {
261242
if (component === "App" || component === "HomeView") continue;
262243
// splice out if there is a match
263244
state.componentMap[component].actions = state.componentMap[component].actions.filter(
264-
(action) => action !== payload)
245+
(action) => action !== payload);
265246
}
266247
let index = state.userActions.indexOf(payload);
267248
state.userActions.splice(index, 1);

0 commit comments

Comments
 (0)