@@ -35,17 +35,38 @@ Description:
3535 <div class =" component-title" >
3636 <p style =" color : black " >{{ componentData.componentName }}</p >
3737 </div >
38-
38+ <q-icon v-if =" this.componentMap[componentData.componentName]?.noteList?.length > 0"
39+ color =" red"
40+ size =" 30px"
41+ z-layer =" 0"
42+ name =" edit_note"
43+ class =" compNoteLogo"
44+ @click =" handleAddNotes" />
45+ <q-icon v-else
46+ color =" white"
47+ size =" 30px"
48+ z-layer =" 0"
49+ name =" edit_note"
50+ class =" compNoteLogo"
51+ @click =" handleAddNotes" />
3952 <q-menu context-menu >
4053 <q-list color =" black" class =" menu" >
41- <q-item clickable v-ripple v-close-popup @click =" handleExportComponent" >
54+ <q-item clickable v-ripple v-close-popup @click =" handleExportComponent" >
4255 <q-item-section style =" color : white "
4356 >Export Component</q-item-section
4457 >
4558 <q-item-section avatar >
4659 <q-icon color =" primary" name =" upload" />
4760 </q-item-section >
4861 </q-item >
62+ <q-item clickable v-ripple v-close-popup @click =" handleAddNotes" >
63+ <q-item-section style =" color : white "
64+ >Component Notes</q-item-section
65+ >
66+ <q-item-section avatar >
67+ <q-icon color =" primary" name =" edit_note" />
68+ </q-item-section >
69+ </q-item >
4970 <q-item clickable v-ripple v-close-popup @click =" handleAddChild" >
5071 <q-item-section style =" color : white "
5172 >Update Children</q-item-section
@@ -76,9 +97,10 @@ Description:
7697 </q-item >
7798 </q-list >
7899 </q-menu >
100+
79101 </vue-draggable-resizable >
80102 <div >
81- <q-dialog v-model =" modalOpen" >
103+ <q-dialog v-model =" modalOpen" persistent >
82104 <q-select
83105 @select =" handleSelect"
84106 id =" dropdown"
@@ -92,6 +114,37 @@ Description:
92114 style =" width : 250px ; background-color : #fd5f00 "
93115 />
94116 </q-dialog >
117+ <!-- 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.-->
118+ <q-dialog v-model =" noteModal" @update:model-value =" this.handleAddNotes" >
119+ <div class =" noteBox" >
120+ <div class =" noteHolder" >
121+ <p class =" title" >Adding notes to {{ this.activeComponent }}</p >
122+ <div class =" noteContainer" >
123+ <li v-for =" (note, index) in this.componentMap[this.activeComponent].noteList" :key =" note" @click =" deleteNote" >
124+ Note #{{index}}:
125+ <div class =" noteblock" >{{ note }}</div >
126+ </li >
127+ </div >
128+ <q-form class =" formBox" autofocus >
129+ <q-input
130+ v-model =" noteText"
131+ label =" Add your note here"
132+ filled
133+ dark
134+ max-height =15%
135+ autofocus true
136+ ></q-input >
137+ <q-btn
138+ color =" secondary"
139+ label =" Submit Note"
140+ type =" submit"
141+ :disable =" noteText.length > 0 ? false : true"
142+ @click =" submitNote"
143+ />
144+ </q-form >
145+ </div >
146+ </div >
147+ </q-dialog >
95148 </div >
96149 </div >
97150</template >
@@ -114,8 +167,10 @@ export default {
114167 data () {
115168 return {
116169 modalOpen: false ,
117- abilityToDelete: false ,
170+ noteText: ' ' ,
171+ wasDragged: false ,
118172 testModel: [],
173+ noteModal: false ,
119174 mockImg: false ,
120175 initialPosition: { x: 0 , y: 0 },
121176 initialSize: { w: 0 , h: 0 },
@@ -126,27 +181,29 @@ export default {
126181 // when component is mounted, add ability to delete
127182 window .addEventListener (" keyup" , (event ) => {
128183 if (event .key === " Backspace" ) {
129- if (this .activeComponent ) {
184+ if (this .activeComponent !== ' ' && this . noteModalOpen === false ) {
130185 this .$store .dispatch (" deleteActiveComponent" );
131186 }
132187 }
133188 });
134189 window .addEventListener (" keyup" , (event ) => {
135190 if (event .key === " Delete" ) {
136- if (this .activeComponent ) {
191+ if (this .activeComponent !== ' ' && this . noteModalOpen === false ) {
137192 this .$store .dispatch (" deleteActiveComponent" );
138193 }
139194 }
140195 });
141196 // listener for the copy
142197 window .addEventListener (" copy" , () => {
143198 // if there is an activeComponent, copy info to state using dispatch
144- if (this .activeComponent ) {
199+ if (this .activeComponent !== ' ' && this . noteModalOpen === false ) {
145200 this .$store .dispatch (" copyActiveComponent" );
146201 }
147202 });
148203 window .addEventListener (" paste" , () => {
149- this .$store .dispatch (" pasteActiveComponent" );
204+ if (this .noteModalOpen === false ){
205+ this .$store .dispatch (" pasteActiveComponent" );
206+ }
150207 });
151208 },
152209 computed: {
@@ -159,6 +216,7 @@ export default {
159216 " imagePath" ,
160217 " activeComponentObj" ,
161218 " exportAsTypescript" ,
219+ " noteModalOpen"
162220 ]),
163221 // used in VueDraggableResizeable component
164222 activeRouteArray () {
@@ -247,11 +305,19 @@ export default {
247305 " updateComponentLayer" ,
248306 " updateStartingSize" ,
249307 " updateComponentSize" ,
308+ " addActiveComponentNote" ,
309+ " deleteActiveComponentNote" ,
310+ " openNoteModal" ,
250311 ]),
251312 // records component's initial position in case of drag
252- recordInitialPosition : function (e ) {
313+ recordInitialPosition : function (e ) {
253314 if (this .activeComponent !== e .target .id ) {
254- this .setActiveComponent (e .target .id );
315+ if (e .target .parentElement ? .classList .contains (' draggable' )){
316+ // console.log("using vanilla JS to WIN")
317+ this .setActiveComponent (e .target .parentElement .id )
318+ } else {
319+ this .setActiveComponent (e .target .id );
320+ }
255321 }
256322 this .initialPosition .x = this .activeComponentData .x ;
257323 this .initialPosition .y = this .activeComponentData .y ;
@@ -297,31 +363,9 @@ export default {
297363 ) {
298364 this .updateComponentPosition (payload);
299365 }
366+ this .wasDragged = true ;
367+ setTimeout (()=> this .wasDragged = false , 100 )
300368 },
301- /* Records size/position
302- Add @resizing="onResize" to VueDraggableResizable #component-box to use
303- onResize: function (x, y, width, height) {
304- this.activeComponentData.x = x
305- this.activeComponentData.y = y
306- this.activeComponentData.w = width
307- this.activeComponentData.h = height
308- this.componentMap[this.activeComponent].x = x
309- this.componentMap[this.activeComponent].y = y
310- this.componentMap[this.activeComponent].w = width
311- this.componentMap[this.activeComponent].h = height
312- },
313- */
314- /* Records component's position
315- Add @dragging="onDrag" to VueDraggableResizable #component-box to use
316- onDrag: function (x, y) {
317- console.log('ondrag')
318- this.activeComponentData.x = x
319- this.activeComponentData.y = y
320- this.componentMap[this.activeComponent].x = x
321- this.componentMap[this.activeComponent].y = y
322- },
323- */
324- // unhighlights all inactive components
325369 onActivated (componentData ) {
326370 if (! componentData){
327371 return ;
@@ -357,9 +401,26 @@ export default {
357401 }
358402 },
359403 // renders modal with Update Children and Layer in it
404+ handleAddNotes (){
405+ if (this .wasDragged === false ){
406+ this .openNoteModal ();
407+ }
408+ },
360409 handleAddChild () {
361410 this .modalOpen = true ;
362411 },
412+ submitNote (e ){
413+ e .preventDefault ()
414+ if (this .noteText === ' ' ){
415+ return ;
416+ }
417+ this .addActiveComponentNote (this .noteText );
418+ this .noteText = ' ' ;
419+ },
420+ deleteNote (e ){
421+ // currently just deletes the note based on the text alone.
422+ this .deleteActiveComponentNote (e .target .innerText );
423+ },
363424 // used when user selects to add child from dropdown
364425 handleSelect (value ) {
365426 this .updateActiveComponentChildrenValue (value);
@@ -386,6 +447,10 @@ export default {
386447 copyActiveComponent () {},
387448 },
388449 watch: {
450+ noteModalOpen (){
451+ console .log (' display note, prevent delete?' , this .noteModalOpen )
452+ this .noteModal = this .noteModalOpen ;
453+ },
389454 activeComponent: {
390455 handler (){
391456 this .onActivated (this .activeComponentObj );
@@ -397,6 +462,53 @@ export default {
397462< / script>
398463
399464< style scoped lang= " scss" >
465+ li{
466+ display: flex;
467+ font- weight: bold;
468+ padding: 3px ;
469+ }
470+
471+ li: hover{
472+ background- color: $negative;
473+ }
474+ .noteblock {
475+ white- space: pre- wrap;
476+ font- weight: normal;
477+ width: 85 % ;
478+ margin- left: 10px ;
479+ align- self : flex- end;
480+ }
481+ .noteBox {
482+ background- color: $subprimary;
483+ color: $menutext;
484+ width: 65 % ;
485+ height: 60vh ;
486+ padding: 15px ;
487+ }
488+ .noteHolder {
489+ background- color: $subsecondary;
490+ width: 100 % ;
491+ height: 100 % ;
492+ padding: 10px ;
493+ display: flex;
494+ flex- direction: column;
495+ flex- wrap: nowrap;
496+ border- radius: 4px ;
497+ overflow- y: hidden;
498+ }
499+ .noteDisplay {
500+ min- height: 30 % ;
501+ }
502+ .noteContainer {
503+ max- height: 400px ;
504+ border: 1px solid $primary;
505+ border- radius: 4px ;
506+ overflow- y: auto;
507+ }
508+ .formBox {
509+ max- height: 15 % ;
510+ justify- self : flex- end;
511+ }
400512.component - title {
401513 position: relative;
402514 font- size: 16px ;
@@ -454,6 +566,19 @@ export default {
454566.menu {
455567 margin- bottom: 0px ! important;
456568}
569+
570+ .compNoteLogo {
571+ background: $subprimary;
572+ opacity: 90 % ;
573+ border- radius: 4px ;
574+ position: absolute;
575+ top: 4px ;
576+ left: 4px ;
577+ }
578+ .compNoteLogo : hover{
579+ background: $primary;
580+ }
581+
457582.component - box {
458583 color: white;
459584 border: 1 .2px dashed rgb (231 , 203 , 75 );
@@ -483,4 +608,9 @@ export default {
483608#counter {
484609 margin- top: 20px ;
485610}
611+ .title {
612+ font- size: 20px ;
613+ font- weight: bold;
614+ color: white;
615+ }
486616< / style>
0 commit comments