revelation: show number of voters

This commit is contained in:
Settel 2021-09-05 21:30:13 +02:00
parent b75a254a80
commit a1740b3467
5 changed files with 41 additions and 7 deletions

View File

@ -8,6 +8,11 @@
{{ source.name }} {{ source.name }}
</div> </div>
</div> </div>
<div v-if="badgeCount" class="source__badge">
<div class="source__badge-count">
{{ badgeCount }}
</div>
</div>
</div> </div>
</template> </template>
@ -22,6 +27,12 @@ export default {
'source__container__selected': this.isSelected(), 'source__container__selected': this.isSelected(),
} }
}, },
badgeCount() {
const revelation = this.$store.state.round.revelation || {}
const votes = revelation.votes || {}
const list = votes[this.source.id] || []
return list.length
},
}, },
methods: { methods: {
isSelected() { isSelected() {
@ -87,5 +98,25 @@ export default {
user-select: none; user-select: none;
} }
&__badge {
display: flex;
align-items: center;
position: absolute;
right: -12px;
top: -16px;
width: 24px;
height: 24px;
background-color: #6040c0;
border: 2px solid #ffffff;
border-radius: 14px;
color: #c0c060;
font-family: "Wendy One";
font-size: 16px;
&-count {
width: 100%;
text-align: center;
}
}
} }
</style> </style>

View File

@ -2,6 +2,7 @@ export const state = () => ({
quote: "", quote: "",
sources: [], sources: [],
selections: {}, selections: {},
revelation: {},
}) })
export const mutations = { export const mutations = {
@ -10,10 +11,12 @@ export const mutations = {
state.quote = game.round.quote state.quote = game.round.quote
state.sources = game.round.sources state.sources = game.round.sources
state.selections = game.round.selections state.selections = game.round.selections
state.revelation = game.round.revelation
} else { } else {
state.quote = "" state.quote = ""
state.sources = [] state.sources = []
state.selections = {} state.selections = {}
state.revelation = {}
} }
}, },
} }

View File

@ -54,7 +54,11 @@ func (gm *Game) getRevelation() *syncdata.Revelation {
return nil return nil
} }
votes := make(map[string]syncdata.Votes, 0) votes := make(map[string][]string, 0)
for key, val := range gm.round.selections {
votes[val] = append(votes[val], key)
}
revelation := syncdata.Revelation{ revelation := syncdata.Revelation{
Votes: votes, Votes: votes,
} }

View File

@ -17,12 +17,8 @@ type SourceInfo struct {
Name string `json:"name"` Name string `json:"name"`
} }
type Votes struct {
Count int `json:"count"`
}
type Revelation struct { type Revelation struct {
Votes map[string]Votes `json:"votes"` Votes map[string][]string `json:"votes"`
} }
type RoundInfo struct { type RoundInfo struct {