Skip to content

Commit 7b6462a

Browse files
committed
Left side shows stuff!
1 parent b55451a commit 7b6462a

File tree

3 files changed

+92
-3
lines changed

3 files changed

+92
-3
lines changed

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ let redoMixin = {
6666
if (event.ctrlKey && event.key === 'a') {
6767
event.preventDefault()
6868
if (this.$store.state.activeHTML !== '') {
69-
this.$store.dispatch('setActiveLayer', this.$store.state.activeHTML)
69+
this.$store.dispatch('setActiveLayer', {id:this.$store.state.activeHTML, text:"banana"})
7070
}
7171
}
7272
});

src/components/CreateComponent.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import Icons from './Icons'
3939
import ParentMultiselect from '../components/ParentMultiselect'
4040
import { mapState, mapActions } from 'vuex'
4141
42+
4243
export default {
4344
name: 'HomeSidebar',
4445
components: {

src/components/Icons.vue

Lines changed: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,21 @@
1717

1818
<script>
1919
import { mapState } from 'vuex'
20-
20+
const breadthFirstSearch = (array,id) => {
21+
let queue = [...array.filter(el => typeof el === 'object')];
22+
while(queue.length){
23+
let evaluated = queue.shift()
24+
if(evaluated.id === id){
25+
return evaluated
26+
}
27+
else{
28+
if (evaluated.children.length){
29+
queue.push(...evaluated.children)
30+
}
31+
}
32+
}
33+
console.log("We shouldn't be ever getting here, how did you even search an id that didn't exist?")
34+
}
2135
export default {
2236
data () {
2337
return {
@@ -58,7 +72,27 @@ export default {
5872
}
5973
// console.log('storage is ', this.elementStorage)
6074
},
75+
activeLayer: {
76+
deep: true,
77+
handler(){
78+
if (this.activeComponent)
79+
{
80+
this.elementStorage = {};
81+
if (this.activeLayer.id !== '' && this.activeHTML === '') {
82+
let activeLayerObj = breadthFirstSearch(this.componentMap[this.activeComponent].htmlList, this.activeLayer.id)
83+
activeLayerObj.children.forEach(el => {
84+
if (!this.elementStorage[el.text]) {
85+
this.elementStorage[el.text] = 1;
86+
} else {
87+
this.elementStorage[el.text] += 1;
88+
}
89+
})
90+
}
91+
}
92+
}
93+
},
6194
// if componentMap is updated (i.e. element is added to component's htmlList), elementStorage will update its cache of elements & frequency
95+
6296
componentMap: {
6397
deep: true,
6498
handler () {
@@ -67,17 +101,71 @@ export default {
67101
// console.log('htmlList', this.componentMap[this.activeComponent].htmlList)
68102
if (this.activeComponent) {
69103
this.elementStorage = {};
70-
this.componentMap[this.activeComponent].htmlList.forEach(el => {
104+
if (this.activeLayer.id !== '' && this.activeHTML === '') {
105+
let activeLayerObj = breadthFirstSearch(this.componentMap[this.activeComponent].htmlList, this.activeLayer.id)
106+
activeLayerObj.children.forEach(el => {
71107
if (!this.elementStorage[el.text]) {
72108
this.elementStorage[el.text] = 1;
73109
} else {
74110
this.elementStorage[el.text] += 1;
75111
}
76112
})
113+
} else if(this.activeHTML !== ''){
114+
let activeHtmlObj = breadthFirstSearch(this.componentMap[this.activeComponent].htmlList, this.activeHTML)
115+
activeHtmlObj.children.forEach(el => {
116+
if (!this.elementStorage[el.text]) {
117+
this.elementStorage[el.text] = 1;
118+
} else {
119+
this.elementStorage[el.text] += 1;
120+
}
121+
})
122+
} else {
123+
this.componentMap[this.activeComponent].htmlList.forEach(el => {
124+
if (!this.elementStorage[el.text]) {
125+
this.elementStorage[el.text] = 1;
126+
} else {
127+
this.elementStorage[el.text] += 1;
128+
}
129+
})
130+
}
77131
// console.log('elementStorage is ', this.elementStorage);
78132
}
79133
},
80134
},
135+
136+
activeHTML: function() {
137+
this.elementStorage = {};
138+
if (this.activeHTML!== ''){
139+
let activeHtmlObj = breadthFirstSearch(this.componentMap[this.activeComponent].htmlList, this.activeHTML)
140+
activeHtmlObj.children.forEach(el => {
141+
if (!this.elementStorage[el.text]) {
142+
this.elementStorage[el.text] = 1;
143+
} else {
144+
this.elementStorage[el.text] += 1;
145+
}
146+
})
147+
}
148+
else{
149+
if (this.activeLayer.id !== '' && this.activeHTML === '') {
150+
let activeLayerObj = breadthFirstSearch(this.componentMap[this.activeComponent].htmlList, this.activeLayer.id)
151+
activeLayerObj.children.forEach(el => {
152+
if (!this.elementStorage[el.text]) {
153+
this.elementStorage[el.text] = 1;
154+
} else {
155+
this.elementStorage[el.text] += 1;
156+
}
157+
})
158+
} else {
159+
this.componentMap[this.activeComponent].htmlList.forEach(el => {
160+
if (!this.elementStorage[el.text]) {
161+
this.elementStorage[el.text] = 1;
162+
} else {
163+
this.elementStorage[el.text] += 1;
164+
}
165+
})
166+
}
167+
}
168+
},
81169
// if activeComponent is updated, elementStorage will update its cache of elements & frequency to reflect new active component
82170
activeComponent: function() {
83171
// console.log('watching activeComponent', this.activeComponent);

0 commit comments

Comments
 (0)