From da6fb55ca0e01f085eb43ee0282ba5bec7295da6 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Tue, 29 Nov 2022 14:52:22 +0200 Subject: [PATCH] Fixed automated tab navs. going to the wrong tab --- .../client/ui/creature/CreatureForm.vue | 28 +++++++++---------- .../character/CharacterCreationDialog.vue | 2 +- app/imports/client/ui/vuexStore.js | 13 +++++++++ 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/app/imports/client/ui/creature/CreatureForm.vue b/app/imports/client/ui/creature/CreatureForm.vue index d0752e73..65d1b6e6 100644 --- a/app/imports/client/ui/creature/CreatureForm.vue +++ b/app/imports/client/ui/creature/CreatureForm.vue @@ -218,30 +218,30 @@ export default { }, methods: { changeShowTreeTab(value) { + let currentTab = this.$store.getters.tabNameById(this.model._id); + if (!value && currentTab === 'tree') { + this.$store.commit( + 'setTabForCharacterSheet', + { id: this.model._id, tab: 'build' } + ); + } this.$emit('change', { path: ['settings', 'showTreeTab'], value: !!value }); - let currentTab = this.$store.getters.tabById(this.model._id); - if (!value && currentTab === 5) { - this.$store.commit( - 'setTabForCharacterSheet', - { id: this.model._id, tab: 4 } - ); - } }, changeHideSpellsTab(value) { + let currentTab = this.$store.getters.tabNameById(this.model._id); + if (!value && currentTab === 'spells') { + this.$store.commit( + 'setTabForCharacterSheet', + { id: this.model._id, tab: 'actions' } + ); + } this.$emit('change', { path: ['settings', 'hideSpellsTab'], value: !value }); - let currentTab = this.$store.getters.tabById(this.model._id); - if (!value && currentTab === 3) { - this.$store.commit( - 'setTabForCharacterSheet', - { id: this.model._id, tab: 4 } - ); - } }, allUserLibrariesChange(value, ack) { toggleAllUserLibraries.call({ diff --git a/app/imports/client/ui/creature/character/CharacterCreationDialog.vue b/app/imports/client/ui/creature/character/CharacterCreationDialog.vue index 001f8a64..e18cfc38 100644 --- a/app/imports/client/ui/creature/character/CharacterCreationDialog.vue +++ b/app/imports/client/ui/creature/character/CharacterCreationDialog.vue @@ -195,7 +195,7 @@ export default { } else { this.$store.commit( 'setTabForCharacterSheet', - {id: creatureId, tab: 5} + {id: creatureId, tab: 'build'} ); this.$emit('pop', creatureId); defer(() => { diff --git a/app/imports/client/ui/vuexStore.js b/app/imports/client/ui/vuexStore.js index 87010418..d4578aa0 100644 --- a/app/imports/client/ui/vuexStore.js +++ b/app/imports/client/ui/vuexStore.js @@ -50,6 +50,19 @@ const store = new Vuex.Store({ document.title = value; }, setTabForCharacterSheet(state, { tab, id }) { + // Convert tab names to tab numbers + if (typeof tab === 'string') { + const creature = Creatures.findOne(id); + if (creature?.settings?.hideSpellsTab) { + tab = tabsWithoutSpells.indexOf(tab); + } else { + tab = tabs.indexOf(tab); + } + if (!(tab > -1)) { + throw 'Could not find requested tab'; + } + console.log('resolved: ', tab); + } Vue.set(state.characterSheetTabs, id, tab); }, setShowDetailsDialog(state, value) {