diff --git a/README.md b/README.md index 4b48f13..8d2f445 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,7 @@ Serve i file dalla cartella `/dist` per testare la build prima del deploy. | `Ctrl + ↑` | Incrementa punti | | `Ctrl + ↓` | Decrementa punti | | `Ctrl + →` | Incrementa set | +| `Ctrl + C` | Apri dialog cambi | ### Controlli Tastiera Squadra Guest @@ -161,6 +162,7 @@ Serve i file dalla cartella `/dist` per testare la build prima del deploy. | `Shift + ↑` | Incrementa punti | | `Shift + ↓` | Decrementa punti | | `Shift + →` | Incrementa set | +| `Shift + C` | Apri dialog cambi | ### Comandi Globali @@ -172,7 +174,6 @@ Serve i file dalla cartella `/dist` per testare la build prima del deploy. | `Ctrl + F` | Attiva/disattiva fullscreen | | `Ctrl + S` | Annuncio vocale punteggio corrente | | `Ctrl + Z` | Switch tra visualizzazione formazioni e punteggio | -| `Ctrl + C` | Apri dialog cambi | --- diff --git a/src/components/HomePage/HomePage.html b/src/components/HomePage/HomePage.html index b806753..cef59bd 100644 --- a/src/components/HomePage/HomePage.html +++ b/src/components/HomePage/HomePage.html @@ -68,6 +68,13 @@ Ok + +
Scegli squadra
+ + {{ sp.nomi.home }} + {{ sp.nomi.guest }} + +
CAMBI
@@ -79,12 +86,12 @@ - + - + diff --git a/src/components/HomePage/HomePage.js b/src/components/HomePage/HomePage.js index d32d011..22c9cfe 100644 --- a/src/components/HomePage/HomePage.js +++ b/src/components/HomePage/HomePage.js @@ -13,9 +13,13 @@ export default { }, diaCambi: { show: false, + team: "home", guest: { in: "", out: "" }, home: { in: "", out: "" }, }, + diaCambiTeam: { + show: false, + }, visuForm: false, visuButt: true, visuStriscia: true, @@ -49,20 +53,11 @@ export default { return this.sp.punt.home === 0 && this.sp.punt.guest === 0; }, cambiConfermabili() { - const guestIn = (this.diaCambi.guest.in || "").trim(); - const guestOut = (this.diaCambi.guest.out || "").trim(); - const homeIn = (this.diaCambi.home.in || "").trim(); - const homeOut = (this.diaCambi.home.out || "").trim(); + const team = this.diaCambi.team; + const teamIn = (this.diaCambi[team].in || "").trim(); + const teamOut = (this.diaCambi[team].out || "").trim(); - const guestEmpty = !guestIn && !guestOut; - const homeEmpty = !homeIn && !homeOut; - const guestComplete = !!guestIn && !!guestOut; - const homeComplete = !!homeIn && !!homeOut; - - const noIncomplete = (guestEmpty || guestComplete) && (homeEmpty || homeComplete); - const atLeastOne = guestComplete || homeComplete; - - return noIncomplete && atLeastOne; + return !!teamIn && !!teamOut; } }, methods: { @@ -235,20 +230,30 @@ export default { this.disabilitaTastiSpeciali(); this.diaNomi.show = true; }, - resettaCambi() { - this.diaCambi.guest.in = ""; - this.diaCambi.guest.out = ""; - this.diaCambi.home.in = ""; - this.diaCambi.home.out = ""; + resettaCambi(team) { + const teams = team ? [team] : ["home", "guest"]; + teams.forEach((t) => { + this.diaCambi[t].in = ""; + this.diaCambi[t].out = ""; + }); }, apriDialogCambi() { this.disabilitaTastiSpeciali(); - this.resettaCambi(); + this.diaCambiTeam.show = true; + }, + apriDialogCambiTeam(team) { + this.disabilitaTastiSpeciali(); + this.diaCambi.team = team; + this.resettaCambi(team); this.diaCambi.show = true; }, + selezionaTeamCambi(team) { + this.diaCambiTeam.show = false; + this.apriDialogCambiTeam(team); + }, chiudiDialogCambi() { this.diaCambi.show = false; - this.resettaCambi(); + this.resettaCambi(this.diaCambi.team); this.abilitaTastiSpeciali(); }, confermaCambi() { @@ -256,40 +261,31 @@ export default { return; } - const cambi = [ - { team: "guest", in: (this.diaCambi.guest.in || "").trim(), out: (this.diaCambi.guest.out || "").trim() }, - { team: "home", in: (this.diaCambi.home.in || "").trim(), out: (this.diaCambi.home.out || "").trim() }, - ]; + const team = this.diaCambi.team; + const cambio = { + team, + in: (this.diaCambi[team].in || "").trim(), + out: (this.diaCambi[team].out || "").trim(), + }; - const cambiDaApplicare = []; - for (const cambio of cambi) { - if (!cambio.in && !cambio.out) { - continue; - } + const form = this.sp.form[cambio.team].map((val) => String(val).trim()); - const form = this.sp.form[cambio.team].map((val) => String(val).trim()); - - if (form.includes(cambio.in)) { - this.$waveui.notify(`Numero ${cambio.in} già presente in formazione ${cambio.team}`, "warning"); - return; - } - if (!form.includes(cambio.out)) { - this.$waveui.notify(`Numero ${cambio.out} non presente in formazione ${cambio.team}`, "warning"); - return; - } - if (cambio.in === cambio.out) { - this.$waveui.notify(`Numero IN e OUT uguali per ${cambio.team}`, "warning"); - return; - } - - cambiDaApplicare.push({ ...cambio }); + if (form.includes(cambio.in)) { + this.$waveui.notify(`Numero ${cambio.in} già presente in formazione ${cambio.team}`, "warning"); + return; + } + if (!form.includes(cambio.out)) { + this.$waveui.notify(`Numero ${cambio.out} non presente in formazione ${cambio.team}`, "warning"); + return; + } + if (cambio.in === cambio.out) { + this.$waveui.notify(`Numero IN e OUT uguali per ${cambio.team}`, "warning"); + return; } - for (const cambio of cambiDaApplicare) { - const idx = this.sp.form[cambio.team].findIndex((val) => String(val).trim() === cambio.out); - if (idx !== -1) { - this.sp.form[cambio.team].splice(idx, 1, cambio.in); - } + const idx = this.sp.form[cambio.team].findIndex((val) => String(val).trim() === cambio.out); + if (idx !== -1) { + this.sp.form[cambio.team].splice(idx, 1, cambio.in); } this.chiudiDialogCambi(); @@ -301,7 +297,7 @@ export default { window.addEventListener("keydown", this.funzioneTastiSpeciali); }, funzioneTastiSpeciali(e) { - if (this.diaNomi.show || this.diaCambi.show) { + if (this.diaNomi.show || this.diaCambi.show || this.diaCambiTeam.show) { return; } @@ -367,7 +363,10 @@ export default { this.cambiaPalla() handled = true; } else if (e.ctrlKey && (e.key == "c" || e.key == "C")) { - this.apriDialogCambi() + this.apriDialogCambiTeam("home") + handled = true; + } else if (e.shiftKey && (e.key == "c" || e.key == "C")) { + this.apriDialogCambiTeam("guest") handled = true; } else { return false }
{{ sp.nomi.home }}
{{ sp.nomi.guest }}