Skip to content

Commit 81830ad

Browse files
committed
pulled
2 parents 54cb350 + bec4898 commit 81830ad

File tree

4 files changed

+38
-38
lines changed

4 files changed

+38
-38
lines changed

src/components/ComponentDisplay.vue

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export default {
9191
testOptions: ["parent", "child", "grandchild"],
9292
testModel: [],
9393
mockImg: false,
94-
counter: 0,
94+
// counter: 6,
9595
initialPosition:{x:0, y:0,},
9696
initialSize:{w:0,h:0,},
9797
};
@@ -119,7 +119,7 @@ export default {
119119
]),
120120
// used in VueDraggableResizeable component
121121
activeRouteArray() {
122-
// console.log("active route array method", this.routes[this.activeRoute]);
122+
console.log("active route array method", this.routes[this.activeRoute]);
123123
return this.routes[this.activeRoute];
124124
},
125125
// used to delete components
@@ -185,16 +185,16 @@ export default {
185185
},
186186
updated() {
187187
//console.log("updated")
188-
if (this.activeComponent === '') {
189-
if (this.$refs.boxes) {
190-
this.$refs.boxes.forEach((element) => {
188+
if(this.activeComponent === '')
189+
{
190+
if(this.$refs.boxes){
191+
this.$refs.boxes.forEach((element)=> {
191192
element.enabled = false;
192193
element.$emit('deactivated')
193194
element.$emit('update:active', false)
194-
})
195-
}
196-
}
197-
else {
195+
196+
})}
197+
} else {
198198
this.$refs.boxes.forEach((element)=>{
199199
// added "element.enabled === false to stop it from emitting a change every frame the box moves
200200
// may need to re-enable to track box movement and resizing since that stuff isn't part of a single source of truth.
@@ -214,6 +214,7 @@ export default {
214214
"updateActiveComponentChildrenValue",
215215
"updateComponentPosition",
216216
"updateStartingPosition",
217+
"updateComponentLayer",
217218
"updateStartingSize",
218219
"updateComponentSize",
219220
]),
@@ -300,11 +301,6 @@ export default {
300301
this.componentMap[this.activeComponent].y = y;
301302
this.userImage;
302303
},
303-
// onLayer: function(z) {
304-
// this.activeComponentData.z = z;
305-
// // Want to change the "Z" of the component found in Routes[activeRoute][whatever the component is]
306-
// //have to do this via an action or it won't be preserved in our undo/redo
307-
// },
308304
309305
finishedDrag: function(x,y) {
310306
console.log("FINISHED DRAGGING")
@@ -322,11 +318,11 @@ export default {
322318
}
323319
},
324320
325-
onActivated (componentData) {
321+
onActivated(componentData) {
326322
//console.log("I RAN!")
327-
this.$refs.boxes.forEach((element) => {
328-
if (element.$attrs.id !== componentData.componentName) {
329-
element.enabled = false;
323+
this.$refs.boxes.forEach((element)=> {
324+
if (element.$attrs.id !== componentData.componentName){
325+
element.enabled = false;
330326
element.$emit('deactivated')
331327
element.$emit('update:active', false)
332328
}
@@ -371,31 +367,24 @@ export default {
371367
},
372368
handleLayer(e) {
373369
e.preventDefault()
374-
console.log('event object', e.target.innerText)
375-
console.log('Layer handled')
376-
377-
if(e.target.innerText === '+') {
378-
this.counter++;
379-
// this.activeComponentData.z = z;
380-
}
381-
if(e.target.innerText === '-' && this.counter > 0) {
382-
this.counter--;
370+
const payload = {
371+
activeComponent: this.activeComponent,
372+
routeArray: this.routes[this.activeRoute],
373+
activeComponentData: this.activeComponentData,
374+
z: this.activeComponentData.z,
383375
}
384-
console.log('counter', this.counter)
385-
this.activeComponentData.z = this.counter;
386-
this.componentMap[this.activeComponent].z = this.counter;
387-
376+
if(e.target.innerText === '+') payload.z++;
377+
if(e.target.innerText === '-' && payload.z > 0) payload.z--;
378+
this.updateComponentLayer(payload)
388379
},
389380
// @dblclick.native="onDoubleClick(componentData)"
390381
// onDoubleClick (compData) {
391382
// this.setActiveComponent(compData.componentName)
392383
// this.activeComponentData.isActive = true
393384
// }
394-
handleClick (event) {
395-
if (event.target.className === "component-display grid-bg") {
396-
if (!('' === this.activeComponent)) {
397-
this.setActiveComponent('');
398-
}
385+
handleClick(event){
386+
if(event.target.className === "component-display grid-bg") {
387+
if(!('' === this.activeComponent)) this.setActiveComponent('');
399388
}
400389
}
401390
}

src/store/actions.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ const actions = {
6363
commit(types.UPDATE_COMPONENT_POSITION, payload)
6464

6565
},
66+
[types.updateComponentLayer]: ({ commit }, payload) => {
67+
commit(types.UPDATE_COMPONENT_LAYER, payload)
68+
},
6669

6770
//does the same as update component position, but needed to record the initial spot of the draggable resizeable in component display
6871
// or else undo/redo won't work

src/store/mutations.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,14 @@ const mutations = {
297297
updatedComponent.x = payload.x
298298
updatedComponent.y = payload.y
299299
},
300-
301-
300+
[types.UPDATE_COMPONENT_LAYER]: (state, payload) => {
301+
const updatedComponent = state.routes[state.activeRoute].filter(element => {
302+
return element.componentName === payload.activeComponent
303+
})[0]
304+
updatedComponent.z = payload.z
305+
state.componentMap[payload.activeComponent].z = payload.z
306+
// payload.activeComponentData.z = payload.z
307+
},
302308
[types.UPDATE_ACTIVE_COMPONENT_CHILDREN_VALUE]: (state, payload) => {
303309
// original line
304310
let temp = state.componentMap[state.activeComponent].children // b c and we are removing c

src/store/types.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const UPDATE_COMPONENT_NAME_INPUT_VALUE =
3535
export const UPDATE_COMPONENT_CHILDREN_VALUE =
3636
'UPDATE_COMPONENT_CHILDREN_VALUE'
3737
export const UPDATE_COMPONENT_POSITION = "UPDATE_COMPONENT_POSITION"
38+
export const UPDATE_COMPONENT_LAYER = "UPDATE_COMPONENT_LAYER"
3839
export const UPDATE_ACTIVE_COMPONENT_CHILDREN_VALUE =
3940
'UPDATE_ACTIVE_COMPONENT_CHILDREN_VALUE'
4041
export const ADD_COMPONENT_TO_COMPONENT_CHILDREN =
@@ -92,6 +93,7 @@ export const updateActiveComponentChildrenValue =
9293
export const updateComponentChildrenValue = 'updateComponentChildrenValue'
9394
export const updateComponentNameInputValue = 'updateComponentNameInputValue'
9495
export const updateComponentPosition = 'updateComponentPosition'
96+
export const updateComponentLayer = 'updateComponentLayer'
9597
export const updateOpenModal = 'updateOpenModal'
9698
export const parentSelected = 'parentSelected'
9799
export const deleteRoute = 'deleteRoute'

0 commit comments

Comments
 (0)