File tree Expand file tree Collapse file tree 6 files changed +23
-3
lines changed Expand file tree Collapse file tree 6 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -137,5 +137,4 @@ export default {
137137.input-container {
138138 margin-top : 1rem ;
139139 }
140-
141140 </style >
Original file line number Diff line number Diff line change @@ -36,12 +36,13 @@ export default {
3636 }
3737 },
3838 methods: {
39- ... mapActions ([' addRouteToRouteMap' ]),
39+ ... mapActions ([' addRouteToRouteMap' , ' setRoutes ' ]),
4040 handleEnterKeyPress () {
4141 this .addRouteToRouteMap (this .newRoute )
4242 .then (() => {
4343 this .newRoute = ' '
4444 })
45+
4546 .catch (err => console .log (err))
4647 }
4748 }
Original file line number Diff line number Diff line change 66 v-for =" route in Object.keys(routes)"
77 :key =" route"
88 @click =" handleClick(route)"
9+ v-on:keyup.delete =" deleteSelectedRoute(route)"
910 >
1011<!--
1112 <span class="panel-icon">
@@ -34,9 +35,13 @@ export default {
3435 ... mapState ([' routes' , ' activeRoute' ])
3536 },
3637 methods: {
37- ... mapActions ([' setActiveRoute' ]),
38+ ... mapActions ([' setActiveRoute' , ' deleteRoute ' ]),
3839 handleClick (route ) {
3940 this .setActiveRoute (route)
41+ },
42+ deleteSelectedRoute (route ) {
43+ this .deleteRoute (route)
44+ this .setActiveRoute (' ' )
4045 }
4146 }
4247}
Original file line number Diff line number Diff line change @@ -112,6 +112,10 @@ const actions = {
112112 } ,
113113 [ types . parentSelected ] : ( { commit } , payload ) => {
114114 commit ( types . PARENT_SELECTED , payload )
115+ } ,
116+ [ types . deleteRoute ] : ( { state, commit } , payload ) => {
117+ console . log ( 'stat in actions:' , state )
118+ commit ( types . DELETE_ROUTE , payload )
115119 }
116120}
117121
Original file line number Diff line number Diff line change @@ -103,6 +103,7 @@ const mutations = {
103103 ...state . routes ,
104104 [ payload ] : [ ]
105105 }
106+ console . log ( 'payload in add_route' , payload )
106107 } ,
107108 // Changes the component map
108109 [ types . ADD_ROUTE_TO_COMPONENT_MAP ] : ( state , payload ) => {
@@ -128,6 +129,7 @@ const mutations = {
128129 state . activeComponent = payload
129130 } ,
130131 [ types . SET_ROUTES ] : ( state , payload ) => {
132+ console . log ( 'setroutespayload:' , payload )
131133 state . routes = Object . assign ( { } , payload )
132134 } ,
133135 // invoked when a component is deleted
@@ -179,6 +181,13 @@ const mutations = {
179181 } ,
180182 [ types . PARENT_SELECTED ] : ( state , payload ) => {
181183 state . parentSelected = payload
184+ } ,
185+ [ types . DELETE_ROUTE ] : ( state , payload ) => {
186+ const stateCopy = state
187+ delete stateCopy . routes [ payload ]
188+ delete stateCopy . componentMap [ payload ]
189+ state = stateCopy
190+ console . log ( 'aftermutations state' , state )
182191 }
183192}
184193
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ export const ADD_COMPONENT_TO_COMPONENT_CHILDREN =
3939 'ADD_COMPONENT_TO_COMPONENT_CHILDREN'
4040export const UPDATE_OPEN_MODAL = 'UPDATE_OPEN_MODAL'
4141export const PARENT_SELECTED = 'PARENT_SELECTED'
42+ export const DELETE_ROUTE = 'DELETE_ROUTE'
4243
4344// Actions
4445export const registerComponent = 'registerComponent'
@@ -71,3 +72,4 @@ export const updateComponentChildrenValue = 'updateComponentChildrenValue'
7172export const updateComponentNameInputValue = 'updateComponentNameInputValue'
7273export const updateOpenModal = 'updateOpenModal'
7374export const parentSelected = 'parentSelected'
75+ export const deleteRoute = 'deleteRoute'
You can’t perform that action at this time.
0 commit comments