feat: admin interface: open player edit overlay

This commit is contained in:
Settel 2022-03-01 22:08:07 +01:00
parent 1e64c27918
commit 2b10149a87
5 changed files with 141 additions and 19 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="collect-quotes-explain"> <div class="collect-quotes-explain">
<div class="collect-quotes-explain__container"> <Infobox>
<div class="collect-quotes-explain__open-close-toggle" @click="toggleOpenClose"> <div class="collect-quotes-explain__open-close-toggle" @click="toggleOpenClose">
<span v-if="explainOpen">X</span> <span v-if="explainOpen">X</span>
<span v-else>&gt;</span> <span v-else>&gt;</span>
@ -34,7 +34,7 @@
</transition> </transition>
</div> </div>
</div> </div>
</div> </Infobox>
</div> </div>
</template> </template>
@ -84,14 +84,6 @@ export default {
@import '~/assets/css/components'; @import '~/assets/css/components';
.collect-quotes-explain { .collect-quotes-explain {
&__container {
margin: 20px 80px;
padding: 0 40px;
border: 1px solid white;
border-radius: 20px;
background-color: $primary-box-background-color;
}
&__open-close-toggle { &__open-close-toggle {
float: right; float: right;
margin: 16px -16px 16px 16px; margin: 16px -16px 16px 16px;

View File

@ -0,0 +1,26 @@
<template>
<div class="infobox">
<div class="infobox__container">
<slot />
</div>
</div>
</template>
<script>
export default {
}
</script>
<style lang="scss">
@import '~/assets/css/components';
.infobox {
&__container {
margin: 20px 80px;
padding: 0 40px;
border: 1px solid white;
border-radius: 20px;
background-color: $primary-box-background-color;
}
}
</style>

View File

@ -0,0 +1,53 @@
<template>
<div class="admin-edit-player">
<Infobox>
<div class="admin-edit-player__close" @click="$emit('close')" />
<h1>ooookay!</h1>
<table>
<tr>
<td>Name: </td>
<td>{{ player.name }}</td>
</tr>
<tr>
<td>Score: </td>
<td>{{ player.score }}</td>
</tr>
<tr>
<td>Authcode: </td>
<td>{{ player.authcode }}</td>
</tr>
</table>
</Infobox>
</div>
</template>
<script>
export default {
props: ['player'],
}
</script>
<style lang="scss">
@import '~/assets/css/components';
.admin-edit-player {
&__close {
float: right;
margin: 16px -16px 16px 16px;
padding: 12px;
border: 1px solid #ffffff;
border-radius: 8px;
background-color: $primary-background-color;
font-family: "Wendy One";
color: #ffffff;
cursor: pointer;
&:hover {
background-color: $primary-box-background-color;
}
&::after {
content: 'x';
}
}
}
</style>

View File

@ -7,7 +7,7 @@
<th class="admin-tile-players__table-head">Score</th> <th class="admin-tile-players__table-head">Score</th>
<th class="admin-tile-players__table-head">Status</th> <th class="admin-tile-players__table-head">Status</th>
</tr> </tr>
<tr class="admin-tile-players__player" @click="editPlayer(player.id)" v-for="player in players" :key="player.id"> <tr class="admin-tile-players__player" @click="editPlayer(player)" v-for="player in players" :key="player.id">
<td>{{ player.name }}</td> <td>{{ player.name }}</td>
<td>{{ player.numQuotes }}</td> <td>{{ player.numQuotes }}</td>
<td>{{ player.score }}</td> <td>{{ player.score }}</td>
@ -26,11 +26,11 @@
export default { export default {
props: ['gameinfo', 'players'], props: ['gameinfo', 'players'],
methods: { methods: {
editPlayer(id) { editPlayer(player) {
alert(id) this.$emit('edit', player)
}, },
newPlayer() { newPlayer() {
alert('new') this.$emit('edit', {})
}, },
}, },
} }

View File

@ -5,10 +5,15 @@
</template> </template>
<template v-if="isGamemasterOrAdmin"> <template v-if="isGamemasterOrAdmin">
<GameControls /> <GameControls />
<div class="page-admin__tiles"> <div class="page-admin__body">
<AdminTileMyself :user="user" /> <div v-if="overlay.open" class="page-admin__player-overlay">
<AdminTileGameinfo :gameinfo="gameinfo" :players="players" /> <AdminEditPlayer :player="overlay.player" @close="overlay.open=false"/>
<AdminTilePlayers :gameinfo="gameinfo" :players="players" /> </div>
<div class="page-admin__tiles">
<AdminTileMyself :user="user" />
<AdminTileGameinfo :gameinfo="gameinfo" :players="players" />
<AdminTilePlayers :gameinfo="gameinfo" :players="players" @edit="editPlayer" />
</div>
</div> </div>
</template> </template>
</div> </div>
@ -20,6 +25,13 @@ export default {
await this.$engine.fetchUserInfo() await this.$engine.fetchUserInfo()
await this.$engine.fetchGameInfo({ g: this.$store.state.engine.user.game }) await this.$engine.fetchGameInfo({ g: this.$store.state.engine.user.game })
}, },
data() {
return {
overlay: {
open: false,
},
}
},
computed: { computed: {
isGamemasterOrAdmin() { isGamemasterOrAdmin() {
const user = this.$store.state.engine.user const user = this.$store.state.engine.user
@ -37,16 +49,55 @@ export default {
return players.sort((a, b) => { return a.name.localeCompare(b.name) }) return players.sort((a, b) => { return a.name.localeCompare(b.name) })
}, },
}, },
methods: {
editPlayer(player) {
this.overlay.open = true
this.overlay.player = player
},
},
} }
</script> </script>
<style lang="scss"> <style lang="scss">
@import '~/assets/css/components';
.page-admin { .page-admin {
color: #ffffff; color: #ffffff;
width: 100%;
height: 100%;
&__body {
position: relative;
}
&__tiles { &__tiles {
display: flex; display: flex;
margin: 24px; padding: 24px;
}
&__player-overlay {
position: absolute;
left: 10%;
top: 10%;
width: 80%;
}
&__player-overlay-close {
float: right;
margin: 16px -16px 16px 16px;
padding: 12px;
border: 1px solid #ffffff;
border-radius: 8px;
background-color: $primary-background-color;
font-family: "Wendy One";
color: #ffffff;
cursor: pointer;
&:hover {
background-color: $primary-box-background-color;
}
&::after {
content: 'x';
}
} }
} }
</style> </style>