Skip to content

Commit 037b2f0

Browse files
committed
changing to vbinding
1 parent a860975 commit 037b2f0

File tree

1 file changed

+37
-7
lines changed

1 file changed

+37
-7
lines changed

src/store/mutations.js

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,27 @@ const mutations = {
209209
// //add binding
210210
[types.addBindingText]: (state, payload) => {
211211
//access the htmlList, add payload to the empty bind obj
212-
//state.component
213-
console.log(state.componentMap[state.activeComponent])
212+
//const active = state.componentMap[state.activeComponent].htmlList;
213+
if (payload === "") {
214+
state.componentMap = {
215+
...state.componentMap
216+
}
217+
} else {
218+
const id = payload.id
219+
state.componentMap[state.activeComponentObj].htmlList.forEach((el) => {
220+
221+
if (el.children.length !== 0) {
222+
el.children.forEach((element) => {
223+
if (payload.id === element.id) {
224+
element.binding = payload.binding
225+
}
226+
})
227+
}
228+
if (payload.id === el.id) {
229+
el.binding = payload.binding
230+
}
231+
})
232+
}
214233
},
215234
[types.DELETE_ACTION_FROM_COMPONENT]: (state, payload) => {
216235
state.componentMap[state.activeComponent].actions = state.componentMap[state.activeComponent].actions.filter(
@@ -807,12 +826,23 @@ const mutations = {
807826
},
808827

809828
[types.ADD_ACTIVE_COMPONENT_CLASS]: (state, payload) => {
810-
state.componentMap[state.activeComponent].htmlList.forEach((el) => {
811-
if (payload.id === el.id) {
812-
el.class = payload.class
813-
}
814-
})
829+
if (state.activeComponentObj.htmlList)
830+
state.componentMap[state.activeComponent].htmlList.forEach((el) => {
831+
//adding class into it's child 1st layer
832+
if (el.children.length !== 0) {
833+
el.children.forEach((element) => {
834+
if (payload.id === element.id) {
835+
element.class = payload.class
836+
}
837+
})
838+
}
839+
if (payload.id === el.id) {
840+
el.class = payload.class
841+
}
842+
})
815843
},
844+
845+
816846
[types.DELETE_ACTIVE_COMPONENT_CLASS]: (state, payload) => {
817847
state.componentMap[state.activeComponent].classList.forEach((el, ind) => {
818848
if (payload === el) {

0 commit comments

Comments
 (0)