1
1
<template >
2
2
<section class =" home-queue" v-on:click =" handleClick" >
3
- <span class = ' list-title ' v-if =' this.activeLayer.id !== ""' > Viewing Elements in '{{ this.activeComponent }} - {{ this.activeLayer.lineage }}' </ span >
4
- <!-- < span class='list-title' v-if='this.activeLayer.id !== ""'> Viewing Elements in '{{ this.activeLayer.lineage }}' </span> -- >
3
+ <i v-if =' this.activeLayer.id !== ""' class = " fas fa fa-chevron-up fa-md " @click = " setParentLayer " ></ i >
4
+ <span class =' list-title' v-if =' this.activeLayer.id !== ""' > Viewing Elements in '{{ this.activeComponent }} {{ this.depth }}' </span >
5
5
<span class =' list-title' v-else-if =' this.activeComponent !==""' > Viewing Elements in '{{ this.activeComponent }}' </span >
6
6
<span class =' list-title' v-else > Elements in Queue </span >
7
7
<hr >
13
13
@start =" drag = true"
14
14
@end =" drag = false"
15
15
>
16
- <div :class =" activeHTML === element[2] ? 'list-group-item-selected' : 'list-group-item'" @dblclick =" setActiveElement(element)" v-for =" (element) in renderList" :key =" element[1] + Date.now()" >
16
+ <div :class =" activeHTML === element[2] ? 'list-group-item-selected' : 'list-group-item'" @dblclick.self =" setActiveElement(element)" v-for =" (element) in renderList" :key =" element[1] + Date.now()" >
17
17
<i class =" fas fa fa-angle-double-down fa-md" @click =" setLayer({text: element[0], id: element[2]})" ></i >
18
18
{{ element[0] }}
19
- <i class =" fas fa fa-trash fa-md" @click =" deleteElement(element[1])" ></i >
19
+ <i class =" fas fa fa-trash fa-md" @click.self =" deleteElement(element[1])" ></i >
20
20
</div >
21
21
</draggable >
22
22
</section >
25
25
<script >
26
26
import draggable from ' vuedraggable'
27
27
import { mapState , mapActions } from ' vuex'
28
- import { setSelectedElementList , deleteSelectedElement , deleteFromComponentHtmlList , setActiveHTML , setActiveLayer } from ' ../store/types'
28
+ import { setSelectedElementList , deleteSelectedElement , deleteFromComponentHtmlList } from ' ../store/types'
29
29
30
30
const breadthFirstSearch = (array , id ) => {
31
31
let queue = [... array .filter (el => typeof el === ' object' )]
@@ -52,19 +52,18 @@ export default {
52
52
type: Array
53
53
}
54
54
},
55
- // data () {
56
- // return {
57
- // //component: false
58
- // }
59
- // },
55
+ data () {
56
+ return {
57
+ depth : ' '
58
+ }
59
+ },
60
60
computed: {
61
61
... mapState ([' selectedElementList' , ' componentMap' , ' activeComponent' , ' activeHTML' , ' activeLayer' ]),
62
62
renderList: {
63
63
get () {
64
64
if (this .activeComponent === ' ' ) return this .selectedElementList .map ((el , index ) => [el .text , index, el .id ])
65
65
// change activeComponent's htmlList into an array of arrays ([element/component name, index in state])
66
66
if (this .activeComponent !== ' ' && this .activeLayer .id === ' ' ) {
67
- console .log (' this works right?' )
68
67
let sortedHTML = this .componentMap [this .activeComponent ].htmlList .map ((el , index ) => [el .text , index, el .id ]).filter (el => {
69
68
return el[0 ] !== undefined
70
69
})
@@ -82,16 +81,30 @@ export default {
82
81
}
83
82
},
84
83
methods: {
85
- ... mapActions ([' setActiveHTML' , ' setActiveLayer' ]),
84
+ ... mapActions ([' setActiveHTML' , ' setActiveLayer' , ' upOneLayer ' ]),
86
85
deleteElement (index ) {
87
86
if (this .activeComponent === ' ' ) this .$store .dispatch (deleteSelectedElement, index)
88
87
else this .$store .dispatch (deleteFromComponentHtmlList, index)
89
88
},
90
89
setActiveElement (element ) {
91
- this .$store . dispatch ( setActiveHTML, element)
90
+ this .setActiveHTML ( element)
92
91
},
93
92
setLayer (element ) {
94
- this .$store .dispatch (setActiveLayer, element)
93
+ this .setActiveLayer (element)
94
+ this .setTitle ()
95
+ },
96
+ setParentLayer () {
97
+ if (this .activeLayer .id !== ' ' ) {
98
+ this .upOneLayer (this .activeLayer .id )
99
+ this .setTitle ()
100
+ }
101
+ },
102
+ setTitle () {
103
+ let newTitle = ' '
104
+ this .activeLayer .lineage .forEach (el => {
105
+ newTitle += ` > ${ el} `
106
+ })
107
+ this .depth = newTitle
95
108
},
96
109
handleClick (event ) {
97
110
console .log (event .target )
@@ -102,17 +115,23 @@ export default {
102
115
},
103
116
components: {
104
117
draggable
118
+ },
119
+ watch: {
120
+ activeComponent : function () {
121
+ // console.log('watching activeComponent in HomeQueue')
122
+ if (this .activeComponent !== ' ' ) {
123
+ this .component = true
124
+ } else {
125
+ this .component = false
126
+ }
127
+ },
128
+ activeLayer : function () {
129
+ // console.log('watching activeComponent in HomeQueue')
130
+ if (this .activeLayer !== ' ' ) {
131
+ this .setTitle ()
132
+ }
133
+ }
105
134
}
106
- // watch: {
107
- // activeComponent: function () {
108
- // // console.log('watching activeComponent in HomeQueue')
109
- // if (this.activeComponent !== '') {
110
- // this.component = true
111
- // } else {
112
- // this.component = false
113
- // }
114
- // }
115
- // }
116
135
}
117
136
</script >
118
137
@@ -170,6 +189,16 @@ li {
170
189
cursor : pointer ;
171
190
color : #41 B8 83 ;
172
191
}
192
+
193
+ .fa-chevron-up {
194
+ position : relative ;
195
+ }
196
+
197
+ .fa-chevron-up :hover {
198
+ cursor : pointer ;
199
+ color : #41 B8 83 ;
200
+ }
201
+
173
202
hr {
174
203
border : 1px solid grey
175
204
}
0 commit comments