Skip to content

Commit ec7d853

Browse files
committed
component added to htmlList on component creation and update children
1 parent 8fb2a91 commit ec7d853

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

src/components/CodeSnippet.vue

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ export default {
5353
createTemplate(componentName, children) {
5454
let output = ``;
5555
output += ` <div>\n`;
56-
children.forEach(name => {
57-
output += ` <${name}>\n </${name}>\n`;
58-
});
56+
// children.forEach(name => {
57+
// output += ` <${name}>\n </${name}>\n`;
58+
// });
5959
let templateTagStr = this.writeTemplateTag(componentName);
6060
return `<template>\n ${output}${templateTagStr} </div>\n</template>`;
6161
},
@@ -83,8 +83,12 @@ export default {
8383
let outputStr = ``;
8484
for (let el of htmlArr) {
8585
outputStr += ` `;
86-
outputStr += htmlElementMap[el.text][0];
87-
outputStr += htmlElementMap[el.text][1];
86+
if (el.text) {
87+
outputStr += htmlElementMap[el.text][0];
88+
outputStr += htmlElementMap[el.text][1];
89+
} else {
90+
outputStr += `<${el} />`
91+
}
8892
outputStr += ` \n`;
8993
}
9094
// console.log(`outputStr from writeTemplateTag: ${outputStr}`)

src/components/ComponentDisplay.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ export default {
138138
// console.log('component parent',component.parent)
139139
// console.log('component parent parent', component.parent.parent)
140140
if (!Object.keys(component.parent).length) return lineage;
141-
for(var parents in component.parent) {
142-
//for each parent in our component
141+
for (var parents in component.parent) {
142+
// for each parent in our component
143143
console.log('parents', parents)
144-
lineage.push(parents); //push the parent into lineage
144+
lineage.push(parents); // push the parent into lineage
145145
console.log('lineage pre push', component, lineage)
146146
checkParents(component.parent[parents], lineage);
147147
console.log('lineage post recursive call', lineage)
@@ -187,7 +187,7 @@ export default {
187187
//console.log("updated")
188188
if(this.activeComponent === '')
189189
{
190-
if(this.$refs.boxes){
190+
if(this.$refs.boxes) {
191191
this.$refs.boxes.forEach((element)=> {
192192
element.enabled = false;
193193
element.$emit('deactivated')
@@ -406,7 +406,7 @@ export default {
406406
z-index: -1;
407407
}
408408
.component-children {
409-
position: absolute;
409+
position: relative;
410410
top: 0rem;
411411
left: 2px;
412412
color: black;

src/components/HomeQueue.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default {
4444
renderList: {
4545
get () {
4646
if (this.activeComponent === '') return this.selectedElementList
47-
return this.componentMap[this.activeComponent].htmlList
47+
return this.componentMap[this.activeComponent].htmlList.filter(el => el.text)
4848
},
4949
set (value) {
5050
this.$store.dispatch(setSelectedElementList, value)

src/store/mutations.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ const mutations = {
129129
[types.ADD_PARENT]: (state, payload) => {
130130
state.componentMap[payload.componentName].parent[state.parentSelected] = state.componentMap[state.parentSelected]
131131
state.componentMap[state.parentSelected].children.push(payload.componentName)
132+
state.componentMap[state.parentSelected].htmlList.push(payload.componentName)
132133
},
133-
134134
// adds a html tag from the Icons.vue to the HomeQueue.vue
135135
// event: getClickedIcon @Icons.vue
136136
[types.ADD_TO_SELECTED_ELEMENT_LIST]: (state, payload) => {
@@ -323,6 +323,13 @@ const mutations = {
323323
].children.filter(el => !payload.includes(el))
324324
state.componentMap[child[0]].parent[state.activeComponent] = state.componentMap[state.activeComponent]
325325
}
326+
const copy = [...state.componentMap[state.activeComponent].htmlList]
327+
for (var x in payload) {
328+
if (!copy.includes(payload[x])) {
329+
copy.push(payload[x])
330+
}
331+
}
332+
state.componentMap[state.activeComponent].htmlList = copy
326333
},
327334
// allows usr to change the name of component!!
328335
[types.UPDATE_COMPONENT_NAME_INPUT_VALUE]: (state, payload) => {

0 commit comments

Comments
 (0)