From 1ac2954aacb208f02743410f3cf9b079f6f01eff Mon Sep 17 00:00:00 2001 From: solderq35 Date: Tue, 19 Dec 2023 13:32:36 -0800 Subject: [PATCH] comment update for edit chart labels, vuex --- src/components/view/modals/edit_card.vue | 1 + src/components/view/view.vue | 14 +++++++++----- src/store/block.module.js | 10 ++++++++++ src/store/block_modifiers/building_compare.mod.js | 3 +++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/components/view/modals/edit_card.vue b/src/components/view/modals/edit_card.vue index 3b4350f6..fb281008 100644 --- a/src/components/view/modals/edit_card.vue +++ b/src/components/view/modals/edit_card.vue @@ -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]) diff --git a/src/components/view/view.vue b/src/components/view/view.vue index ca677255..6cbb8d4a 100644 --- a/src/components/view/view.vue +++ b/src/components/view/view.vue @@ -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) } }) @@ -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) diff --git a/src/store/block.module.js b/src/store/block.module.js index 1f11a3f9..eaaae0a3 100644 --- a/src/store/block.module.js +++ b/src/store/block.module.js @@ -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) } }, @@ -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_`) will go to src\store\chart.module.js, + // store.commit('map/') will go to src\store\map.module.js + + // 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()) diff --git a/src/store/block_modifiers/building_compare.mod.js b/src/store/block_modifiers/building_compare.mod.js index 091f71c6..8148f54b 100644 --- a/src/store/block_modifiers/building_compare.mod.js +++ b/src/store/block_modifiers/building_compare.mod.js @@ -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 @@ -90,6 +92,7 @@ export default class CompareModifier { }) } } + // block.module.js loadCharts function is called here await store.dispatch(mod.getters.path + '/loadCharts', charts) }