4 .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
6 button(@click="display='live'") Live games
7 button(@click="display='corr'") Correspondance games
8 GameList(v-show="display=='live'" :games="filterGames('live')"
10 GameList(v-show="display=='corr'" :games="filterGames('corr')"
11 @show-game="showGame")
15 // TODO: background orange si à moi de jouer
16 // (helper: static fonction "GetNextCol()" dans base_rules.js)
17 // use GameStorage.getAll()
19 import { store } from "@/store";
20 import { GameStorage } from "@/utils/gameStorage";
21 import { ajax } from "@/utils/ajax";
22 import GameList from "@/components/GameList.vue";
36 GameStorage.getAll((localGames) => {
37 localGames.forEach((g) => g.type = this.classifyObject(g));
38 Array.prototype.push.apply(this.games, localGames);
40 if (this.st.user.id > 0)
42 ajax("/games", "GET", {uid: this.st.user.id}, (res) => {
43 res.games.forEach((g) => g.type = this.classifyObject(g));
44 //Array.prototype.push.apply(this.games, res.games); //TODO: Vue 3
45 this.games = this.games.concat(res.games);
50 // TODO: classifyObject and filterGames are redundant (see Hall.vue)
51 classifyObject: function(o) {
52 return (o.timeControl.indexOf('d') === -1 ? "live" : "corr");
54 filterGames: function(type) {
55 return this.games.filter(g => g.type == type);
57 showGame: function(g) {
58 // NOTE: we play in this game, since this is "MyGames" page
59 this.$router.push("/game/" + g.id);
65 <!-- Add "scoped" attribute to limit CSS to this component only -->
66 <style scoped lang="sass">