feat: add functionality to delete player
This commit is contained in:
parent
1bbaee6474
commit
f9342b94ce
@ -39,6 +39,14 @@ $button-disabled-text-color: #102028;
|
|||||||
$button-disabled-border: 4px solid transparent;
|
$button-disabled-border: 4px solid transparent;
|
||||||
$button-disabled-border-border: 4px solid #004060;
|
$button-disabled-border-border: 4px solid #004060;
|
||||||
|
|
||||||
|
$button-caution-background-color: #a04040;
|
||||||
|
$button-caution-border: 4px solid #b05050;
|
||||||
|
$button-caution-text-color: #ffffff;
|
||||||
|
|
||||||
|
$button-caution-hover-background-color: #e06060;
|
||||||
|
$button-caution-hover-border: 4px solid #f07070;
|
||||||
|
$button-caution-hover-text-color: $button-caution-text-color;
|
||||||
|
|
||||||
// Topbar
|
// Topbar
|
||||||
$topbar-background-color: #006898;
|
$topbar-background-color: #006898;
|
||||||
$topbar-separator-color: #ffffff;
|
$topbar-separator-color: #ffffff;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<button :type="type" class="button__button"
|
<button :type="type" class="button__button"
|
||||||
:class="{ 'button__button__disabled': disabled, 'button__button__border': border }">
|
:class="{ 'button__button__disabled': disabled, 'button__button__border': border, 'button__button__caution': cssClass==='caution' }">
|
||||||
<slot />
|
<slot />
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
@ -19,6 +19,10 @@ defineProps({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
cssClass: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -70,6 +74,17 @@ defineProps({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__caution {
|
||||||
|
background-color: $button-caution-background-color;
|
||||||
|
border: $button-caution-border;
|
||||||
|
color: $button-caution-text-color;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: $button-caution-hover-background-color;
|
||||||
|
border: $button-caution-hover-border;
|
||||||
|
color: $button-caution-hover-text-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
<span class="player-dialog__id" :class="{ 'player-dialog__id__show': showId }">{{ player.id }}</span>
|
<span class="player-dialog__id" :class="{ 'player-dialog__id__show': showId }">{{ player.id }}</span>
|
||||||
</div>
|
</div>
|
||||||
<template v-slot:footer>
|
<template v-slot:footer>
|
||||||
<Button v-for="button in buttons" :key="button.id" class="player-dialog__button" :border="['primary', 'caution'].indexOf(button.type) >= 0"
|
<Button v-for="button in buttons" :key="button.id" class="player-dialog__button"
|
||||||
@click="emit('submit', button.id)">{{ button.name }}</Button>
|
:css-class="button.type === 'caution' ? button.type : ''" :border="['primary', 'caution'].indexOf(button.type) >= 0"
|
||||||
|
@click="emit('submit', button.id)">{{ button.name
|
||||||
|
}}</Button>
|
||||||
</template>
|
</template>
|
||||||
</ModalDialog>
|
</ModalDialog>
|
||||||
</template>
|
</template>
|
||||||
@ -61,7 +63,7 @@ watch([props], () => { showId.value = false }) // reset visibility each time th
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__button ~ &__button {
|
&__button~&__button {
|
||||||
margin-left: 16px;
|
margin-left: 16px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,10 @@ const playerDialogSubmit = async (action: ButtonAction): Promise<void> => {
|
|||||||
emit('update')
|
emit('update')
|
||||||
break
|
break
|
||||||
case 'delete':
|
case 'delete':
|
||||||
|
if (confirm(`"${playerDialogPlayer.value.name}" löschen?`)) {
|
||||||
|
await useEngine().deletePlayer(playerDialogPlayer.value.id)
|
||||||
|
emit('update')
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,3 +71,11 @@ export async function savePlayer(this: EngineContext, player: PlayerEdit): Promi
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function deletePlayer(this: EngineContext, id: string): Promise<void> {
|
||||||
|
const userInfoStore = useUserinfoStore()
|
||||||
|
await this.callApi('/api/deletePlayer', {
|
||||||
|
g: userInfoStore.gameId,
|
||||||
|
id,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import { callApi, QueryParams } from '@/composables/engine/callApi'
|
|||||||
import { start, stop } from '@/composables/engine/startStop'
|
import { start, stop } from '@/composables/engine/startStop'
|
||||||
import { fetchUpdate } from '@/composables/engine/fetchUpdate'
|
import { fetchUpdate } from '@/composables/engine/fetchUpdate'
|
||||||
import { loadQuotes, getQuotesRef, deleteQuote, saveQuote } from '@/composables/engine/quotes'
|
import { loadQuotes, getQuotesRef, deleteQuote, saveQuote } from '@/composables/engine/quotes'
|
||||||
import { collectQuotes, startGame, continueGame, resetGame, finishGame, fetchGameInfo, setGameLang, setGameName, savePlayer } from '@/composables/engine/gamemaster'
|
import { collectQuotes, startGame, continueGame, resetGame, finishGame, fetchGameInfo, setGameLang, setGameName, savePlayer, deletePlayer } from '@/composables/engine/gamemaster'
|
||||||
import { saveSelection } from '@/composables/engine/play'
|
import { saveSelection } from '@/composables/engine/play'
|
||||||
import type { Quotes, GameInfo, PlayerEdit } from '@/composables/engine.d'
|
import type { Quotes, GameInfo, PlayerEdit } from '@/composables/engine.d'
|
||||||
|
|
||||||
@ -40,6 +40,7 @@ export interface useEngine {
|
|||||||
setGameLang: (lang: string) => Promise<void>
|
setGameLang: (lang: string) => Promise<void>
|
||||||
setGameName: (name: string) => Promise<void>
|
setGameName: (name: string) => Promise<void>
|
||||||
savePlayer: (player: PlayerEdit) => Promise<void>
|
savePlayer: (player: PlayerEdit) => Promise<void>
|
||||||
|
deletePlayer: (id: string) => Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
export default (): useEngine => {
|
export default (): useEngine => {
|
||||||
@ -77,5 +78,6 @@ export default (): useEngine => {
|
|||||||
setGameLang: (lang: string) => setGameLang.apply(context, [lang]),
|
setGameLang: (lang: string) => setGameLang.apply(context, [lang]),
|
||||||
setGameName: (name: string) => setGameName.apply(context, [name]),
|
setGameName: (name: string) => setGameName.apply(context, [name]),
|
||||||
savePlayer: (player: PlayerEdit) => savePlayer.apply(context, [player]),
|
savePlayer: (player: PlayerEdit) => savePlayer.apply(context, [player]),
|
||||||
|
deletePlayer: (id: string) => deletePlayer.apply(context, [id]),
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user