Skip to content

Commit 6020c0d

Browse files
APAP
authored andcommitted
routes and their children can now be deleted
1 parent 1520678 commit 6020c0d

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

src/components/Tree.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ export default {
6262
return result
6363
},
6464
buildTree () {
65-
console.log('this map', this.componentMap)
6665
let build = this.transformToTree(this.componentMap)
67-
console.log('build', build)
6866
return build['App']
6967
}
7068
}

src/store/mutations.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -361,20 +361,21 @@ const mutations = {
361361
state.parentSelected = payload
362362
},
363363
[types.DELETE_ROUTE]: (state, payload) => {
364-
// const deleteChildren = (children) => {
365-
// console.log('children', children.children)
366-
// children.children.forEach((child) => {
367-
// if (!state.componentMap[child].children.length) delete state.componentMap[child];
368-
// else deleteChildren(child);
369-
// });
370-
// }
371-
372-
// deleteChildren(state.routes[payload])
364+
const deleteChildren = (child) => {
365+
if (state.componentMap[child.componentName].children.length) {
366+
child.children.forEach((grandchild) => {
367+
deleteChildren(grandchild)
368+
})
369+
}
370+
delete state.componentMap[child.componentName]
371+
}
372+
state.routes[payload].forEach((child => {
373+
deleteChildren(child)
374+
}))
373375

374-
// const stateCopy = state
375376
delete state.routes[payload]
376377
delete state.componentMap[payload]
377-
// state = stateCopy
378+
378379
state.componentMap.App.children = state.componentMap.App.children.filter((route) => {
379380
return route !== payload;
380381
})

0 commit comments

Comments
 (0)