Skip to content

Commit ebe5f58

Browse files
committed
Htmlelements now have a unique id
1 parent 681c2bf commit ebe5f58

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

src/components/HomeQueue.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default {
4444
...mapState(['selectedElementList', 'componentMap', 'activeComponent']),
4545
renderList: {
4646
get () {
47-
if (this.activeComponent === '') return this.selectedElementList
47+
if (this.activeComponent === '') return this.selectedElementList.map((el,index) => [el.text, index])
4848
// change activeComponent's htmlList into an array of arrays ([element/component name, index in state])
4949
let sortedHTML = this.componentMap[this.activeComponent].htmlList.map((el, index) => [el.text, index]).filter(el => {
5050
return el[0] !== undefined

src/components/Icons.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export default {
3030
},
3131
methods: {
3232
changeState (elementName) {
33-
if (this.activeComponent === '') { this.$emit('getClickedIcon', elementName) } else this.$emit('activeElement', elementName)
33+
if (this.activeComponent === '') { this.$emit('getClickedIcon', {elementName, date:Date.now()}) }
34+
else this.$emit('activeElement', {elementName,date:Date.now()})
3435
}
3536
},
3637
watch: {

src/store/mutations.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,20 @@ const mutations = {
134134
// adds a html tag from the Icons.vue to the HomeQueue.vue
135135
// event: getClickedIcon @Icons.vue
136136
[types.ADD_TO_SELECTED_ELEMENT_LIST]: (state, payload) => {
137-
state.selectedElementList.push({ text: payload, children: [] })
137+
state.selectedElementList.push({ text: payload.elementName, id: payload.date, children: [] })
138138
},
139139
// allows user to create a new component in ComponentDisplay.vue
140140
// invovled in creating a new component, porbably does more
141141
[types.SET_SELECTED_ELEMENT_LIST]: (state, payload) => {
142142
state.selectedElementList = payload
143143
},
144-
[types.ADD_TO_COMPONENT_HTML_LIST]: (state, elementName) => {
144+
[types.ADD_TO_COMPONENT_HTML_LIST]: (state, payload) => {
145145
const componentName = state.activeComponent
146146

147147
state.componentMap[componentName] = {...state.componentMap[componentName]}
148148
state.componentMap[componentName].htmlList.push({
149-
text: elementName,
149+
text: payload.elementName,
150+
id: payload.date,
150151
children: []
151152
})
152153
},

src/store/state/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ let hardA = {
1313
children:[{
1414
children:[{
1515
text: 'button',
16-
children:[]
16+
children:[],
17+
id:0
1718
}],
18-
text:'form'
19+
text:'form',
20+
id:2
1921
}],
20-
text: "div"
22+
text: "div",
23+
id:1
2124
}],
2225
children: [],
2326
parent: {},

0 commit comments

Comments
 (0)