refactor(striscia): nuova struttura array-di-set, elimina storicoServizio
La striscia diventa un array di set: ogni elemento è { serv, r[] }
dove r è la sequenza di scorer ('home'|'guest') del set.
- Un rally = un elemento in r: minimo non-derivabile
- Tutti i set (passati e corrente) sono conservati nell'array
- Dal set corrente si derivano: punteggio, servizio, cambio palla, rotazione
- Dal set completo si derivano: vincitore (r.at(-1)), score finale (count)
- storicoServizio eliminato: l'undo legge l'entry precedente di r
DisplayPage calcola le strip visive (home/guest) tramite computed
da striscia.at(-1).r senza dati ridondanti nel modello.
This commit is contained in:
@@ -224,7 +224,7 @@ export default {
|
||||
visuStriscia: true,
|
||||
modalitaPartita: "3/5",
|
||||
sp: {
|
||||
striscia: { home: [0], guest: [0] },
|
||||
striscia: [{ serv: 'home', r: [] }],
|
||||
servHome: true,
|
||||
punt: { home: 0, guest: 0 },
|
||||
set: { home: 0, guest: 0 },
|
||||
@@ -233,7 +233,6 @@ export default {
|
||||
home: ["1", "2", "3", "4", "5", "6"],
|
||||
guest: ["1", "2", "3", "4", "5", "6"],
|
||||
},
|
||||
storicoServizio: [],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -92,16 +92,16 @@
|
||||
<div class="striscia" v-if="state.visuStriscia">
|
||||
<span class="striscia-nome text-bold">{{ state.sp.nomi.home }}</span>
|
||||
<div class="striscia-items" ref="homeItems">
|
||||
<div v-for="(h, i) in state.sp.striscia.home" :key="'sh'+i"
|
||||
class="item" :class="{ 'item-vuoto': String(h).trim() === '' }">
|
||||
{{ String(h) }}
|
||||
<div v-for="(h, i) in stricciaStrip.home" :key="'sh'+i"
|
||||
class="item" :class="{ 'item-vuoto': h === ' ' }">
|
||||
{{ h }}
|
||||
</div>
|
||||
</div>
|
||||
<span class="striscia-nome text-bold guest-striscia">{{ state.sp.nomi.guest }}</span>
|
||||
<div class="striscia-items guest-striscia" ref="guestItems">
|
||||
<div v-for="(h, i) in state.sp.striscia.guest" :key="'sg'+i"
|
||||
class="item" :class="{ 'item-vuoto': String(h).trim() === '' }">
|
||||
{{ String(h) }}
|
||||
<div v-for="(h, i) in stricciaStrip.guest" :key="'sg'+i"
|
||||
class="item" :class="{ 'item-vuoto': h === ' ' }">
|
||||
{{ h }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -132,7 +132,7 @@ export default {
|
||||
visuStriscia: true,
|
||||
modalitaPartita: "3/5",
|
||||
sp: {
|
||||
striscia: { home: [0], guest: [0] },
|
||||
striscia: [{ serv: 'home', r: [] }],
|
||||
servHome: true,
|
||||
punt: { home: 0, guest: 0 },
|
||||
set: { home: 0, guest: 0 },
|
||||
@@ -141,7 +141,6 @@ export default {
|
||||
home: ["1", "2", "3", "4", "5", "6"],
|
||||
guest: ["1", "2", "3", "4", "5", "6"],
|
||||
},
|
||||
storicoServizio: [],
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -192,23 +191,29 @@ export default {
|
||||
this.ws = null
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'state.sp.striscia.home': {
|
||||
deep: true,
|
||||
handler() {
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs.homeItems) this.$refs.homeItems.scrollLeft = this.$refs.homeItems.scrollWidth
|
||||
})
|
||||
computed: {
|
||||
stricciaStrip() {
|
||||
const currentSet = this.state.sp.striscia.at(-1)
|
||||
if (!currentSet) return { home: [], guest: [] }
|
||||
let h = 0, g = 0
|
||||
const home = [], guest = []
|
||||
for (const scorer of currentSet.r) {
|
||||
if (scorer === 'home') { h++; home.push(h); guest.push(' ') }
|
||||
else { g++; guest.push(g); home.push(' ') }
|
||||
}
|
||||
return { home, guest }
|
||||
},
|
||||
'state.sp.striscia.guest': {
|
||||
},
|
||||
watch: {
|
||||
'state.sp.striscia': {
|
||||
deep: true,
|
||||
handler() {
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs.homeItems) this.$refs.homeItems.scrollLeft = this.$refs.homeItems.scrollWidth
|
||||
if (this.$refs.guestItems) this.$refs.guestItems.scrollLeft = this.$refs.guestItems.scrollWidth
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
isMobile() {
|
||||
|
||||
Reference in New Issue
Block a user