2017-08-10 23:14:45 +02:00
|
|
|
<template>
|
|
|
|
<section>
|
2017-08-13 01:23:24 +02:00
|
|
|
<header class="results-header">
|
2017-08-13 15:44:03 +02:00
|
|
|
<h1>{{ $t('euromat.results.headline') }}</h1>
|
2017-08-13 01:23:24 +02:00
|
|
|
</header>
|
2017-08-10 23:47:40 +02:00
|
|
|
|
|
|
|
<ul class="party-results">
|
|
|
|
<li v-for="party in parties">
|
2017-08-13 01:23:24 +02:00
|
|
|
<h2>{{ party.token }}</h2>
|
2017-08-13 15:44:03 +02:00
|
|
|
<svgicon :name="getPartyLogoName(party.token)" width="50" height="50" />
|
2017-08-13 01:23:24 +02:00
|
|
|
<party-percentage :value="getPartyMatch(party)" :max="thesesCount" />
|
2017-08-10 23:47:40 +02:00
|
|
|
</li>
|
|
|
|
</ul>
|
2017-08-10 23:14:45 +02:00
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2017-08-10 23:47:40 +02:00
|
|
|
import { getParties, getParty, getThesesCount } from '@/utils/data'
|
2017-08-13 01:23:24 +02:00
|
|
|
import Progress from '@/components/progress'
|
2017-08-13 15:44:03 +02:00
|
|
|
import '@/assets/icons'
|
2017-08-10 23:47:40 +02:00
|
|
|
|
2017-08-10 23:14:45 +02:00
|
|
|
export default {
|
|
|
|
name: 'Results',
|
|
|
|
|
2017-08-13 01:23:24 +02:00
|
|
|
components: {
|
|
|
|
'party-percentage': Progress
|
|
|
|
},
|
|
|
|
|
2017-08-10 23:14:45 +02:00
|
|
|
data () {
|
|
|
|
return {
|
2017-08-13 15:44:03 +02:00
|
|
|
results: [],
|
2017-08-10 23:47:40 +02:00
|
|
|
thesesCount: getThesesCount(),
|
|
|
|
parties: getParties()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
getPartyMatch (party) {
|
|
|
|
const { positions } = getParty(party.token)
|
2017-08-12 21:28:33 +02:00
|
|
|
return this.results
|
|
|
|
.filter(answer =>
|
|
|
|
answer.option.position === positions[answer.thesis.id].position)
|
|
|
|
.length
|
2017-08-13 15:44:03 +02:00
|
|
|
},
|
|
|
|
getPartyLogoName (token) {
|
|
|
|
return `${token.toLowerCase()}-logo`
|
2017-08-10 23:14:45 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted () {
|
2017-08-13 18:01:30 +02:00
|
|
|
const results = JSON.parse(localStorage.getItem('euromat-results'))
|
|
|
|
if (results) {
|
|
|
|
this.results = results
|
|
|
|
}
|
2017-08-10 23:47:40 +02:00
|
|
|
console.log(this.results)
|
2017-08-10 23:14:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2017-08-10 23:47:40 +02:00
|
|
|
<style lang="scss" scoped>
|
2017-08-13 01:23:24 +02:00
|
|
|
@import "~styles/layout";
|
|
|
|
|
|
|
|
.results-header {
|
|
|
|
margin-bottom: $base-gap;
|
|
|
|
}
|
|
|
|
|
2017-08-10 23:47:40 +02:00
|
|
|
.party-results {
|
|
|
|
list-style: none;
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
li {
|
|
|
|
display: flex;
|
2017-08-13 01:23:24 +02:00
|
|
|
flex-direction: column;
|
|
|
|
margin-bottom: $base-gap;
|
2017-08-10 23:47:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|