@@ -35,17 +35,38 @@ Description:
35
35
<div class =" component-title" >
36
36
<p style =" color : black " >{{ componentData.componentName }}</p >
37
37
</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" />
39
52
<q-menu context-menu >
40
53
<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" >
42
55
<q-item-section style =" color : white "
43
56
>Export Component</q-item-section
44
57
>
45
58
<q-item-section avatar >
46
59
<q-icon color =" primary" name =" upload" />
47
60
</q-item-section >
48
61
</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 >
49
70
<q-item clickable v-ripple v-close-popup @click =" handleAddChild" >
50
71
<q-item-section style =" color : white "
51
72
>Update Children</q-item-section
@@ -76,9 +97,10 @@ Description:
76
97
</q-item >
77
98
</q-list >
78
99
</q-menu >
100
+
79
101
</vue-draggable-resizable >
80
102
<div >
81
- <q-dialog v-model =" modalOpen" >
103
+ <q-dialog v-model =" modalOpen" persistent >
82
104
<q-select
83
105
@select =" handleSelect"
84
106
id =" dropdown"
@@ -92,6 +114,37 @@ Description:
92
114
style =" width : 250px ; background-color : #fd5f00 "
93
115
/>
94
116
</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 >
95
148
</div >
96
149
</div >
97
150
</template >
@@ -114,8 +167,10 @@ export default {
114
167
data () {
115
168
return {
116
169
modalOpen: false ,
117
- abilityToDelete: false ,
170
+ noteText: ' ' ,
171
+ wasDragged: false ,
118
172
testModel: [],
173
+ noteModal: false ,
119
174
mockImg: false ,
120
175
initialPosition: { x: 0 , y: 0 },
121
176
initialSize: { w: 0 , h: 0 },
@@ -126,27 +181,29 @@ export default {
126
181
// when component is mounted, add ability to delete
127
182
window .addEventListener (" keyup" , (event ) => {
128
183
if (event .key === " Backspace" ) {
129
- if (this .activeComponent ) {
184
+ if (this .activeComponent !== ' ' && this . noteModalOpen === false ) {
130
185
this .$store .dispatch (" deleteActiveComponent" );
131
186
}
132
187
}
133
188
});
134
189
window .addEventListener (" keyup" , (event ) => {
135
190
if (event .key === " Delete" ) {
136
- if (this .activeComponent ) {
191
+ if (this .activeComponent !== ' ' && this . noteModalOpen === false ) {
137
192
this .$store .dispatch (" deleteActiveComponent" );
138
193
}
139
194
}
140
195
});
141
196
// listener for the copy
142
197
window .addEventListener (" copy" , () => {
143
198
// if there is an activeComponent, copy info to state using dispatch
144
- if (this .activeComponent ) {
199
+ if (this .activeComponent !== ' ' && this . noteModalOpen === false ) {
145
200
this .$store .dispatch (" copyActiveComponent" );
146
201
}
147
202
});
148
203
window .addEventListener (" paste" , () => {
149
- this .$store .dispatch (" pasteActiveComponent" );
204
+ if (this .noteModalOpen === false ){
205
+ this .$store .dispatch (" pasteActiveComponent" );
206
+ }
150
207
});
151
208
},
152
209
computed: {
@@ -159,6 +216,7 @@ export default {
159
216
" imagePath" ,
160
217
" activeComponentObj" ,
161
218
" exportAsTypescript" ,
219
+ " noteModalOpen"
162
220
]),
163
221
// used in VueDraggableResizeable component
164
222
activeRouteArray () {
@@ -247,11 +305,19 @@ export default {
247
305
" updateComponentLayer" ,
248
306
" updateStartingSize" ,
249
307
" updateComponentSize" ,
308
+ " addActiveComponentNote" ,
309
+ " deleteActiveComponentNote" ,
310
+ " openNoteModal" ,
250
311
]),
251
312
// records component's initial position in case of drag
252
- recordInitialPosition : function (e ) {
313
+ recordInitialPosition : function (e ) {
253
314
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
+ }
255
321
}
256
322
this .initialPosition .x = this .activeComponentData .x ;
257
323
this .initialPosition .y = this .activeComponentData .y ;
@@ -297,31 +363,9 @@ export default {
297
363
) {
298
364
this .updateComponentPosition (payload);
299
365
}
366
+ this .wasDragged = true ;
367
+ setTimeout (()=> this .wasDragged = false , 100 )
300
368
},
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
325
369
onActivated (componentData ) {
326
370
if (! componentData){
327
371
return ;
@@ -357,9 +401,26 @@ export default {
357
401
}
358
402
},
359
403
// renders modal with Update Children and Layer in it
404
+ handleAddNotes (){
405
+ if (this .wasDragged === false ){
406
+ this .openNoteModal ();
407
+ }
408
+ },
360
409
handleAddChild () {
361
410
this .modalOpen = true ;
362
411
},
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
+ },
363
424
// used when user selects to add child from dropdown
364
425
handleSelect (value ) {
365
426
this .updateActiveComponentChildrenValue (value);
@@ -386,6 +447,10 @@ export default {
386
447
copyActiveComponent () {},
387
448
},
388
449
watch: {
450
+ noteModalOpen (){
451
+ console .log (' display note, prevent delete?' , this .noteModalOpen )
452
+ this .noteModal = this .noteModalOpen ;
453
+ },
389
454
activeComponent: {
390
455
handler (){
391
456
this .onActivated (this .activeComponentObj );
@@ -397,6 +462,53 @@ export default {
397
462
< / script>
398
463
399
464
< 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
+ }
400
512
.component - title {
401
513
position: relative;
402
514
font- size: 16px ;
@@ -454,6 +566,19 @@ export default {
454
566
.menu {
455
567
margin- bottom: 0px ! important;
456
568
}
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
+
457
582
.component - box {
458
583
color: white;
459
584
border: 1 .2px dashed rgb (231 , 203 , 75 );
@@ -483,4 +608,9 @@ export default {
483
608
#counter {
484
609
margin- top: 20px ;
485
610
}
611
+ .title {
612
+ font- size: 20px ;
613
+ font- weight: bold;
614
+ color: white;
615
+ }
486
616
< / style>
0 commit comments