kandimat-user-app/src/app/euromat/components/results.vue

78 lines
1.6 KiB
Vue
Raw Normal View History

2017-08-10 23:14:45 +02:00
<template>
<section>
2017-08-13 01:23:24 +02:00
<header class="results-header">
<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>
<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'
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 {
results: [],
2017-08-10 23:47:40 +02:00
thesesCount: getThesesCount(),
parties: getParties()
}
},
methods: {
getPartyMatch (party) {
const { positions } = getParty(party.token)
return this.results
.filter(answer =>
answer.option.position === positions[answer.thesis.id].position)
.length
},
getPartyLogoName (token) {
return `${token.toLowerCase()}-logo`
2017-08-10 23:14:45 +02:00
}
},
mounted () {
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>