feat: enable/disable buttons according to state and phase

This commit is contained in:
Settel 2022-03-15 08:06:08 +01:00
parent c12e1d36f8
commit 0f74661e07

View File

@ -1,10 +1,10 @@
<template>
<nav v-if="isGamemaster" class="gamecontrols">
<button @click="collectQuotes">Collect Quotes</button>
<button @click="startGame">Start</button>
<button @click="continueGame">Continue</button>
<button @click="resetGame">Idle</button>
<button @click="finishGame">Finish Game</button>
<button :disabled="buttonsDisabled.collect" @click="collectQuotes">Collect Quotes</button>
<button :disabled="buttonsDisabled.start" @click="startGame">Start</button>
<button :disabled="buttonsDisabled.continue" @click="continueGame">Continue</button>
<button :disabled="buttonsDisabled.idle" @click="resetGame">Idle</button>
<button :disabled="buttonsDisabled.finish" @click="finishGame">Finish Game</button>
<button v-if="$route.path != '/play'" @click="go('/play')">switch to game</button>
<button v-if="$route.path != '/admin'" @click="go('/admin')">admin interface</button>
<button class="button-logout" @click="logout">logout</button>
@ -21,6 +21,16 @@ export default {
const user = this.$store.state.engine.user
return user && user.role === 'gamemaster'
},
buttonsDisabled() {
const { state, phase } = this.$store.state.game
return {
collect: state !== 'idle',
start: state !== 'idle',
continue: state !== 'play' && ['select-quote', 'reveal-show-count', 'reveal-source'].indexOf(phase) == -1,
idle: false,
finish: ['play', 'idle'].indexOf(state) == -1,
}
}
},
methods: {
collectQuotes() {