1010 class =" component-display grid-bg"
1111 :style =" mockBg"
1212 v-on:click =" handleClick"
13+ v-on:click.right =" handleRight"
1314 >
1415 <!-- This is the actual component box -->
1516 <!-- https://www.npmjs.com/package/vue-draggable-resizable -->
5051 <q-menu context-menu >
5152 <q-list color =" black" class =" menu" >
5253 <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 >
5455 <q-btn
5556 class =" minorAction"
5657 color =" transparent"
9192 </vue-draggable-resizable >
9293 <div >
9394 <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 >
107111 </q-dialog >
108112
109113 <!-- 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.-->
153157<script >
154158import { mapState , mapActions } from " vuex" ;
155159import VueDraggableResizable from " vue-draggable-resizable/src/components/vue-draggable-resizable.vue" ;
160+ import VueMultiselect from " vue-multiselect" ;
156161import " vue-draggable-resizable/src/components/vue-draggable-resizable.css" ;
157162import handleExportComponentMixin from " ./ExportComponentMixin.vue" ;
158163const { fs , ipcRenderer } = window ;
@@ -163,6 +168,7 @@ export default {
163168 name: " ComponentDisplay" ,
164169 components: {
165170 VueDraggableResizable,
171+ VueMultiselect,
166172 },
167173 mixins: [handleExportComponentMixin],
168174 data () {
@@ -176,6 +182,7 @@ export default {
176182 initialPosition: { x: 0 , y: 0 },
177183 initialSize: { w: 0 , h: 0 },
178184 htmlElements: [],
185+ childrenSelected: [],
179186 };
180187 },
181188 mounted () {
@@ -203,7 +210,7 @@ export default {
203210 });
204211 window .addEventListener (" paste" , () => {
205212 if (this .noteModalOpen === false ){
206- this .$store .dispatch (" pasteActiveComponent" );
213+ this .$store .dispatch (" pasteActiveComponent" );
207214 }
208215 });
209216 },
@@ -217,8 +224,8 @@ export default {
217224 " imagePath" ,
218225 " activeComponentObj" ,
219226 " exportAsTypescript" ,
220- " noteModalOpen"
221-
227+ " noteModalOpen" ,
228+ " activeRouteDisplay "
222229 ]),
223230 // used in VueDraggableResizeable component
224231 activeRouteArray () {
@@ -231,34 +238,37 @@ export default {
231238 return cloneDeep (this .activeComponentObj );
232239 },
233240 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 = [];
251246 }
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;
262272 },
263273 userImage () {
264274 const imgSrc = ` file://` + this .imagePath [this .activeRoute ];
@@ -316,7 +326,6 @@ export default {
316326 recordInitialPosition : function (e ) {
317327 if (this .activeComponent !== e .target .id ) {
318328 if (e .target .parentElement ? .classList .contains (' draggable' )){
319- // console.log("using vanilla JS to WIN")
320329 this .setActiveComponent (e .target .parentElement .id )
321330 } else {
322331 this .setActiveComponent (e .target .id );
@@ -424,7 +433,7 @@ export default {
424433 this .deleteActiveComponentNote (e .target .previousElementSibling .innerText );
425434 },
426435 // used when user selects to add child from dropdown
427- handleSelect (value ) {
436+ handleSelect (value ) { // actually handles adding or deleting
428437 this .updateActiveComponentChildrenValue (value);
429438 },
430439 // user can change component's layer order
@@ -446,7 +455,11 @@ export default {
446455 this .setActiveComponent (" " );
447456 }
448457 },
449- copyActiveComponent () {},
458+ handleRight (event ) {
459+ if (event .target .className === " component-display grid-bg" ) {
460+ // right click modal to make a component?
461+ }
462+ },
450463 },
451464 watch: {
452465 noteModalOpen (){
@@ -468,6 +481,17 @@ export default {
468481< / script>
469482
470483< 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+
471495li{
472496 display: flex;
473497 font- weight: bold;
477501li: hover{
478502 background- color: $subprimary;
479503}
504+
505+
480506.noteblock {
481507 white- space: pre- wrap;
482508 font- weight: normal;
0 commit comments