Skip to content

Commit 8a495c1

Browse files
committed
Merge branch 'dev' of https://github.com/oslabs-beta/OverVue into dev
2 parents 93d2bcf + 9239603 commit 8a495c1

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

src/components/left-sidebar/ComponentTab/CreateMenuHTMLQueue.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,17 @@ export default {
106106
},
107107
//METHODS FOR DRAG-AND-DROP
108108
startDrag (event, id) {
109-
//add a class of 'currentlyDragging' to the HTML element that you are currently dragging
109+
//add a class to make the html element currently being drag transparent
110110
event.target.classList.add('currentlyDragging')
111111
const dragId = id;
112+
//store the id of dragged element
112113
if (this.activeComponent === '') this.setSelectedIdDrag(dragId)
113114
else this.setIdDrag(dragId)
114115
},
115116
dragEnter (event, id) {
116117
event.preventDefault();
117118
const dropId = id;
119+
//store the id of the html element whose location the dragged html element could be dropped upon
118120
if (this.activeComponent === '') this.setSelectedIdDrop(dropId)
119121
else this.setIdDrop(dropId)
120122
},
@@ -123,7 +125,7 @@ export default {
123125
event.preventDefault();
124126
},
125127
endDrag (event) {
126-
//remove the 'currentlyDragging' class after the HTML is dropped
128+
//remove the 'currentlyDragging' class after the HTML is dropped to remove transparency
127129
event.preventDefault();
128130
event.target.classList.remove('currentlyDragging')
129131
//invoke the action that will use the idDrag and idDrop to sort the HtmlList

src/components/left-sidebar/ComponentTab/Icons.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Description:
1414
<br />
1515
<span>{{ elementName }}</span>
1616
</button>
17-
<!-- Child Component Icons-->
17+
<!-- Icons for activeComponent's Child Components-->
1818
<button
1919
@click.prevent="changeState(elementName)"
2020
v-for="(elementName, idx) in childrenComp"
@@ -27,7 +27,6 @@ Description:
2727
<span>{{ elementName }}</span>
2828
</button>
2929

30-
3130
</section>
3231
</template>
3332

src/components/right-sidebar/HTMLQueue.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ export default {
147147
})
148148
return newTitle;
149149
},
150+
//make child components in htmlList exceptions
150151
moreExceptions: function () {
151152
let childComponent = [];
152153
if(this.activeComponent) {
@@ -179,15 +180,17 @@ export default {
179180
},
180181
//METHODS FOR DRAG-AND-DROP
181182
startDrag(event, id) {
182-
//add a class of 'currentlyDragging' to the HTML element that you are currently dragging
183+
//add a class to make the html element currently being drag transparent
183184
event.target.classList.add('currentlyDragging')
184185
const dragId = id;
186+
//store the id of dragged element
185187
if (this.activeComponent === '') this.setSelectedIdDrag(dragId)
186188
else this.setIdDrag(dragId)
187189
},
188190
dragEnter(event, id) {
189191
event.preventDefault();
190192
const dropId = id;
193+
//store the id of the html element whose location the dragged html element could be dropped upon
191194
if (this.activeComponent === '') this.setSelectedIdDrop(dropId)
192195
else this.setIdDrop(dropId)
193196
},
@@ -196,7 +199,7 @@ export default {
196199
event.preventDefault();
197200
},
198201
endDrag(event) {
199-
//remove the 'currentlyDragging' class after the HTML is dropped
202+
//remove the 'currentlyDragging' class after the HTML is dropped to remove transparency
200203
event.preventDefault();
201204
event.target.classList.remove('currentlyDragging')
202205
//invoke the action that will use the idDrag and idDrop to sort the HtmlList

src/store/mutations.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ const mutations = {
330330
}
331331
}
332332
}
333-
//update the component name in the htmlList of all components if it is a child component
333+
//update the the htmlList, find child components within the htmlLists with the old value, update it to the new value
334334
for (const item of Object.values(state.componentMap)) {
335335
if (item.htmlList) {
336336
const newArray = [...item.htmlList];
@@ -495,25 +495,26 @@ const mutations = {
495495
}
496496
state.activeHTML = "";
497497
},
498-
498+
//Drag-andDrop
499+
//store id of dragged html element in activeComponent
499500
[types.SET_ID_DRAG]: (state, payload) => {
500501
const componentName = state.activeComponent;
501502
state.componentMap[componentName].idDrag = payload;
502503
},
503-
504+
//store id of html element whose place the dragged html element is dropped on in activeComponent
504505
[types.SET_ID_DROP]: (state, payload) => {
505506
const componentName = state.activeComponent;
506507
state.componentMap[componentName].idDrop = payload;
507508
},
508-
509+
//store id of dragged selected html element when creating a component
509510
[types.SET_SELECTED_ID_DRAG]: (state, payload) => {
510511
state.selectedIdDrag = payload;
511512
},
512-
513+
//store id of html element whose place the dragged selected html element will be dropped when creating a component
513514
[types.SET_SELECTED_ID_DROP]: (state, payload) => {
514515
state.selectedIdDrop = payload;
515516
},
516-
517+
// use idDrag and idDrop to rearrange the htmlList of the activeComponent to perform drag-and-drop functionality
517518
[types.DRAG_DROP_SORT_HTML_ELEMENTS]: (state) => {
518519
const componentName = state.activeComponent;
519520
const idDrag = state.componentMap[componentName].idDrag;
@@ -525,27 +526,32 @@ const mutations = {
525526
const htmlList = state.componentMap[componentName].htmlList.slice(0)
526527

527528
if (state.activeLayer.id === "") {
529+
//find the indexes belonging to the html elements with idDrag and idDrop
528530
htmlList.forEach((el, i) => {
529531
if (el.id === idDrag) {
530532
indexDrag = i;
531533
} else if (el.id === idDrop) {
532534
indexDrop = i;
533535
}
534536
})
537+
//use the indexes to rearrange htmlList
535538
const draggedEl = htmlList.splice(indexDrag, 1)[0]
536539
htmlList.splice(indexDrop, 0, draggedEl)
537540
} else {
541+
//Use breadFirstSearchParent to find the parent and indexes of nested html elements with idDrag and idDrop
538542
const nestedDrag = breadthFirstSearchParent(htmlList, idDrag);
539543
const nestedDrop = breadthFirstSearchParent(htmlList, idDrop);
544+
//use the indexes and parents to rearrange htmlList
540545
let nestedEl = nestedDrag.evaluated.children.splice(nestedDrag.index, 1)[0]
541546
nestedDrop.evaluated.children.splice(nestedDrop.index, 0, nestedEl)
542547
}
543548
state.componentMap[componentName].htmlList = htmlList;
544549
}
550+
//reset the ids
545551
state.componentMap[componentName].idDrag = '';
546552
state.componentMap[componentName].idDrop = '';
547553
},
548-
554+
// use selectedIdDrag and selectedIdDrop to rearrange the selectedElementList to perform drag-and-drop functionality
549555
[types.DRAG_DROP_SORT_SELECTED_HTML_ELEMENTS]: (state) => {
550556
const selectedIdDrag = state.selectedIdDrag;
551557
const selectedIdDrop = state.selectedIdDrop;
@@ -555,19 +561,20 @@ const mutations = {
555561

556562
let indexDrag;
557563
let indexDrop;
558-
564+
//find the indexes belonging to the html elements with the selectedIdDrag and selectedIdDrop
559565
htmlList.forEach((el, i) => {
560566
if (el.id === selectedIdDrag) {
561567
indexDrag = i;
562568
} else if (el.id === selectedIdDrop) {
563569
indexDrop = i;
564570
}
565571
})
566-
572+
//use the indexes to delete the dragged element and place them into the new location
567573
const draggedEl = htmlList.splice(indexDrag, 1)[0]
568574
htmlList.splice(indexDrop, 0, draggedEl)
569575
state.selectedElementList = htmlList;
570576
}
577+
//reset the ids
571578
state.selectedIdDrag = '';
572579
state.selectedIdDrop = '';
573580
},

0 commit comments

Comments
 (0)