Skip to content

Commit

Permalink
comment update for edit chart labels, vuex
Browse files Browse the repository at this point in the history
  • Loading branch information
solderq35 committed Dec 19, 2023
1 parent 590c23d commit 1ac2954
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/components/view/modals/edit_card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ export default {
const chartPath = charts[index].path
this.$store.dispatch(chartPath + '/update', this.form.sets[index])
// update legend name
// line below is what "resets" the chart name, maybe comment it out but needs more testing
this.$store.commit(chartPath + '/name', this.$store.getters[chartPath + '/pointString'])
} else {
this.$store.dispatch(blockPath + '/newChart', this.form.sets[index])
Expand Down
14 changes: 9 additions & 5 deletions src/components/view/view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,20 @@ export default {
console.log(buildings.map(building => building.id))
await this.$store.dispatch(this.cards[0].path + '/removeAllModifiers')
// addModifier and updateModifier below call block.module.js, which then calls building_compare.mod.js
// See addModifier and updateModifier functions in block.module.js
// See addCharts and RemoveOldCharts in building_compare.mod.js
await this.$store.dispatch(this.cards[0].path + '/addModifier', 'building_compare')
// buildingIds below defines which buildingId are sent to block.module.js and then building_compare.mod.js,
// which also affects chartSpace naming (duplicate chart path triggers error)
// Full call order: view.vue's compareBuildings() > block.module.js's updateModifier >
// building_compare.mod.js's updateData() > building_compare.mod.js's addCharts() > block.module.js's loadCharts()
// Alternatively (building_compare_mod.js's updateData calls two things):
// view.vue's compareBuildings() > block.module.js's updateModifier > building_compare.mod.js's updateData() >
// building_compare.mod.js's removeOldCharts() > block.module.js's unloadChart()
await this.$store.dispatch(this.cards[0].path + '/updateModifier', {
name: 'building_compare',
data: {
// buildingIds below defines which buildingId are sent to block.module.js and then building_compare.mod.js,
// which also affects chartSpace naming (duplicate chart path triggers error)
buildingIds: buildings.map(building => building.id)
}
})
Expand Down Expand Up @@ -122,7 +127,6 @@ export default {
}
} else {
for (let card of this.cards) {
console.log(card)
if (!card.path) return
this.$nextTick(() => {
console.log(card)
Expand Down
10 changes: 10 additions & 0 deletions src/store/block.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ const actions = {
throw new Error('Modifier not found on block')
} else {
const updatingMod = store.getters.modifiers[modIndex]

// I think this calls building_compare.mod.js's updateData function
await updatingMod.updateData(this, store, payload.data)
}
},
Expand All @@ -115,6 +117,14 @@ const actions = {
)
await this.getters['map/promise']
await this.getters['map/allBuildingPromise']
console.log(chartSpace)
// Example chartSpace: chart_29
// As a generalization, the first part of whatever is the input of store.commit determines where it goes. Check src/store
// Example: store.commit('chart_<something>`) will go to src\store\chart.module.js,

Check failure on line 123 in src/store/block.module.js

View workflow job for this annotation

GitHub Actions / Build / Deploy to S3 Test Build

Trailing spaces not allowed
// store.commit('map/<something>') will go to src\store\map.module.js

Check failure on line 125 in src/store/block.module.js

View workflow job for this annotation

GitHub Actions / Build / Deploy to S3 Test Build

Trailing spaces not allowed
// Example: store.commit(chartSpace/building) > search "buildings" in "mutations" section (I think), in chart.module file
// Mutations = change store value, getters = retrieve value. https://vuex.vuejs.org/guide/mutations
store.commit(chartSpace + '/building', this.getters['map/meterGroup'](chart.meters).building)
store.commit(chartSpace + '/meterGroupPath', this.getters['map/meterGroup'](chart.meters).path)
store.commit(chartSpace + '/promise', Promise.resolve())
Expand Down
3 changes: 3 additions & 0 deletions src/store/block_modifiers/building_compare.mod.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export default class CompareModifier {
await this.removeOldCharts(store, module, this.data.buildingIds)
}

// I *think* updateModifier function from block.module.js lands here, not sure.
// updateData function below calls addCharts and removeOldCharts
async updateData (store, mod, data) {
/*
Function is called when a block
Expand Down Expand Up @@ -90,6 +92,7 @@ export default class CompareModifier {
})
}
}
// block.module.js loadCharts function is called here
await store.dispatch(mod.getters.path + '/loadCharts', charts)
}

Expand Down

0 comments on commit 1ac2954

Please sign in to comment.