50
50
<q-menu context-menu >
51
51
<q-list color =" black" class =" menu" >
52
52
<q-item clickable v-ripple v-close-popup id =" layer-item" >
53
- <q-item-section class =" layer" >Layer</q-item-section >
53
+ <q-item-section class =" layer" >Component Layer</q-item-section >
54
54
<q-btn
55
55
class =" minorAction"
56
56
color =" transparent"
91
91
</vue-draggable-resizable >
92
92
<div >
93
93
<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
- />
94
+ <div class =" addChild" >
95
+ <p >Add/Remove Children</p >
96
+ <VueMultiselect
97
+ v-model =" childrenSelected"
98
+ placeholder =" Add/remove children"
99
+ :multiple =" true"
100
+ :close-on-select =" false"
101
+ :options =" options"
102
+ :show-labels =" false"
103
+ @remove =" handleSelect"
104
+ @select =" handleSelect"
105
+ :height =" 300"
106
+ :option-height =" 40"
107
+ :searchable =" false"
108
+ />
109
+ </div >
107
110
</q-dialog >
108
111
109
112
<!-- 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
156
<script >
154
157
import { mapState , mapActions } from " vuex" ;
155
158
import VueDraggableResizable from " vue-draggable-resizable/src/components/vue-draggable-resizable.vue" ;
159
+ import VueMultiselect from " vue-multiselect" ;
156
160
import " vue-draggable-resizable/src/components/vue-draggable-resizable.css" ;
157
161
import handleExportComponentMixin from " ./ExportComponentMixin.vue" ;
158
162
const { fs , ipcRenderer } = window ;
@@ -163,6 +167,7 @@ export default {
163
167
name: " ComponentDisplay" ,
164
168
components: {
165
169
VueDraggableResizable,
170
+ VueMultiselect,
166
171
},
167
172
mixins: [handleExportComponentMixin],
168
173
data () {
@@ -176,6 +181,7 @@ export default {
176
181
initialPosition: { x: 0 , y: 0 },
177
182
initialSize: { w: 0 , h: 0 },
178
183
htmlElements: [],
184
+ childrenSelected: [],
179
185
};
180
186
},
181
187
mounted () {
@@ -203,7 +209,7 @@ export default {
203
209
});
204
210
window .addEventListener (" paste" , () => {
205
211
if (this .noteModalOpen === false ){
206
- this .$store .dispatch (" pasteActiveComponent" );
212
+ this .$store .dispatch (" pasteActiveComponent" );
207
213
}
208
214
});
209
215
},
@@ -217,8 +223,8 @@ export default {
217
223
" imagePath" ,
218
224
" activeComponentObj" ,
219
225
" exportAsTypescript" ,
220
- " noteModalOpen"
221
-
226
+ " noteModalOpen" ,
227
+ " activeRouteDisplay "
222
228
]),
223
229
// used in VueDraggableResizeable component
224
230
activeRouteArray () {
@@ -231,34 +237,38 @@ export default {
231
237
return cloneDeep (this .activeComponentObj );
232
238
},
233
239
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 ]);
240
+ if (this .activeComponent !== ' ' ){
241
+ this .childrenSelected = [];
242
+ this .childrenSelected = this .componentMap [this .activeComponent ].children ;
243
+ } else {
244
+ this .childrenSelected = [];
251
245
}
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
- });
246
+ const compMap = this .componentMap ;
247
+ const activeComp = this .activeComponent ;
248
+ const val = this .routes [this .activeRoute ].map (
249
+ (component ) => component .componentName
250
+ );
251
+ console .log (val)
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 ];
@@ -424,7 +434,7 @@ export default {
424
434
this .deleteActiveComponentNote (e .target .previousElementSibling .innerText );
425
435
},
426
436
// used when user selects to add child from dropdown
427
- handleSelect (value ) {
437
+ handleSelect (value ) { // actually handles adding or deleting
428
438
this .updateActiveComponentChildrenValue (value);
429
439
},
430
440
// user can change component's layer order
@@ -468,6 +478,17 @@ export default {
468
478
< / script>
469
479
470
480
< style scoped lang= " scss" >
481
+
482
+ .addChild {
483
+ width: 25vh ;
484
+ height: 25vh ;
485
+ display: flex;
486
+ flex- direction: column;
487
+ align- items: center;
488
+ background: $subsecondary;
489
+ padding: 10px ;
490
+ }
491
+
471
492
li{
472
493
display: flex;
473
494
font- weight: bold;
477
498
li: hover{
478
499
background- color: $subprimary;
479
500
}
501
+
502
+
480
503
.noteblock {
481
504
white- space: pre- wrap;
482
505
font- weight: normal;
0 commit comments