Skip to content

Commit 037d90a

Browse files
committed
merge activeLayer
2 parents 2787625 + 55d1def commit 037d90a

File tree

6 files changed

+35
-4
lines changed

6 files changed

+35
-4
lines changed

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ let redoMixin = {
6666
if (event.ctrlKey && event.key === 'a') {
6767
event.preventDefault()
6868
if (this.$store.state.activeHTML !== '') {
69-
this.$store.dispatch('addNestedHTML', { elementName: 'div', date: Date.now() })
69+
this.$store.dispatch('setActiveLayer', this.$store.state.activeHTML)
7070
}
7171
}
7272
});

src/components/Icons.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ export default {
3232
changeState (elementName) {
3333
if (this.activeComponent === '') { this.$emit('getClickedIcon', {elementName, date:Date.now()}) }
3434
else {
35-
if(this.activeHTML === ''){
35+
if(this.activeHTML === '') {
3636
this.$emit('activeElement', {elementName,date:Date.now()})
3737
}
38-
else{
38+
else {
3939
this.$emit('activeHTML', {elementName, date:Date.now()})
4040
}
4141
}

src/store/actions.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ const actions = {
88
// },
99

1010
// creates a new component in componentMap
11+
12+
[types.setActiveLayer]: ({commit}, payload) => {
13+
commit(types.SET_ACTIVE_LAYER, payload)
14+
},
15+
1116
[types.registerComponent]: ({ state, commit }, payload) => {
1217
const { componentName } = payload
1318
if (!state.componentMap[componentName]) {

src/store/mutations.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,31 @@ const breadthFirstSearchParent = (array, id) => {
4343
}
4444

4545
const mutations = {
46+
47+
[types.SET_ACTIVE_LAYER]: (state, payload) =>{
48+
let newLayer = cloneDeep(state.activeLayer)
49+
50+
//should only be reached if we change active component
51+
if (payload === '') {
52+
state.activeLayer = {
53+
id:'',
54+
lineage:[]
55+
}
56+
}
57+
else{
58+
//htmlArray = state.componentMap[state.activeComponent].htmlList
59+
if(newLayer.id === ''){
60+
newLayer.lineage.push(state.activeComponent)
61+
}
62+
else{
63+
newLayer.lineage.push(newLayer.id)
64+
}
65+
newLayer.id = payload
66+
}
67+
state.activeLayer = newLayer
68+
},
69+
70+
4671
// pushs new component to componentMap
4772
[types.ADD_COMPONENT_TO_COMPONENT_MAP]: (state, payload) => {
4873
const { componentName, htmlList, children, parent, isActive } = payload

src/store/state/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ const newState = {
6969
lineage:[]
7070
},
7171

72-
7372
selectedElementList: [],
7473
projectNumber: 2,
7574
activeTab: 0,

src/store/types.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Mutations
2+
export const SET_ACTIVE_LAYER = 'SET_ACTIVE_LAYER'
23
export const EMPTY_STATE = 'EMPTY_STATE'
34
export const ADD_NESTED_HTML = 'ADD_NESTED_HTML'
45
export const ADD_COMPONENT_TO_COMPONENT_MAP = 'ADD_COMPONENT_TO_COMPONENT_MAP'
@@ -63,6 +64,7 @@ export const DELETE_USER_STATE = 'DELETE_USER_STATE'
6364
export const SET_IMAGE_PATH = 'SET_IMAGE_PATH'
6465

6566
// Actions
67+
export const setActiveLayer = 'setActiveLayer'
6668
export const addNestedHTML = 'addNestedHTML'
6769
export const updateComponentSize = 'updateComponentSize'
6870
export const updateStartingSize = 'updateStartingSize'

0 commit comments

Comments
 (0)