townsquare/src/components/modals/VoteHistoryModal.vue

181 lines
3.6 KiB
Vue
Raw Normal View History

2020-12-06 21:27:52 +00:00
<template>
<Modal
class="vote-history"
2021-05-05 06:58:13 +00:00
v-if="modals.voteHistory && (session.voteHistory || !session.isSpectator)"
2020-12-06 21:27:52 +00:00
@close="toggleModal('voteHistory')"
>
<font-awesome-icon
@click="clearVoteHistory"
2020-12-06 21:27:52 +00:00
icon="trash-alt"
class="clear"
2021-05-05 19:06:23 +00:00
title="Clear vote history"
2021-05-05 06:58:13 +00:00
v-if="session.isSpectator"
2020-12-06 21:27:52 +00:00
/>
2021-05-05 19:06:23 +00:00
<h3>Vote history</h3>
2021-05-05 06:58:13 +00:00
<template v-if="!session.isSpectator">
2021-05-05 19:06:23 +00:00
<div class="options">
<div class="option" @click="setRecordVoteHistory">
<font-awesome-icon
:icon="[
'fas',
session.isVoteHistoryAllowed ? 'check-square' : 'square'
]"
/>
Accessible to players
</div>
<div class="option" @click="clearVoteHistory">
<font-awesome-icon icon="trash-alt" />
Clear for everyone
</div>
</div>
2021-05-05 06:58:13 +00:00
</template>
2020-12-06 21:27:52 +00:00
<table>
<thead>
<tr>
2021-01-07 19:25:12 +00:00
<td>Time</td>
2020-12-06 21:27:52 +00:00
<td>Nominator</td>
<td>Nominee</td>
<td>Type</td>
<td>Votes</td>
2021-01-07 19:12:38 +00:00
<td>Majority</td>
2021-01-07 19:25:12 +00:00
<td>
<font-awesome-icon icon="user-friends" />
Voters
</td>
2020-12-06 21:27:52 +00:00
</tr>
</thead>
<tbody>
<tr v-for="(vote, index) in session.voteHistory" :key="index">
2021-01-07 19:25:12 +00:00
<td>
{{
vote.timestamp
.getHours()
.toString()
.padStart(2, "0")
}}:{{
vote.timestamp
.getMinutes()
.toString()
.padStart(2, "0")
2021-01-07 19:25:12 +00:00
}}
2021-01-07 19:25:12 +00:00
</td>
2020-12-06 21:27:52 +00:00
<td>{{ vote.nominator }}</td>
<td>{{ vote.nominee }}</td>
<td>{{ vote.type }}</td>
<td>
2021-01-07 19:25:12 +00:00
{{ vote.votes.length }}
<font-awesome-icon icon="hand-paper" />
2020-12-06 21:27:52 +00:00
</td>
<td>
2021-01-07 19:12:38 +00:00
{{ vote.majority }}
<font-awesome-icon
2021-01-07 19:25:12 +00:00
:icon="[
'fas',
vote.votes.length >= vote.majority ? 'check-square' : 'square'
]"
2021-01-07 19:12:38 +00:00
/>
</td>
2021-01-07 19:25:12 +00:00
<td>
{{ vote.votes.join(", ") }}
</td>
2020-12-06 21:27:52 +00:00
</tr>
</tbody>
</table>
</Modal>
</template>
<script>
import Modal from "./Modal";
import { mapMutations, mapState } from "vuex";
export default {
components: {
Modal
},
computed: {
...mapState(["session", "modals"])
},
methods: {
2021-05-05 06:58:13 +00:00
clearVoteHistory() {
this.$store.commit("session/clearVoteHistory");
},
setRecordVoteHistory() {
this.$store.commit(
"session/setVoteHistoryAllowed",
!this.session.isVoteHistoryAllowed
);
},
2021-05-05 19:06:23 +00:00
...mapMutations(["toggleModal"])
2020-12-06 21:27:52 +00:00
}
};
</script>
<style lang="scss" scoped>
@import "../../vars.scss";
.clear {
position: absolute;
left: 20px;
top: 15px;
2020-12-06 21:27:52 +00:00
cursor: pointer;
&:hover {
color: red;
}
}
2021-05-05 19:06:23 +00:00
.options {
display: flex;
justify-content: center;
align-items: center;
justify-content: center;
align-content: center;
}
2021-05-05 06:58:13 +00:00
.option {
color: white;
text-decoration: none;
margin: 0 15px;
2021-05-05 06:58:13 +00:00
&:hover {
color: red;
2021-05-05 19:06:23 +00:00
cursor: pointer;
2021-05-05 06:58:13 +00:00
}
}
2020-12-06 21:27:52 +00:00
h3 {
2021-02-12 18:19:34 +00:00
margin: 0 40px 0 10px;
2020-12-06 21:27:52 +00:00
svg {
vertical-align: middle;
}
}
table {
border-spacing: 10px 0;
margin-left: auto;
margin-right: auto;
2020-12-06 21:27:52 +00:00
}
thead td {
font-weight: bold;
border-bottom: 1px solid white;
text-align: center;
padding: 0 3px;
}
tbody {
2021-01-07 19:25:12 +00:00
td:nth-child(2) {
2020-12-06 21:27:52 +00:00
color: $townsfolk;
}
2021-01-07 19:25:12 +00:00
td:nth-child(3) {
2020-12-06 21:27:52 +00:00
color: $demon;
}
2021-01-07 19:25:12 +00:00
td:nth-child(5) {
2020-12-06 21:27:52 +00:00
text-align: center;
}
td:nth-child(6) {
text-align: center;
}
2020-12-06 21:27:52 +00:00
}
</style>