Skip to content

Commit 79c0c54

Browse files
committed
nesting one layer up and down working
1 parent 48f5be2 commit 79c0c54

File tree

1 file changed

+53
-24
lines changed

1 file changed

+53
-24
lines changed

src/components/HomeQueue.vue

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<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>
55
<span class='list-title' v-else-if='this.activeComponent !==""'> Viewing Elements in '{{ this.activeComponent }}' </span>
66
<span class='list-title' v-else> Elements in Queue </span>
77
<hr>
@@ -13,10 +13,10 @@
1313
@start="drag = true"
1414
@end="drag = false"
1515
>
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()">
1717
<i class="fas fa fa-angle-double-down fa-md" @click="setLayer({text: element[0], id: element[2]})"></i>
1818
{{ 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>
2020
</div>
2121
</draggable>
2222
</section>
@@ -25,7 +25,7 @@
2525
<script>
2626
import draggable from 'vuedraggable'
2727
import { mapState, mapActions } from 'vuex'
28-
import { setSelectedElementList, deleteSelectedElement, deleteFromComponentHtmlList, setActiveHTML, setActiveLayer } from '../store/types'
28+
import { setSelectedElementList, deleteSelectedElement, deleteFromComponentHtmlList } from '../store/types'
2929
3030
const breadthFirstSearch = (array, id) => {
3131
let queue = [...array.filter(el => typeof el === 'object')]
@@ -52,19 +52,18 @@ export default {
5252
type: Array
5353
}
5454
},
55-
// data () {
56-
// return {
57-
// //component: false
58-
// }
59-
// },
55+
data () {
56+
return {
57+
depth: ''
58+
}
59+
},
6060
computed: {
6161
...mapState(['selectedElementList', 'componentMap', 'activeComponent', 'activeHTML', 'activeLayer']),
6262
renderList: {
6363
get () {
6464
if (this.activeComponent === '') return this.selectedElementList.map((el, index) => [el.text, index, el.id])
6565
// change activeComponent's htmlList into an array of arrays ([element/component name, index in state])
6666
if (this.activeComponent !== '' && this.activeLayer.id === '') {
67-
console.log('this works right?')
6867
let sortedHTML = this.componentMap[this.activeComponent].htmlList.map((el, index) => [el.text, index, el.id]).filter(el => {
6968
return el[0] !== undefined
7069
})
@@ -82,16 +81,30 @@ export default {
8281
}
8382
},
8483
methods: {
85-
...mapActions(['setActiveHTML', 'setActiveLayer']),
84+
...mapActions(['setActiveHTML', 'setActiveLayer', 'upOneLayer']),
8685
deleteElement (index) {
8786
if (this.activeComponent === '') this.$store.dispatch(deleteSelectedElement, index)
8887
else this.$store.dispatch(deleteFromComponentHtmlList, index)
8988
},
9089
setActiveElement (element) {
91-
this.$store.dispatch(setActiveHTML, element)
90+
this.setActiveHTML(element)
9291
},
9392
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
95108
},
96109
handleClick (event) {
97110
console.log(event.target)
@@ -102,17 +115,23 @@ export default {
102115
},
103116
components: {
104117
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+
}
105134
}
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-
// }
116135
}
117136
</script>
118137

@@ -170,6 +189,16 @@ li {
170189
cursor: pointer;
171190
color: #41B883;
172191
}
192+
193+
.fa-chevron-up {
194+
position: relative;
195+
}
196+
197+
.fa-chevron-up:hover {
198+
cursor: pointer;
199+
color: #41B883;
200+
}
201+
173202
hr {
174203
border: 1px solid grey
175204
}

0 commit comments

Comments
 (0)