Fix games list display + challenges display
[vchess.git] / client / src / components / ChallengeList.vue
CommitLineData
85e5b5c1
BA
1<template lang="pug">
2table
3 tr
03608482 4 th Variant
85e5b5c1
BA
5 th From
6 th To
7 th Cadence
0b0dc040 8 tr(v-for="c in sortedChallenges" @click="$emit('click-challenge',c)")
bb7dd7db 9 td {{ c.vname }}
85e5b5c1 10 td {{ c.from.name }}
c9695cb1 11 td {{ c.to }}
03608482 12 td {{ c.timeControl }}
85e5b5c1
BA
13</template>
14
15<script>
0b0dc040
BA
16import { store } from "@/store";
17
85e5b5c1
BA
18export default {
19 name: "my-challenge-list",
20 props: ["challenges"],
0b0dc040
BA
21 data: function() {
22 return {
23 st: store.state,
24 };
25 },
26 computed: {
27 sortedChallenges: function() {
28 // Show in order: challenges I sent, challenges I received, other challenges
29 let augmentedChalls = this.challenges.map(c => {
30 let priority = 0;
31 if (c.to == this.st.user.name)
32 priority = 1;
33 else if (c.from.id == this.st.user.id || c.from.sid == this.st.user.sid)
34 priority = 2;
35 return Object.assign({}, c, {priority: priority});
36 });
37 return augmentedChalls.sort((c1,c2) => { return c2.priority - c1.priority; });
38 },
39 },
85e5b5c1 40};
85e5b5c1
BA
41</script>
42
43<style lang="sass">
44// TODO: affichage bizarre sur petits écrans <=767px
45</style>