Skip to content

Commit 3884470

Browse files
APAP
authored andcommitted
Merge branch 'routeDeletion' into routeDeletion3
2 parents 14f5c04 + 6020c0d commit 3884470

File tree

5 files changed

+33
-14
lines changed

5 files changed

+33
-14
lines changed

src/components/ComponentDisplay.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ export default {
9191
testOptions: ["parent", "child", "grandchild"],
9292
testModel: [],
9393
mockImg: false,
94-
// counter: 6,
9594
initialPosition:{x:0, y:0,},
9695
initialSize:{w:0,h:0,},
9796
};

src/components/Routes.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ export default {
3333
this.setActiveRoute(route)
3434
},
3535
deleteSelectedRoute (route) {
36-
this.setActiveRoute(route)
36+
// this.setActiveRoute(route)
3737
this.deleteRoute(route)
38-
this.setActiveRoute('')
38+
// this.setActiveRoute('')
3939
}
4040
}
4141
}

src/components/Tree.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default {
2222
computed: {
2323
...mapState(['componentMap']),
2424
computedTree () {
25+
console.log('buildtree', this.buildTree())
2526
return this.buildTree()
2627
}
2728
},

src/store/mutations.js

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ const mutations = {
122122
id: payload.date,
123123
children: []
124124
})
125+
if (state.activeElement.length) {
126+
console.log('activeelement')
127+
state.componentMap[componentName].htmlList.push({
128+
text: elementName,
129+
children: []
130+
});
131+
} else state.componentMap[componentName].children.push(elementName);
132+
// state.activeElement.push(state.componentMap[componentName].children.length - 1, elementName);
125133
},
126134

127135
[types.ADD_NESTED_HTML]: (state, payload) => {
@@ -379,10 +387,25 @@ const mutations = {
379387
state.parentSelected = payload
380388
},
381389
[types.DELETE_ROUTE]: (state, payload) => {
382-
const stateCopy = state
383-
delete stateCopy.routes[payload]
384-
delete stateCopy.componentMap[payload]
385-
state = stateCopy
390+
const deleteChildren = (child) => {
391+
if (state.componentMap[child.componentName].children.length) {
392+
child.children.forEach((grandchild) => {
393+
deleteChildren(grandchild)
394+
})
395+
}
396+
delete state.componentMap[child.componentName]
397+
}
398+
state.routes[payload].forEach((child => {
399+
deleteChildren(child)
400+
}))
401+
402+
delete state.routes[payload]
403+
delete state.componentMap[payload]
404+
405+
state.componentMap.App.children = state.componentMap.App.children.filter((route) => {
406+
return route !== payload;
407+
})
408+
if (!state.routes[state.activeRoute]) state.activeRoute = 'HomeView'
386409
},
387410
[types.DELETE_COMPONENT]: (state, payload) => {
388411
const stateCopy = state

src/store/state/index.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ let hardA = {
2222
text: "div",
2323
id:1
2424
}],
25-
children: [],
25+
children: ["div"],
2626
parent: {},
2727
isActive: false
2828
}
@@ -63,12 +63,8 @@ const newState = {
6363

6464
activeRoute: 'HomeView',
6565
activeComponent: '',
66-
activeHTML: '',
67-
activeLayer: {
68-
id:'',
69-
lineage:[]
70-
},
71-
66+
// on click, push name and index into active element
67+
activeElement: [0, 'div'],
7268
selectedElementList: [],
7369
projectNumber: 2,
7470
activeTab: 0,

0 commit comments

Comments
 (0)