5050 <q-menu context-menu >
5151 <q-list color =" black" class =" menu" >
5252 <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 >
5454 <q-btn
5555 class =" minorAction"
5656 color =" transparent"
9191 </vue-draggable-resizable >
9292 <div >
9393 <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 >
107110 </q-dialog >
108111
109112 <!-- 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.-->
153156<script >
154157import { mapState , mapActions } from " vuex" ;
155158import VueDraggableResizable from " vue-draggable-resizable/src/components/vue-draggable-resizable.vue" ;
159+ import VueMultiselect from " vue-multiselect" ;
156160import " vue-draggable-resizable/src/components/vue-draggable-resizable.css" ;
157161import handleExportComponentMixin from " ./ExportComponentMixin.vue" ;
158162const { fs , ipcRenderer } = window ;
@@ -163,6 +167,7 @@ export default {
163167 name: " ComponentDisplay" ,
164168 components: {
165169 VueDraggableResizable,
170+ VueMultiselect,
166171 },
167172 mixins: [handleExportComponentMixin],
168173 data () {
@@ -176,6 +181,7 @@ export default {
176181 initialPosition: { x: 0 , y: 0 },
177182 initialSize: { w: 0 , h: 0 },
178183 htmlElements: [],
184+ childrenSelected: [],
179185 };
180186 },
181187 mounted () {
@@ -203,7 +209,7 @@ export default {
203209 });
204210 window .addEventListener (" paste" , () => {
205211 if (this .noteModalOpen === false ){
206- this .$store .dispatch (" pasteActiveComponent" );
212+ this .$store .dispatch (" pasteActiveComponent" );
207213 }
208214 });
209215 },
@@ -217,8 +223,8 @@ export default {
217223 " imagePath" ,
218224 " activeComponentObj" ,
219225 " exportAsTypescript" ,
220- " noteModalOpen"
221-
226+ " noteModalOpen" ,
227+ " activeRouteDisplay "
222228 ]),
223229 // used in VueDraggableResizeable component
224230 activeRouteArray () {
@@ -231,34 +237,38 @@ export default {
231237 return cloneDeep (this .activeComponentObj );
232238 },
233239 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 = [];
251245 }
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;
262272 },
263273 userImage () {
264274 const imgSrc = ` file://` + this .imagePath [this .activeRoute ];
@@ -424,7 +434,7 @@ export default {
424434 this .deleteActiveComponentNote (e .target .previousElementSibling .innerText );
425435 },
426436 // used when user selects to add child from dropdown
427- handleSelect (value ) {
437+ handleSelect (value ) { // actually handles adding or deleting
428438 this .updateActiveComponentChildrenValue (value);
429439 },
430440 // user can change component's layer order
@@ -468,6 +478,17 @@ export default {
468478< / script>
469479
470480< 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+
471492li{
472493 display: flex;
473494 font- weight: bold;
477498li: hover{
478499 background- color: $subprimary;
479500}
501+
502+
480503.noteblock {
481504 white- space: pre- wrap;
482505 font- weight: normal;
0 commit comments