Fixed automated tab navs. going to the wrong tab

This commit is contained in:
Stefan Zermatten
2022-11-29 14:52:22 +02:00
parent 8551e318c2
commit da6fb55ca0
3 changed files with 28 additions and 15 deletions

View File

@@ -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({

View File

@@ -195,7 +195,7 @@ export default {
} else {
this.$store.commit(
'setTabForCharacterSheet',
{id: creatureId, tab: 5}
{id: creatureId, tab: 'build'}
);
this.$emit('pop', creatureId);
defer(() => {

View File

@@ -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) {