@@ -5,15 +5,42 @@ Description:
5
5
-->
6
6
7
7
<template >
8
- <section class =" html-queue" >
8
+ <section class =" html-queue" @dragover = " dragOver($event), false " >
9
9
<span class =' list-title' v-if =' this.activeLayer.id !== ""' >
10
10
<i class =" fas fa fa-chevron-up fa-md" @click =" setParentLayer" ></i >
11
+
11
12
  ;   ; Viewing Elements in {{ this.activeComponent }} '{{ depth }}'
12
13
<hr >
13
14
</span >
14
15
<span class =' list-title' v-else-if =' !this.activeComponent' ></span >
16
+
15
17
<div group =" people" class =" list-group" >
18
+
16
19
<p v-if =' !this.componentMap[this.activeComponent]?.htmlList.length' >No HTML elements in component</p >
20
+ <div v-for =" (element) in renderList" :key =" element[1] + Date.now()" @dragenter =" dragEnter($event, element[2])" >
21
+ <div id =" tooltipCon" :class =" activeHTML === element[2] ? 'list-group-item-selected' : 'list-group-item'"
22
+ @dragstart =" startDrag($event, element[2])" @dragend =" endDrag($event)" draggable =" true" >
23
+ <!-- invisible button for tooltip-->
24
+ <button class =" attributeButton" @click =" setActiveElement(element)" >
25
+ <div class =" tooltip" > Edit {{ element[0] }} attributes </div >
26
+ </button >
27
+ <i v-if =' activeComponent === "" || exceptions.includes(element[0])' ></i >
28
+ <i v-else class =" fas fa fa-angle-double-down fa-md"
29
+ @click =" setLayer({ text: element[0], id: element[2] })" ></i >
30
+ {{ element[0] }}
31
+ <i class =" fas fa fa-trash fa-md" @click.self =" deleteElement([element[1], element[2]])" ></i >
32
+ </div >
33
+ </div >
34
+ </div >
35
+
36
+ <!-- START OF CHANGES-->
37
+ <!-- Viewing Elements in {{ this.activeComponent }} '{{ depth }}'
38
+ <hr>
39
+ </span>
40
+ <span class='list-title' v-else-if='!this.activeComponent'></span>
41
+ <div group="people" class="list-group">
42
+ <p v-if='!this.componentMap[this.activeComponent]?.htmlList.length'>No HTML elements in component</p>
43
+
17
44
<div id="tooltipCon" :class="activeHTML === element[2] ? 'list-group-item-selected' : 'list-group-item'"
18
45
v-for="(element) in renderList" :key="element[1] + Date.now()">
19
46
@@ -25,21 +52,23 @@ Description:
25
52
{{ element[0] }}
26
53
<i class="fas fa fa-trash fa-md" @click.self="deleteElement([element[1], element[2]])"></i>
27
54
</div>
28
- </div >
55
+ </div> -->
29
56
30
57
<!-- attribute pop-up -->
31
58
<q-dialog v-model =" attributeModal" >
32
59
<!-- @update:model-value="setActiveElement" -->
33
60
<div class =" AttributeBox" >
34
- <p class =" title" >Added attributes to {{ this.activeComponent }}</p >
61
+ <p class =" title" >Add attributes to: {{ this.activeComponent }}</p >
62
+ <!-- attribute child-->
35
63
<div class =" AttributeContainer" v-for =" element in this.componentMap[this.activeComponent].htmlList"
36
64
:key =" element.id + Date.now()" >
37
65
<p v-if =" element.id === this.activeHTML" >Your class is - {{ element.class }}</p >
38
66
</div >
67
+
39
68
<div class =" formBox" >
40
69
<q-form autofocus v-on:submit.prevent =" submitClass" >
41
70
<p class =" title" >Add Class Name:</p >
42
- <q-input label =" Add your note here" filled dark autofocus true hide-bottom-space v-model =" classText"
71
+ <q-input label =" Add your class here" filled dark autofocus true hide-bottom-space v-model =" classText"
43
72
@keyup.enter =" submitClass" ></q-input >
44
73
<q-btn id =" comp-btn" class =" sidebar-btn" color =" secondary" label =" Submit Attribute"
45
74
:disable =" classText.length > 0 ? false : true" @click =" submitClass(classText, this.activeHTML)" />
@@ -53,6 +82,7 @@ Description:
53
82
54
83
<script >
55
84
85
+ import { keys } from ' localforage'
56
86
import { mapState , mapActions } from ' vuex'
57
87
import { setSelectedElementList , deleteSelectedElement , deleteFromComponentHtmlList } from ' ../../store/types'
58
88
import { breadthFirstSearch } from ' ../../utils/search.util'
@@ -106,16 +136,12 @@ export default {
106
136
107
137
},
108
138
methods: {
109
- ... mapActions ([' setActiveHTML' , ' setActiveLayer' , ' upOneLayer' , ' openAttributeModal ' , ' addActiveComponentClass, addBinding ' ]),
139
+ ... mapActions ([' setActiveHTML' , ' setActiveLayer' , ' upOneLayer' , ' setSelectedIdDrag ' , ' setIdDrag ' , ' setSelectedIdDrop ' , ' setIdDrop ' , ' dragDropSortHtmlElements ' , ' dragDropSortSelectedHtmlElements ' , ' openAttributeModal ' , ' addActiveComponentClass ' ]),
110
140
deleteElement (id ) {
111
141
if (this .activeComponent === ' ' ) this .$store .dispatch (deleteSelectedElement, id[0 ])
112
- else this .$store .dispatch (deleteFromComponentHtmlList, id[1 ])
113
- },
114
- setActiveElement (element ) {
115
- if (this .activeComponent !== ' ' ) {
116
- this .setActiveHTML (element);
117
- this .openAttributeModal (element);
118
- }
142
+ this .setActiveHTML (element);
143
+ this .openAttributeModal (element);
144
+
119
145
},
120
146
setLayer (element ) {
121
147
this .setActiveLayer (element)
@@ -126,6 +152,32 @@ export default {
126
152
this .upOneLayer (this .activeLayer .id )
127
153
}
128
154
},
155
+ // METHODS FOR DRAG-AND-DROP
156
+ startDrag (event , id ) {
157
+ // add a class of 'currentlyDragging' to the HTML element that you are currently dragging
158
+ event .target .classList .add (' currentlyDragging' )
159
+ const dragId = id;
160
+ if (this .activeComponent === ' ' ) this .setSelectedIdDrag (dragId)
161
+ else this .setIdDrag (dragId)
162
+ },
163
+ dragEnter (event , id ) {
164
+ event .preventDefault ();
165
+ const dropId = id;
166
+ if (this .activeComponent === ' ' ) this .setSelectedIdDrop (dropId)
167
+ else this .setIdDrop (dropId)
168
+ },
169
+ dragOver (event ) {
170
+ // needed stop the dragend animation so endDrag is invoked automatically
171
+ event .preventDefault ();
172
+ },
173
+ endDrag (event ) {
174
+ // remove the 'currentlyDragging' class after the HTML is dropped
175
+ event .preventDefault ();
176
+ event .target .classList .remove (' currentlyDragging' )
177
+ // invoke the action that will use the idDrag and idDrop to sort the HtmlList
178
+ if (this .activeComponent === ' ' ) this .dragDropSortSelectedHtmlElements ()
179
+ else this .dragDropSortHtmlElements ()
180
+ },
129
181
submitClass (element , idNum ) {
130
182
if (element === ' ' ) {
131
183
return ;
@@ -182,11 +234,12 @@ li {
182
234
height : 35px ;
183
235
padding-top : 6px ;
184
236
text-align : center ;
237
+ cursor : move ;
185
238
}
186
239
187
240
.list-group-item-selected {
188
241
display : inline-block ;
189
- margin : 2 px 1.5% ;
242
+ margin : 4 px 1.5% ;
190
243
min-width : 175px ;
191
244
width : 30% ;
192
245
border-radius : 0.5cm ;
195
248
height : 35px ;
196
249
padding-top : 6px ;
197
250
text-align : center ;
251
+ cursor : move ;
198
252
}
199
253
200
254
.fa-trash :hover {
@@ -239,11 +293,18 @@ hr {
239
293
border : 1px solid grey
240
294
}
241
295
296
+ .currentlyDragging {
297
+ opacity : 1 ;
298
+ }
299
+
300
+ .ignoreByDragover {
301
+ pointer-events : none ;
302
+ }
242
303
243
304
#tooltipCon {
244
305
position : relative ;
245
306
cursor : pointer ;
246
- margin-top : 2 em ;
307
+ margin-top : 1 em ;
247
308
}
248
309
249
310
.tooltip {
268
329
}
269
330
270
331
271
-
272
-
273
332
.AttributeBox {
274
333
background-color : $subsecondary ;
275
334
color : $menutext ;
0 commit comments