restore bug fixed
authorBenjamin Auder <benjamin.auder@somewhere>
Thu, 28 Dec 2017 14:02:31 +0000 (15:02 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Thu, 28 Dec 2017 14:02:31 +0000 (15:02 +0100)
css/index.css
doc/index.pug
js/index.js

index 9afc23e..727e212 100644 (file)
@@ -2,10 +2,6 @@
 
 @import '../vendor/Ubuntu_googlefont.css';
 
-html, body {
-       height: 100%;
-}
-
 body {
        font-family: Ubuntu, Verdana, sans-serif;
        margin: 0 auto;
@@ -94,14 +90,14 @@ table th {
 }
 /* All children except first: margin: 30px */
 .button-container-horizontal .btn:not(:first-child) {
-       margin-right: 30px;
+       margin-left: 30px;
 }
 .button-container-vertical .btn {
        display: block;
        margin-left: 30px;
 }
 .button-container-vertical .btn:not(:first-child) {
-       margin-top: 15px;
+       margin-top: 30px;
 }
 
 button.validate {
index 8e08c5e..9d7d348 100644 (file)
@@ -31,7 +31,7 @@ html
                p.
                        Un clic sur le bouton "Nouvelle ronde" réinitialise toutes les tables, en (re-)répartissant les joueurs aléatoirement sur celles-ci.
                        Si nécessaire, un quatrième joueur "Toto" est ajouté en fin de table.
-                       Si seulement 1, 2, ou 5 ou 6 joueurs sont présents, aucune configuration ne permet de faire jouer tout le monde : il y aura des joueurs exempts.
+                       Si seulement 1, 2, ou 5 joueurs sont présents, aucune configuration ne permet de faire jouer tout le monde : il y aura des joueurs exempts.
 
                img(src="doc/screen_pairings_scoring.png")
 
index 42a376e..02e490e 100644 (file)
@@ -83,7 +83,7 @@ new Vue({
                                                                <td :class="{toto: players[tables[currentIndex][i]].prenom=='Toto'}">
                                                                        {{ players[tables[currentIndex][i]].prenom }} {{ players[tables[currentIndex][i]].nom }}
                                                                </td>
-                                                               <td><input type="text" v-model="sessions[currentIndex][i]" value="0"/></td>
+                                                               <td><input type="text" v-model="sessions[currentIndex][i]"/></td>
                                                        </tr>
                                                </table>
                                                <div class="button-container-horizontal">
@@ -93,7 +93,7 @@ new Vue({
                                                <div v-if="scored[currentIndex]" class="warning">
                                                        Attention: un score a déjà été enregistré.
                                                        Les points indiqués ici s'ajouteront : il faut d'abord
-                                                       <span class="link" @click="document.getElementById('restoreBtn').click()">restaurer l'état précédent.</span>
+                                                       <span class="link" @click="clickRestore()">restaurer l'état précédent.</span>
                                                        Si c'est déjà fait, ignorer ce message :)
                                                </div>
                                        </div>
@@ -180,6 +180,9 @@ new Vue({
                                        this.currentIndex = -1;
                                        this.writeScoreToDb();
                                },
+                               clickRestore: function() {
+                                       document.getElementById('restoreBtn').click();
+                               },
                        },
                },
                'my-timer': {
@@ -190,7 +193,7 @@ new Vue({
                                };
                        },
                        template: `
-                               <div id="timer" :style="{lineHeight: screen.height+ 'px', fontSize: 0.66*screen.height + 'px'}">
+                               <div id="timer" :style="{lineHeight: textHeight + 'px', fontSize: 0.66*textHeight + 'px'}">
                                        <div @click.left="pauseResume()" @click.right.prevent="reset()" :class="{timeout:time==0}">
                                                {{ formattedTime }}
                                        </div>
@@ -203,6 +206,9 @@ new Vue({
                                        let minutes = Math.floor(this.time / 60);
                                        return this.padToZero(minutes) + ":" + this.padToZero(seconds);
                                },
+                               textHeight: function() {
+                                       return screen.height;
+                               },
                        },
                        methods: {
                                padToZero: function(a) {
@@ -282,7 +288,6 @@ new Vue({
                                rankPeople: function() {
                                        return this.players
                                                .slice(1) //discard Toto
-                                               .map( p => { return Object.assign({}, p); }) //to not alter original array
                                                .sort(this.sortByScore);
                                },
                                resetPlayers: function() {
@@ -294,7 +299,7 @@ new Vue({
                                                        p.available = 1;
                                                });
                                        this.writeScoreToDb();
-                                       document.getElementById("runPairing").click(); //TODO: hack...
+                                       document.getElementById("runPairing").click();
                                },
                                restoreLast: function() {
                                        let xhr = new XMLHttpRequest();
@@ -312,7 +317,13 @@ new Vue({
                                                                        session: 0,
                                                                        available: 0,
                                                                });
-                                                               self.players = players;
+                                                               // NOTE: Vue warning "do not mutate property" if direct self.players = players
+                                                               for (let i=1; i<players.length; i++)
+                                                               {
+                                                                       players[i].pdt = parseFloat(players[i].pdt);
+                                                                       players[i].session = parseInt(players[i].session);
+                                                                       Vue.set(self.players, i, players[i]);
+                                                               }
                                                        }
                                                }
                                        };
@@ -358,7 +369,6 @@ new Vue({
                        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                        let orderedPlayers = this.players
                                .slice(1) //discard Toto
-                               .map( p => { return Object.assign({}, p); }) //deep (enough) copy
                                .sort(this.sortByScore);
                        xhr.send("players="+encodeURIComponent(JSON.stringify(orderedPlayers)));
                },