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