Separate client and server codes. Keep everything in one git repo for simplicity
[vchess.git] / client / client_OLD / javascripts / components / gameList.js
diff --git a/client/client_OLD/javascripts/components/gameList.js b/client/client_OLD/javascripts/components/gameList.js
new file mode 100644 (file)
index 0000000..9b66982
--- /dev/null
@@ -0,0 +1,29 @@
+Vue.component("my-game-list", {
+       props: ["games"],
+       computed: {
+               showVariant: function() {
+                       return this.games.length > 0 && !!this.games[0].vname;
+               },
+               showResult: function() {
+                       return this.games.length > 0 && this.games[0].score != "*";
+               },
+       },
+       template: `
+               <table>
+                       <tr>
+                               <th v-if="showVariant">Variant</th>
+                               <th>Players names</th>
+                               <th>Cadence</th>
+                               <th v-if="showResult">Result</th>
+                       </tr>
+                       <tr v-for="g in games" @click="$emit('show-game',g)">
+                               <td v-if="showVariant">{{ g.vname }}</td>
+                               <td>
+                                       <span v-for="p in g.players">{{ p.name }}</span>
+                               </td>
+                               <td>{{ g.mainTime }} + {{ g.increment }}</td>
+                               <td v-if="showResult">{{ g.score }}</td>
+                       </tr>
+               </table>
+       `,
+});