From 4cdfddc36f015bc898a96cf2370b4c0bd25f1934 Mon Sep 17 00:00:00 2001 From: solderq35 Date: Sat, 30 Dec 2023 13:52:00 -0800 Subject: [PATCH] fix compare menu prompt and sideView, rename chart function --- src/components/map/map_prompt.vue | 6 +-- src/components/map/sideView.vue | 6 +++ src/components/view/view.vue | 61 +++++++++++-------------------- src/store/chart.module.js | 4 +- 4 files changed, 33 insertions(+), 44 deletions(-) diff --git a/src/components/map/map_prompt.vue b/src/components/map/map_prompt.vue index 2f5c3712..e07ee39e 100644 --- a/src/components/map/map_prompt.vue +++ b/src/components/map/map_prompt.vue @@ -23,9 +23,9 @@ Quick Compare Compare in FullScreen - Compare Multiple Time Periods + Compare Multiple Time Periods + Cancel diff --git a/src/components/map/sideView.vue b/src/components/map/sideView.vue index f23d41fc..8e9fa5ed 100644 --- a/src/components/map/sideView.vue +++ b/src/components/map/sideView.vue @@ -133,6 +133,12 @@ export default { this.index = 0 for (let block of this.buildingBlocks) { await this.$store.dispatch(block.path + '/resetDefault') + let blockpath = block.path + let searchTerm = 'block_' + let chartIndex = blockpath.indexOf(searchTerm) + let blockID = blockpath.slice(chartIndex + searchTerm.length) + this.$store.commit(blockpath + '/chart_' + blockID + '/resetMultStart', [this.dateStart]) + this.$store.commit(blockpath + '/chart_' + blockID + '/resetMultEnd', [this.dateEnd]) } this.$refs.prevArrow.style.display = 'none' if (this.buildingBlocks.length > 1) { diff --git a/src/components/view/view.vue b/src/components/view/view.vue index 5832841e..bb2ae560 100644 --- a/src/components/view/view.vue +++ b/src/components/view/view.vue @@ -86,25 +86,17 @@ export default { this.$store.commit(card.path + '/intervalUnit', this.intervalUnit) } } - if (this.$route.path.includes('compare')) { - // Reset multStart and multEnd variables whenever you are on a comparison page for just 1 building - let buildingComparisonNumber = JSON.parse(decodeURI(this.$route.params.buildings)).length - console.log(buildingComparisonNumber) - if (buildingComparisonNumber === 1) { - for (let card of this.cards) { - if (!card.path) return - this.$nextTick(() => { - let blockpath = this.cards[0].path - let searchTerm = 'block_' - let chartIndex = blockpath.indexOf(searchTerm) - // console.log(blockpath.slice(chartIndex + searchTerm.length)) - let blockID = blockpath.slice(chartIndex + searchTerm.length) - // console.log(blockpath + '/chart_' + blockID + '/multStart') - this.$store.commit(blockpath + '/chart_' + blockID + '/clearAndSetMultStart', [this.dateStart]) - this.$store.commit(blockpath + '/chart_' + blockID + '/clearAndSetMultEnd', [this.dateEnd]) - }) - } - } + // Reset multStart and multEnd variables whenever you change pages + for (let card of this.cards) { + if (!card.path) return + this.$nextTick(() => { + let blockpath = this.cards[0].path + let searchTerm = 'block_' + let chartIndex = blockpath.indexOf(searchTerm) + let blockID = blockpath.slice(chartIndex + searchTerm.length) + this.$store.commit(blockpath + '/chart_' + blockID + '/resetMultStart', [this.dateStart]) + this.$store.commit(blockpath + '/chart_' + blockID + '/resetMultEnd', [this.dateEnd]) + }) } } }, @@ -173,26 +165,17 @@ export default { this.$store.commit(card.path + '/intervalUnit', this.intervalUnit) }) } - if (this.$route.path.includes('compare')) { - // Reset multStart and multEnd variables whenever you are on a comparison page for just 1 building - let buildingComparisonNumber = JSON.parse(decodeURI(this.$route.params.buildings)).length - console.log(buildingComparisonNumber) - if (buildingComparisonNumber === 1) { - for (let card of this.cards) { - if (!card.path) return - this.$nextTick(() => { - let blockpath = this.cards[0].path - let searchTerm = 'block_' - let chartIndex = blockpath.indexOf(searchTerm) - // console.log(blockpath.slice(chartIndex + searchTerm.length)) - let blockID = blockpath.slice(chartIndex + searchTerm.length) - // console.log(blockpath + '/chart_' + blockID + '/multStart') - this.$store.commit(blockpath + '/chart_' + blockID + '/clearAndSetMultStart', [this.dateStart]) - this.$store.commit(blockpath + '/chart_' + blockID + '/clearAndSetMultEnd', [this.dateEnd]) - // console.log(this.$store.getters) - }) - } - } + // Reset multStart and multEnd variables whenever you change pages + for (let card of this.cards) { + if (!card.path) return + this.$nextTick(() => { + let blockpath = this.cards[0].path + let searchTerm = 'block_' + let chartIndex = blockpath.indexOf(searchTerm) + let blockID = blockpath.slice(chartIndex + searchTerm.length) + this.$store.commit(blockpath + '/chart_' + blockID + '/resetMultStart', [this.dateStart]) + this.$store.commit(blockpath + '/chart_' + blockID + '/resetMultEnd', [this.dateEnd]) + }) } } } diff --git a/src/store/chart.module.js b/src/store/chart.module.js index e99b98a9..b28d0f04 100644 --- a/src/store/chart.module.js +++ b/src/store/chart.module.js @@ -225,7 +225,7 @@ const mutations = { // Function to remove all elements from VueX state array and insert a placeholder value // You only need a mutation for this when you are dealing with global state (state.commit, this.store.getters, etc) - clearAndSetMultStart (state, payload) { + resetMultStart (state, payload) { state.multStart = [] state.multStart.push(...payload) }, @@ -244,7 +244,7 @@ const mutations = { } }, - clearAndSetMultEnd (state, payload) { + resetMultEnd (state, payload) { state.multEnd = [] state.multEnd.push(...payload) }