Skip to content

Commit ce32f0d

Browse files
APAP
authored andcommitted
delete routes working
1 parent b28c769 commit ce32f0d

File tree

5 files changed

+24
-8
lines changed

5 files changed

+24
-8
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: 3 additions & 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
},
@@ -61,7 +62,9 @@ export default {
6162
return result
6263
},
6364
buildTree () {
65+
console.log('this map', this.componentMap)
6466
let build = this.transformToTree(this.componentMap)
67+
console.log('build', build)
6568
return build['App']
6669
}
6770
}

src/store/mutations.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,14 @@ const mutations = {
149149
text: elementName,
150150
children: []
151151
})
152+
if (state.activeElement.length) {
153+
console.log('activeelement')
154+
state.componentMap[componentName].htmlList.push({
155+
text: elementName,
156+
children: []
157+
});
158+
} else state.componentMap[componentName].children.push(elementName);
159+
// state.activeElement.push(state.componentMap[componentName].children.length - 1, elementName);
152160
},
153161
[types.DELETE_FROM_COMPONENT_HTML_LIST]: (state, idx) => {
154162
const componentName = state.activeComponent
@@ -341,10 +349,14 @@ const mutations = {
341349
state.parentSelected = payload
342350
},
343351
[types.DELETE_ROUTE]: (state, payload) => {
344-
const stateCopy = state
345-
delete stateCopy.routes[payload]
346-
delete stateCopy.componentMap[payload]
347-
state = stateCopy
352+
// const stateCopy = state
353+
delete state.routes[payload]
354+
delete state.componentMap[payload]
355+
// state = stateCopy
356+
state.componentMap.App.children = state.componentMap.App.children.filter((route) => {
357+
return route !== payload;
358+
})
359+
if (!state.routes[state.activeRoute]) state.activeRoute = 'HomeView'
348360
},
349361
[types.DELETE_COMPONENT]: (state, payload) => {
350362
const stateCopy = state

src/store/state/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ let hardA = {
1616
}],
1717
text: "div"
1818
}],
19-
children: [],
19+
children: ["div"],
2020
parent: {},
2121
isActive: false
2222
}
@@ -56,6 +56,8 @@ const newState = {
5656
projects: [{ filename: 'Untitled-1', lastSavedLocation: '' }],
5757
activeRoute: 'HomeView',
5858
activeComponent: '',
59+
// on click, push name and index into active element
60+
activeElement: [0, 'div'],
5961
selectedElementList: [],
6062
projectNumber: 2,
6163
activeTab: 0,

0 commit comments

Comments
 (0)