Skip to content

Commit bb5f714

Browse files
authored
Merge pull request #25 from oslabs-beta/bryan/improveDeleteNote
note functionality implemented: duplicate check added at time of addi…
2 parents 3db6606 + d081b6e commit bb5f714

File tree

4 files changed

+76
-73
lines changed

4 files changed

+76
-73
lines changed

src/components/ComponentDisplay.vue

Lines changed: 69 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -114,70 +114,44 @@
114114
style="width: 250px; background-color: #fd5f00"
115115
/>
116116
</q-dialog>
117+
117118
<!-- 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.-->
118119
<q-dialog v-model="noteModal" @update:model-value="this.handleAddNotes">
119120
<div class="noteBox">
120121
<div class="noteHolder">
121122
<p class="title">Adding notes to {{ this.activeComponent }}</p>
122123
<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>
124+
<li v-for="(note, index) in this.componentMap[this.activeComponent].noteList" :key="note">
125+
<span class="noteNum">Note {{index}}: </span>
126+
<div class="noteblock">{{ note }}</div><span id="noteDelete" @click="deleteNote">X</span>
157127
</li>
158128
</div>
159-
<q-form class="formBox" autofocus>
129+
<div class="formBox">
130+
<q-form autofocus v-on:submit.prevent="submitNote">
160131
<q-input
161132
v-model="noteText"
162133
label="Add your note here"
163134
filled
164135
dark
165-
autogrow
166-
max-height=15%
167136
autofocus true
137+
hide-bottom-space
138+
:hint="hint"
139+
@keyup.enter="submitNote"
168140
></q-input>
169141
<q-btn
142+
id="comp-btn"
170143
color="secondary"
171144
label="Submit Note"
172145
:disable="noteText.length > 0 ? false : true"
173146
@click="submitNote"
174147
/>
175148
<q-btn
176-
color="secondary"
149+
id="note-btn-close"
177150
label="Exit Notes"
178151
@click="this.openNoteModal"
179152
/>
180153
</q-form>
154+
</div>
181155
</div>
182156
</div>
183157
</q-dialog>
@@ -456,8 +430,7 @@ export default {
456430
this.noteText = '';
457431
},
458432
deleteNote(e){
459-
//currently just deletes the note based on the text alone.
460-
this.deleteActiveComponentNote(e.target.innerText);
433+
this.deleteActiveComponentNote(e.target.previousElementSibling.innerText);
461434
},
462435
// used when user selects to add child from dropdown
463436
handleSelect(value) {
@@ -486,11 +459,15 @@ export default {
486459
},
487460
watch: {
488461
noteModalOpen (){
489-
console.log('display note, prevent delete?', this.noteModalOpen)
490462
this.noteModal = this.noteModalOpen;
491463
},
492464
activeComponent: {
493465
handler(){
466+
if (this.activeComponent !== '' &&
467+
this.$store.state.showTutorial === true &&
468+
this.$store.state.tutorialFirstOpen === true){
469+
this.$store.commit("TOGGLE_TUTORIAL");
470+
}
494471
this.onActivated(this.activeComponentObj);
495472
},
496473
deep: true,
@@ -507,45 +484,70 @@ li{
507484
}
508485
509486
li:hover{
510-
background-color: $negative;
487+
background-color: $subprimary;
511488
}
512489
.noteblock{
513490
white-space: pre-wrap;
514491
font-weight: normal;
515-
width: 85%;
492+
width: 80%;
516493
margin-left: 10px;
517-
align-self: flex-end;
494+
margin-right: 10px;
518495
}
519496
.noteBox{
520497
background-color: $subprimary;
521498
color: $menutext;
522499
width: 65%;
523-
height: 60vh;
524500
padding: 15px;
501+
height: 65vh;
502+
max-height: 80vh;
503+
}
504+
.noteNum{
505+
width: 10%;
506+
}
507+
#noteDelete{
508+
background-color: $secondary;
509+
width: 20px;
510+
height: 20px;
511+
display: flex;
512+
justify-content: center;
513+
align-self: flex-end;
514+
border-radius: 50%;
515+
color: $menutext;
516+
user-select: none;
517+
align-self: center;
518+
}
519+
#noteDelete:hover{
520+
background-color: $negative;
525521
}
526522
.noteHolder{
527523
background-color: $subsecondary;
528524
width: 100%;
529-
height: 100%;
530525
padding: 10px;
531526
display: flex;
532527
flex-direction: column;
533528
flex-wrap: nowrap;
534529
border-radius: 4px;
535530
overflow-y: hidden;
531+
height: 100%;
536532
}
537-
.noteDisplay{
538-
min-height: 30%;
539-
}
533+
540534
.noteContainer{
541-
max-height: 400px;
535+
height: 280px;
536+
max-height: 280px;
542537
border: 1px solid $primary;
543538
border-radius: 4px;
544539
overflow-y: auto;
540+
word-break: break-all;
541+
max-width: 100%;
542+
display:flex;
543+
flex-direction: column;
544+
justify-content: flex-start;
545545
}
546+
546547
.formBox{
547-
max-height: 15%;
548-
justify-self: flex-end;
548+
display: flex;
549+
flex-direction: column;
550+
justify-content: flex-start;
549551
}
550552
551553
.component-title {
@@ -656,4 +658,19 @@ li:hover{
656658
font-weight: bold;
657659
color: white;
658660
}
661+
662+
#comp-btn{
663+
width: 100%;
664+
box-shadow:inset 0 -0.6em 0 -0.35em rgba(0,0,0,0.17);
665+
}
666+
667+
#note-btn-close {
668+
background-color: rgba($negative, .2);
669+
border: 1px solid $negative;
670+
color: $negative;
671+
width: 100%;
672+
margin-top: 10px;
673+
margin-bottom: 10px;
674+
}
675+
659676
</style>

src/components/home_sidebar_items/ComponentTab/CreateComponent.vue

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -215,25 +215,4 @@ export default {
215215
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.2), 0 3px 6px 0 rgba(0, 0, 0, 0.13);
216216
}
217217
218-
// .is-primary {
219-
// height: 45px;
220-
// }
221-
// #add-component-btn {
222-
// height: 15px;
223-
// margin: 0.75rem;
224-
// width: 90%;
225-
// }
226-
// #import-component-btn {
227-
// height: 15px;
228-
// margin: 0 0.75rem;
229-
// width: 90%;
230-
// }
231-
// .inner-div {
232-
// display: flex;
233-
// flex-direction: column;
234-
// justify-content: flex-start;
235-
// padding-left: 15px;
236-
// padding-right: 15px;
237-
// height: 100%;
238-
// }
239218
</style>

src/store/mutations.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ const mutations = {
3333
},
3434

3535
[types.TOGGLE_TUTORIAL]: (state) => {
36+
if (state.tutorialFirstOpen === true){
37+
state.tutorialFirstOpen = false;
38+
}
3639
state.showTutorial = !state.showTutorial;
3740
},
3841

@@ -702,6 +705,9 @@ const mutations = {
702705
if (!state.componentMap[state.activeComponent].hasOwnProperty('noteList')){
703706
state.componentMap[state.activeComponent].noteList = [];
704707
}
708+
while(state.componentMap[state.activeComponent].noteList.includes(payload)){
709+
payload = 'DUPLICATE: ' + payload
710+
}
705711
state.componentMap[state.activeComponent].noteList.push(payload)
706712
},
707713

src/store/state/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const newState = {
5959
pastedComponent: {},
6060
exportAsTypescript: 'off',
6161
showTutorial: true,
62+
tutorialFirstOpen: true,
6263
}
6364

6465
// closured method to ensure we only ever write the default state ONCE

0 commit comments

Comments
 (0)