1
1
<template >
2
- <div class =" component-display grid-bg" :style =" mockBg" >
2
+ <div class =" component-display grid-bg" :style =" mockBg" v-on:click = " handleClick " >
3
3
<!-- <p>{{ userImage }}</p> -->
4
4
<VueDraggableResizable
5
5
class-name =" component-box"
6
6
v-for =" componentData in activeRouteArray"
7
+ ref =" boxes"
7
8
:key =" componentData.componentName"
9
+ :id =" componentData.componentName"
8
10
:x =" componentData.x"
9
11
:y =" componentData.y + 20"
12
+ :z =" componentData.z"
10
13
:w =" componentData.w"
11
14
:h =" componentData.h"
12
15
:parent =" true"
16
+ :preventDeactivation =" true"
13
17
@activated =" onActivated(componentData)"
14
18
@deactivated =" onDeactivated(componentData)"
15
19
@dragging =" onDrag"
25
29
<!-- <p v-for="child in childList" :key="childList.indexOf(child)"> {{ child.text }}</p> -->
26
30
</ul >
27
31
<q-menu context-menu >
28
- <q-list class =" menu" >
32
+ <q-list color = ' black ' class =" menu" >
29
33
<q-item clickable v-ripple v-close-popup @click =" handleAddChild" >
30
34
<q-item-section style =" color : white " >Update Children</q-item-section >
31
35
<q-item-section avatar >
32
36
<q-icon color =" primary" name =" add" />
33
37
</q-item-section >
34
38
</q-item >
35
- <!-- <q-item clickable v-ripple v-close-popup auto-close>
36
- <q-item-section style="color: pink">Delete Children</q-item-section>
37
- <q-item-section avatar>
38
- <q-icon color="primary" name="delete" />
39
- </q-item-section>
40
- </q-item> -->
39
+ <q-item clickable v-ripple v-close-popup >
40
+ <q-item-section class =' layer' style =" color : pink " >Layer</q-item-section >
41
+ <q-btn class =' btn' color =' transparent' text-color =' primary' label =' -' @click =' (e)=>handleLayer(e)' />
42
+ <p id =' counter' style =" color : white " > {{componentData.z}} </p >
43
+ <q-btn class =' btn' color =' transparent' text-color =' primary' label =' +' @click =' (e)=>handleLayer(e)' />
44
+ <!-- <q-item-section avatar>
45
+ <q-icon color="primary" name="layer" />
46
+ </q-item-section> -->
47
+ </q-item >
41
48
</q-list >
42
49
</q-menu >
43
50
</VueDraggableResizable >
@@ -64,7 +71,7 @@ import { mapState, mapActions } from "vuex";
64
71
import VueDraggableResizable from " vue-draggable-resizable" ;
65
72
// import ChildrenMultiselect from '../components/ChildrenMultiselect'
66
73
import " vue-draggable-resizable/dist/VueDraggableResizable.css" ;
67
-
74
+ // :preventDeactivation="true"
68
75
export default {
69
76
name: " ComponentDisplay" ,
70
77
components: {
@@ -77,7 +84,8 @@ export default {
77
84
abilityToDelete: false ,
78
85
testOptions: [" parent" , " child" , " grandchild" ],
79
86
testModel: [],
80
- mockImg: false
87
+ mockImg: false ,
88
+ counter: 0
81
89
};
82
90
},
83
91
mounted () {
@@ -86,7 +94,7 @@ export default {
86
94
window .addEventListener (" keyup" , event => {
87
95
if (event .key === " Backspace" ) {
88
96
if (this .activeComponent && this .activeComponentData .isActive ) {
89
- console .log (' this:' , this )
97
+ // console.log('this:', this)
90
98
this .$store .dispatch (" deleteActiveComponent" );
91
99
}
92
100
}
@@ -116,16 +124,37 @@ export default {
116
124
return this .componentMap [componentData .componentName ].children ;
117
125
},
118
126
options () {
127
+ const checkParents = (component , lineage = [component .componentName ]) => {
128
+ // console.log('component', component)
129
+ // component parent is an object of parents
130
+ // console.log('component parent',component.parent)
131
+ // console.log('component parent parent', component.parent.parent)
132
+ if (! Object .keys (component .parent ).length ) return lineage;
133
+ for (var parents in component .parent ){
134
+ // for each parent in our component
135
+ console .log (' parents' , parents)
136
+ lineage .push (parents); // push the parent into lineage
137
+ console .log (' lineage pre push' , component, lineage)
138
+ checkParents (component .parent [parents], lineage);
139
+ console .log (' lineage post recursive call' , lineage)
140
+ }
141
+ // lineage.push(component.parent[component.componentName]);
142
+ // return checkParents(component.parent, lineage);
143
+ return lineage
144
+ };
145
+ let lineage = [this .activeComponent ];
119
146
// PROBLEM: the objects on childrenmultiselectvalue are applied
120
147
// check to see if there are any existing children
121
148
if (this .componentMap [this .activeComponent ]) {
122
149
// console.log('active component', this.activeComponent)
123
150
// console.log('testmodel', this.testModel)
124
151
// console.log(this.componentMap[this.activeComponent].children)
125
152
this .testModel = this .componentMap [this .activeComponent ].children ;
153
+ lineage = checkParents (this .componentMap [this .activeComponent ]);
154
+ console .log (' Lineage' , lineage);
126
155
}
127
156
const routes = Object .keys (this .routes );
128
- const exceptions = new Set ([" App" , this . activeComponent , ... routes, ... this .testModel ]);
157
+ const exceptions = new Set ([" App" , ... lineage , ... routes, ... this .testModel ]);
129
158
return Object .keys (this .componentMap ).filter (component => {
130
159
if (! exceptions .has (component)) return component;
131
160
});
@@ -145,6 +174,30 @@ export default {
145
174
: {};
146
175
}
147
176
},
177
+
178
+ updated () {
179
+ console .log (" updated" )
180
+ if (this .activeComponent === ' ' )
181
+ {
182
+ this .$refs .boxes .forEach ((element )=> {
183
+ element .enabled = false ;
184
+ element .$emit (' deactivated' )
185
+ element .$emit (' update:active' , false )
186
+
187
+ })
188
+ }
189
+ else {
190
+ this .$refs .boxes .forEach ((element )=> {
191
+ if (this .activeComponent === element .$attrs .id )
192
+ {
193
+ element .enabled = true
194
+ element .$emit (' activated' )
195
+ element .$emit (' update:active' , true )
196
+ }
197
+ })
198
+ }
199
+ },
200
+
148
201
methods: {
149
202
... mapActions ([
150
203
" setActiveComponent" ,
@@ -170,12 +223,34 @@ export default {
170
223
this .componentMap [this .activeComponent ].y = y;
171
224
this .userImage ;
172
225
},
226
+ onLayer : function (z ) {
227
+ this .activeComponentData .z = z;
228
+ },
173
229
onActivated (componentData ) {
230
+ this .$refs .boxes .forEach ((element )=> {
231
+ if (element .$attrs .id !== componentData .componentName ){
232
+ element .enabled = false ;
233
+ element .$emit (' deactivated' )
234
+ element .$emit (' update:active' , false )
235
+ }
236
+ })
174
237
this .setActiveComponent (componentData .componentName );
175
238
this .activeComponentData .isActive = true ;
239
+
176
240
},
177
- onDeactivated () {
241
+
242
+ // deactivated is emitted before activated
243
+
244
+ onDeactivated (componentData ) {
245
+ if (this .activeComponent !== ' ' ){
178
246
this .activeComponentData .isActive = false ;
247
+ }
248
+ // console.log("Componentdataname", componentData.componentName)
249
+ // console.log("active component",this.activeComponent)
250
+ // if(componentData.componentName === this.activeComponent)
251
+ // {
252
+ // console.log("We just clicked without making a new active component")
253
+ // }
179
254
},
180
255
onDoubleClick (compData ) {
181
256
this .setActiveComponent (compData .componentName );
@@ -190,12 +265,35 @@ export default {
190
265
console .log (" Multiselect: " , value);
191
266
this .updateActiveComponentChildrenValue (value);
192
267
// this.updateComponentChildrenMultiselectValue(value)
193
- }
268
+ },
269
+ handleLayer (e ){
270
+ e .preventDefault ()
271
+ console .log (' event object' , e .target .innerText )
272
+ console .log (' Layer handled' )
273
+
274
+ if (e .target .innerText === ' +' ){
275
+ this .counter ++ ;
276
+ // this.activeComponentData.z = z;
277
+ }
278
+ if (e .target .innerText === ' -' && this .counter > 0 ){
279
+ this .counter -- ;
280
+ }
281
+ console .log (' counter' , this .counter )
282
+ this .activeComponentData .z = this .counter ;
283
+ this .componentMap [this .activeComponent ].z = this .counter ;
284
+
285
+ },
194
286
// @dblclick.native="onDoubleClick(componentData)"
195
287
// onDoubleClick (compData) {
196
288
// this.setActiveComponent(compData.componentName)
197
289
// this.activeComponentData.isActive = true
198
290
// }
291
+ handleClick (event ){
292
+ if (event .target .className === " component-display grid-bg" )
293
+ {
294
+ this .setActiveComponent (' ' )
295
+ }
296
+ }
199
297
}
200
298
};
201
299
</script >
@@ -212,6 +310,7 @@ export default {
212
310
/* width: 1rem; */
213
311
line-height : 1.2 ;
214
312
/* margin: 10px; */
313
+ z-index : 0 ;
215
314
}
216
315
.component-children {
217
316
position : absolute ;
@@ -272,4 +371,23 @@ export default {
272
371
background-color : rgba (105 , 179 , 190 , 0.514 );
273
372
border : 1px dashed rgb (227 , 203 , 71 );
274
373
}
374
+ .btn {
375
+ font-size : 25px ;
376
+ /* margin-top: 0;
377
+ margin-bottom: 0; */
378
+ padding : 0 20px ;
379
+ width : 10px ;
380
+ height : 10px ;
381
+ transition : none ;
382
+ }
383
+ .btn :hover , .btn :focus , .btn :active {
384
+ color : white ;
385
+ background-color : transparent ;
386
+ }
387
+ #counter {
388
+ margin-top : 20px ;
389
+ }
390
+ /* .layer {
391
+ padding: 0 20px;
392
+ } */
275
393
</style >
0 commit comments