@@ -35,7 +35,20 @@ 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
54
<q-item clickable v-ripple v-close-popup @click =" handleExportComponent" >
@@ -46,6 +59,14 @@ Description:
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 : menutext "
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,68 @@ 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 >
148
+ <!-- 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.-->
149
+ <q-dialog v-model =" noteModal" @update:model-value =" this.handleAddNotes" >
150
+ <div class =" noteBox" >
151
+ <div class =" noteHolder" >
152
+ <p class =" title" >Adding notes to {{ this.activeComponent }}</p >
153
+ <div class =" noteContainer" >
154
+ <li v-for =" (note, index) in this.componentMap[this.activeComponent].noteList" :key =" note" @click =" deleteNote" >
155
+ Note #{{index}}:
156
+ <div class =" noteblock" >{{ note }}</div >
157
+ </li >
158
+ </div >
159
+ <q-form class =" formBox" autofocus >
160
+ <q-input
161
+ v-model =" noteText"
162
+ label =" Add your note here"
163
+ filled
164
+ dark
165
+ max-height =15%
166
+ autofocus true
167
+ ></q-input >
168
+ <q-btn
169
+ color =" secondary"
170
+ label =" Submit Note"
171
+ type =" submit"
172
+ :disable =" noteText.length > 0 ? false : true"
173
+ @click =" submitNote"
174
+ />
175
+ </q-form >
176
+ </div >
177
+ </div >
178
+ </q-dialog >
95
179
</div >
96
180
</div >
97
181
</template >
@@ -114,8 +198,10 @@ export default {
114
198
data () {
115
199
return {
116
200
modalOpen: false ,
117
- abilityToDelete: false ,
201
+ noteText: ' ' ,
202
+ wasDragged: false ,
118
203
testModel: [],
204
+ noteModal: false ,
119
205
mockImg: false ,
120
206
initialPosition: { x: 0 , y: 0 },
121
207
initialSize: { w: 0 , h: 0 },
@@ -126,27 +212,29 @@ export default {
126
212
// when component is mounted, add ability to delete
127
213
window .addEventListener (" keyup" , (event ) => {
128
214
if (event .key === " Backspace" ) {
129
- if (this .activeComponent ) {
215
+ if (this .activeComponent !== ' ' && this . noteModalOpen === false ) {
130
216
this .$store .dispatch (" deleteActiveComponent" );
131
217
}
132
218
}
133
219
});
134
220
window .addEventListener (" keyup" , (event ) => {
135
221
if (event .key === " Delete" ) {
136
- if (this .activeComponent ) {
222
+ if (this .activeComponent !== ' ' && this . noteModalOpen === false ) {
137
223
this .$store .dispatch (" deleteActiveComponent" );
138
224
}
139
225
}
140
226
});
141
227
// listener for the copy
142
228
window .addEventListener (" copy" , () => {
143
229
// if there is an activeComponent, copy info to state using dispatch
144
- if (this .activeComponent ) {
230
+ if (this .activeComponent !== ' ' && this . noteModalOpen === false ) {
145
231
this .$store .dispatch (" copyActiveComponent" );
146
232
}
147
233
});
148
234
window .addEventListener (" paste" , () => {
149
- this .$store .dispatch (" pasteActiveComponent" );
235
+ if (this .noteModalOpen === false ){
236
+ this .$store .dispatch (" pasteActiveComponent" );
237
+ }
150
238
});
151
239
},
152
240
computed: {
@@ -159,6 +247,8 @@ export default {
159
247
" imagePath" ,
160
248
" activeComponentObj" ,
161
249
" exportAsTypescript" ,
250
+ " noteModalOpen"
251
+
162
252
]),
163
253
// used in VueDraggableResizeable component
164
254
activeRouteArray () {
@@ -248,11 +338,19 @@ export default {
248
338
" updateComponentLayer" ,
249
339
" updateStartingSize" ,
250
340
" updateComponentSize" ,
341
+ " addActiveComponentNote" ,
342
+ " deleteActiveComponentNote" ,
343
+ " openNoteModal" ,
251
344
]),
252
345
// records component's initial position in case of drag
253
346
recordInitialPosition : function (e ) {
254
347
if (this .activeComponent !== e .target .id ) {
255
- this .setActiveComponent (e .target .id );
348
+ if (e .target .parentElement ? .classList .contains (' draggable' )){
349
+ // console.log("using vanilla JS to WIN")
350
+ this .setActiveComponent (e .target .parentElement .id )
351
+ } else {
352
+ this .setActiveComponent (e .target .id );
353
+ }
256
354
}
257
355
this .initialPosition .x = this .activeComponentData .x ;
258
356
this .initialPosition .y = this .activeComponentData .y ;
@@ -298,31 +396,9 @@ export default {
298
396
) {
299
397
this .updateComponentPosition (payload);
300
398
}
399
+ this .wasDragged = true ;
400
+ setTimeout (()=> this .wasDragged = false , 100 )
301
401
},
302
- /* Records size/position
303
- Add @resizing="onResize" to VueDraggableResizable #component-box to use
304
- onResize: function (x, y, width, height) {
305
- this.activeComponentData.x = x
306
- this.activeComponentData.y = y
307
- this.activeComponentData.w = width
308
- this.activeComponentData.h = height
309
- this.componentMap[this.activeComponent].x = x
310
- this.componentMap[this.activeComponent].y = y
311
- this.componentMap[this.activeComponent].w = width
312
- this.componentMap[this.activeComponent].h = height
313
- },
314
- */
315
- /* Records component's position
316
- Add @dragging="onDrag" to VueDraggableResizable #component-box to use
317
- onDrag: function (x, y) {
318
- console.log('ondrag')
319
- this.activeComponentData.x = x
320
- this.activeComponentData.y = y
321
- this.componentMap[this.activeComponent].x = x
322
- this.componentMap[this.activeComponent].y = y
323
- },
324
- */
325
- // unhighlights all inactive components
326
402
onActivated (componentData ) {
327
403
if (! componentData){
328
404
return ;
@@ -358,9 +434,26 @@ export default {
358
434
}
359
435
},
360
436
// renders modal with Update Children and Layer in it
437
+ handleAddNotes (){
438
+ if (this .wasDragged === false ){
439
+ this .openNoteModal ();
440
+ }
441
+ },
361
442
handleAddChild () {
362
443
this .modalOpen = true ;
363
444
},
445
+ submitNote (e ){
446
+ e .preventDefault ()
447
+ if (this .noteText === ' ' ){
448
+ return ;
449
+ }
450
+ this .addActiveComponentNote (this .noteText );
451
+ this .noteText = ' ' ;
452
+ },
453
+ deleteNote (e ){
454
+ // currently just deletes the note based on the text alone.
455
+ this .deleteActiveComponentNote (e .target .innerText );
456
+ },
364
457
// used when user selects to add child from dropdown
365
458
handleSelect (value ) {
366
459
this .updateActiveComponentChildrenValue (value);
@@ -387,6 +480,10 @@ export default {
387
480
copyActiveComponent () {},
388
481
},
389
482
watch: {
483
+ noteModalOpen (){
484
+ console .log (' display note, prevent delete?' , this .noteModalOpen )
485
+ this .noteModal = this .noteModalOpen ;
486
+ },
390
487
activeComponent: {
391
488
handler (){
392
489
this .onActivated (this .activeComponentObj );
@@ -398,6 +495,54 @@ export default {
398
495
< / script>
399
496
400
497
< style scoped lang= " scss" >
498
+ li{
499
+ display: flex;
500
+ font- weight: bold;
501
+ padding: 3px ;
502
+ }
503
+
504
+ li: hover{
505
+ background- color: $negative;
506
+ }
507
+ .noteblock {
508
+ white- space: pre- wrap;
509
+ font- weight: normal;
510
+ width: 85 % ;
511
+ margin- left: 10px ;
512
+ align- self : flex- end;
513
+ }
514
+ .noteBox {
515
+ background- color: $subprimary;
516
+ color: $menutext;
517
+ width: 65 % ;
518
+ height: 60vh ;
519
+ padding: 15px ;
520
+ }
521
+ .noteHolder {
522
+ background- color: $subsecondary;
523
+ width: 100 % ;
524
+ height: 100 % ;
525
+ padding: 10px ;
526
+ display: flex;
527
+ flex- direction: column;
528
+ flex- wrap: nowrap;
529
+ border- radius: 4px ;
530
+ overflow- y: hidden;
531
+ }
532
+ .noteDisplay {
533
+ min- height: 30 % ;
534
+ }
535
+ .noteContainer {
536
+ max- height: 400px ;
537
+ border: 1px solid $primary;
538
+ border- radius: 4px ;
539
+ overflow- y: auto;
540
+ }
541
+ .formBox {
542
+ max- height: 15 % ;
543
+ justify- self : flex- end;
544
+ }
545
+
401
546
.component - title {
402
547
position: relative;
403
548
font- size: 16px ;
@@ -459,6 +604,19 @@ export default {
459
604
.menu {
460
605
margin- bottom: 0px ! important;
461
606
}
607
+
608
+ .compNoteLogo {
609
+ background: $subprimary;
610
+ opacity: 90 % ;
611
+ border- radius: 4px ;
612
+ position: absolute;
613
+ top: 4px ;
614
+ left: 4px ;
615
+ }
616
+ .compNoteLogo : hover{
617
+ background: $primary;
618
+ }
619
+
462
620
.component - box {
463
621
color: $menutext;
464
622
border: 1 .2px dashed $darktext;
@@ -488,4 +646,9 @@ export default {
488
646
#counter {
489
647
margin- top: 20px ;
490
648
}
649
+ .title {
650
+ font- size: 20px ;
651
+ font- weight: bold;
652
+ color: white;
653
+ }
491
654
< / style>
0 commit comments