Bug fix on toggle all
This commit is contained in:
parent
99762dce94
commit
43f4228e19
1 changed files with 11 additions and 4 deletions
|
|
@ -380,6 +380,7 @@
|
||||||
mining: true,
|
mining: true,
|
||||||
lightning: true
|
lightning: true
|
||||||
},
|
},
|
||||||
|
oldToggleStates: {},
|
||||||
gertys: [],
|
gertys: [],
|
||||||
currencyOptions: [
|
currencyOptions: [
|
||||||
'USD',
|
'USD',
|
||||||
|
|
@ -749,15 +750,21 @@
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
toggleStates: {
|
toggleStates: {
|
||||||
handler(toggleStatesValue, oldValue) {
|
handler(toggleStatesValue) {
|
||||||
// Switch all the toggles in each section to the relevant state
|
// Switch all the toggles in each section to the relevant state
|
||||||
for (const [toggleKey, toggleValue] of Object.entries(toggleStatesValue)) {
|
for (const [toggleKey, toggleValue] of Object.entries(toggleStatesValue)) {
|
||||||
for (const [dpKey, dpValue] of Object.entries(this.formDialog.data.display_preferences)) {
|
if (this.oldToggleStates[toggleKey] !== toggleValue) {
|
||||||
if(dpKey.indexOf(toggleKey) === 0) {
|
for (const [dpKey, dpValue] of Object.entries(this.formDialog.data.display_preferences)) {
|
||||||
this.formDialog.data.display_preferences[dpKey] = toggleValue
|
if (dpKey.indexOf(toggleKey) === 0) {
|
||||||
|
this.formDialog.data.display_preferences[dpKey] = toggleValue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// This is a weird hack we have to use to get VueJS to persist the previous toggle state between
|
||||||
|
// watches. VueJS passes the old and new values by reference so when comparing objects they
|
||||||
|
// will have the same values unless we do this
|
||||||
|
this.oldToggleStates = JSON.parse(JSON.stringify(toggleStatesValue))
|
||||||
},
|
},
|
||||||
deep: true
|
deep: true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue