Fix: Tabs and tab headers no longer lose sync when changing characters

This commit is contained in:
Stefan Zermatten
2021-01-28 16:17:03 +02:00
parent d596061fa8
commit db83d5f82a
3 changed files with 12 additions and 2 deletions

View File

@@ -35,7 +35,7 @@
class="fill-height" class="fill-height"
> >
<v-tabs-items <v-tabs-items
:value="$store.state.characterSheetTabs[$route.params.id]" :value="$store.getters.tabById($route.params.id)"
@change="e => $store.commit( @change="e => $store.commit(
'setTabForCharacterSheet', 'setTabForCharacterSheet',
{id: $route.params.id, tab: e} {id: $route.params.id, tab: e}

View File

@@ -81,7 +81,7 @@
centered centered
grow grow
max="100px" max="100px"
:value="$store.state.characterSheetTabs[$route.params.id]" :value="$store.getters.tabById($route.params.id)"
@change="e => $store.commit( @change="e => $store.commit(
'setTabForCharacterSheet', 'setTabForCharacterSheet',
{id: $route.params.id, tab: e} {id: $route.params.id, tab: e}

View File

@@ -17,6 +17,16 @@ const store = new Vuex.Store({
characterSheetTabs: {}, characterSheetTabs: {},
showBuildDialog: false, showBuildDialog: false,
}, },
getters: {
// ...
tabById: (state) => (id) => {
if (id in state.characterSheetTabs){
return state.characterSheetTabs[id];
} else {
return 0;
}
}
},
mutations: { mutations: {
toggleDrawer (state) { toggleDrawer (state) {
state.drawer = !state.drawer; state.drawer = !state.drawer;