Skip to content

Commit

Permalink
fix compare menu prompt and sideView, rename chart function
Browse files Browse the repository at this point in the history
  • Loading branch information
solderq35 committed Dec 30, 2023
1 parent e07fc50 commit 4cdfddc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 44 deletions.
6 changes: 3 additions & 3 deletions src/components/map/map_prompt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="q">Quick Compare</el-dropdown-item>
<el-dropdown-item command="d">Compare in FullScreen</el-dropdown-item>
<el-dropdown-item v-if="compareStories && compareStories.length < 2" command="t"
>Compare Multiple Time Periods</el-dropdown-item
>
<el-dropdown-item v-if="compareStories && compareStories.length <= 2" command="t"
>Compare Multiple Time Periods
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<el-button class="button" type="info" @click="$emit('cancel')">Cancel</el-button>
Expand Down
6 changes: 6 additions & 0 deletions src/components/map/sideView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
61 changes: 22 additions & 39 deletions src/components/view/view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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])
})
}
}
},
Expand Down Expand Up @@ -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])
})
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/store/chart.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
Expand All @@ -244,7 +244,7 @@ const mutations = {
}
},

clearAndSetMultEnd (state, payload) {
resetMultEnd (state, payload) {
state.multEnd = []
state.multEnd.push(...payload)
}
Expand Down

0 comments on commit 4cdfddc

Please sign in to comment.