10
10
class =" component-display grid-bg"
11
11
:style =" mockBg"
12
12
v-on:click =" handleClick"
13
+ v-on:click.right =" handleRight"
13
14
>
14
15
<!-- This is the actual component box -->
15
16
<!-- https://www.npmjs.com/package/vue-draggable-resizable -->
50
51
<q-menu context-menu >
51
52
<q-list color =" black" class =" menu" >
52
53
<q-item clickable v-ripple v-close-popup id =" layer-item" >
53
- <q-item-section class =" layer" >Layer</q-item-section >
54
+ <q-item-section class =" layer" >Component Layer</q-item-section >
54
55
<q-btn
55
56
class =" minorAction"
56
57
color =" transparent"
91
92
</vue-draggable-resizable >
92
93
<div >
93
94
<q-dialog v-model =" modalOpen" >
94
- <q-select
95
- @select =" handleSelect"
96
- id =" childrenDropdown"
97
- filled
98
- v-model =" testModel"
99
- multiple
100
- :options =" options"
101
- use-chips
102
- stack-label
103
- dark
104
- label =" Select children"
105
- style =" width : 250px ; background-color : #201221 ;"
106
- />
95
+ <div class =" addChild" >
96
+ <p >Add/Remove Children</p >
97
+ <VueMultiselect
98
+ v-model =" childrenSelected"
99
+ placeholder =" Add/remove children"
100
+ :multiple =" true"
101
+ :close-on-select =" false"
102
+ :options =" options"
103
+ :show-labels =" false"
104
+ @remove =" handleSelect"
105
+ @select =" handleSelect"
106
+ :height =" 300"
107
+ :option-height =" 40"
108
+ :searchable =" false"
109
+ />
110
+ </div >
107
111
</q-dialog >
108
112
109
113
<!-- some irregularity (delete event listener firing on bkspc/del) with the modal when stored locally, so modal open stored in state, and triggers to local reflect only stateful change.-->
153
157
<script >
154
158
import { mapState , mapActions } from " vuex" ;
155
159
import VueDraggableResizable from " vue-draggable-resizable/src/components/vue-draggable-resizable.vue" ;
160
+ import VueMultiselect from " vue-multiselect" ;
156
161
import " vue-draggable-resizable/src/components/vue-draggable-resizable.css" ;
157
162
import handleExportComponentMixin from " ./ExportComponentMixin.vue" ;
158
163
const { fs , ipcRenderer } = window ;
@@ -163,6 +168,7 @@ export default {
163
168
name: " ComponentDisplay" ,
164
169
components: {
165
170
VueDraggableResizable,
171
+ VueMultiselect,
166
172
},
167
173
mixins: [handleExportComponentMixin],
168
174
data () {
@@ -176,6 +182,7 @@ export default {
176
182
initialPosition: { x: 0 , y: 0 },
177
183
initialSize: { w: 0 , h: 0 },
178
184
htmlElements: [],
185
+ childrenSelected: [],
179
186
};
180
187
},
181
188
mounted () {
@@ -203,7 +210,7 @@ export default {
203
210
});
204
211
window .addEventListener (" paste" , () => {
205
212
if (this .noteModalOpen === false ){
206
- this .$store .dispatch (" pasteActiveComponent" );
213
+ this .$store .dispatch (" pasteActiveComponent" );
207
214
}
208
215
});
209
216
},
@@ -217,8 +224,8 @@ export default {
217
224
" imagePath" ,
218
225
" activeComponentObj" ,
219
226
" exportAsTypescript" ,
220
- " noteModalOpen"
221
-
227
+ " noteModalOpen" ,
228
+ " activeRouteDisplay "
222
229
]),
223
230
// used in VueDraggableResizeable component
224
231
activeRouteArray () {
@@ -231,34 +238,37 @@ export default {
231
238
return cloneDeep (this .activeComponentObj );
232
239
},
233
240
options () {
234
- // checks if component has any parents and pushes them into lineage
235
- const checkParents = (component , lineage = [component .componentName ]) => {
236
- console .log (" Lineage: " + lineage);
237
- if (! Object .keys (component .parent ).length ) return lineage;
238
- for (var parents in component .parent ) {
239
- // Mutating?
240
- lineage .push (parents);
241
- checkParents (component .parent [parents], lineage);
242
- }
243
- return lineage;
244
- };
245
- let lineage = [this .activeComponent ];
246
- // checks to see if there are any existing children
247
- if (this .componentMap [this .activeComponent ]) {
248
- // eslint-disable-next-line vue/no-side-effects-in-computed-properties
249
- this .testModel = this .componentMap [this .activeComponent ].children ;
250
- lineage = checkParents (this .componentMap [this .activeComponent ]);
241
+ if (this .activeComponent !== ' ' ){
242
+ this .childrenSelected = [];
243
+ this .childrenSelected = this .componentMap [this .activeComponent ].children ;
244
+ } else {
245
+ this .childrenSelected = [];
251
246
}
252
- const routes = Object .keys (this .routes );
253
- const exceptions = new Set ([
254
- " App" ,
255
- ... lineage,
256
- ... routes,
257
- ... this .testModel ,
258
- ]);
259
- return Object .keys (this .componentMap ).filter ((component ) => {
260
- if (! exceptions .has (component)) return component;
261
- });
247
+ const compMap = this .componentMap ;
248
+ const activeComp = this .activeComponent ;
249
+ const val = this .routes [this .activeRoute ].map (
250
+ (component ) => component .componentName
251
+ );
252
+ const relatives = [... val]
253
+ // also need to filter out any parents
254
+
255
+ let parentalLineage = [];
256
+ findLineage (relatives)
257
+ function findLineage (children ){
258
+ children .forEach ((el )=> {
259
+ parentalLineage .push (el);
260
+ if (compMap[el].children .length > 0 ){
261
+ findLineage (compMap[el].children );
262
+ }
263
+ if (el !== activeComp){
264
+ parentalLineage .pop ();
265
+ } else {
266
+ return ;
267
+ }
268
+ })
269
+ }
270
+ const optionOutput = val .filter (el => ! parentalLineage .includes (el)).filter (el => el !== this .activeComponent );
271
+ return optionOutput;
262
272
},
263
273
userImage () {
264
274
const imgSrc = ` file://` + this .imagePath [this .activeRoute ];
@@ -316,7 +326,6 @@ export default {
316
326
recordInitialPosition : function (e ) {
317
327
if (this .activeComponent !== e .target .id ) {
318
328
if (e .target .parentElement ? .classList .contains (' draggable' )){
319
- // console.log("using vanilla JS to WIN")
320
329
this .setActiveComponent (e .target .parentElement .id )
321
330
} else {
322
331
this .setActiveComponent (e .target .id );
@@ -424,7 +433,7 @@ export default {
424
433
this .deleteActiveComponentNote (e .target .previousElementSibling .innerText );
425
434
},
426
435
// used when user selects to add child from dropdown
427
- handleSelect (value ) {
436
+ handleSelect (value ) { // actually handles adding or deleting
428
437
this .updateActiveComponentChildrenValue (value);
429
438
},
430
439
// user can change component's layer order
@@ -446,7 +455,11 @@ export default {
446
455
this .setActiveComponent (" " );
447
456
}
448
457
},
449
- copyActiveComponent () {},
458
+ handleRight (event ) {
459
+ if (event .target .className === " component-display grid-bg" ) {
460
+ // right click modal to make a component?
461
+ }
462
+ },
450
463
},
451
464
watch: {
452
465
noteModalOpen (){
@@ -468,6 +481,17 @@ export default {
468
481
< / script>
469
482
470
483
< style scoped lang= " scss" >
484
+
485
+ .addChild {
486
+ width: 25vh ;
487
+ height: 50vh ;
488
+ display: flex;
489
+ flex- direction: column;
490
+ align- items: center;
491
+ background: $subsecondary;
492
+ padding: 10px ;
493
+ }
494
+
471
495
li{
472
496
display: flex;
473
497
font- weight: bold;
477
501
li: hover{
478
502
background- color: $subprimary;
479
503
}
504
+
505
+
480
506
.noteblock {
481
507
white- space: pre- wrap;
482
508
font- weight: normal;
0 commit comments