From 594bd4ae77000d06b1c8e42ef0cc3c658af25f93 Mon Sep 17 00:00:00 2001 From: karthik Date: Sun, 17 Aug 2025 10:51:23 +0530 Subject: [PATCH] fix : repeat (f ) is working --- .../touch-pad-menu.component.ts | 47 +++++++++++++++---- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.ts b/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.ts index 3be3ad6..d3adbd6 100755 --- a/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.ts +++ b/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.ts @@ -1101,6 +1101,8 @@ printTicket() { } const barcodeId = `1111${day}${month}${year}${timeStr}${millis}`; + + //----------------------------------------WINLABELS START HERE ------------------------------------------------------ const winLabels = allRows.map(row => { let displayNumbers = row.numbers; @@ -1138,11 +1140,25 @@ const winLabels = allRows.map(row => { let expandedLegs: string[] = legs.map((leg, i) => { // Find race index for this leg let raceIdx = raceIndices.length > i ? raceIndices[i] - 1 : (baseRaceIdx - 1 + i); - let expanded = leg.flatMap(n => - n === 'F' - ? this.getHorseNumbersForRaceIdx(raceIdx).map(num => num.toString()) - : [n] - ); + // let expanded = leg.flatMap(n => + // n === 'F' + // ? this.getHorseNumbersForRaceIdx(raceIdx).map(num => num.toString()) + // : [n] + // ); + let expanded = leg.flatMap((n, idx) => { + if (n === 'F') { + const horses = this.getHorseNumbersForRaceIdx(raceIdx).map(num => num.toString()).join(','); + const isFirst = idx === 0; + const isLast = idx === leg.length - 1; + if (isFirst && !isLast) return [`${horses}-`]; + if (!isFirst && isLast) return [`-${horses}`]; + if (isFirst && isLast) return [horses]; // only F in the leg + return [`-${horses}-`]; + } + return [n]; +}); + + // Remove '-' and '#' for display return expanded.filter(n => n !== '-' && n !== '#').join(','); }); @@ -1158,9 +1174,22 @@ const winLabels = allRows.map(row => { // 🐎 Expand 'F' to full horse numbers for other pools if (displayNumbers.includes('F')) { - displayNumbers = displayNumbers.flatMap(n => - n === 'F' ? this.getHorseNumbersForSelectedRace().map(num => num.toString()) : [n] - ); + // displayNumbers = displayNumbers.flatMap(n => + // n === 'F' ? this.getHorseNumbersForSelectedRace().map(num => num.toString()) : [n] + // ); + displayNumbers = displayNumbers.flatMap((n, idx, arr) => { + if (n === 'F') { + const horses = this.getHorseNumbersForSelectedRace().map(num => num.toString()).join(','); + const isFirst = idx === 0; + const isLast = idx === arr.length - 1; + if (isFirst && !isLast) return [`${horses}-`]; + if (!isFirst && isLast) return [`-${horses}`]; + if (isFirst && isLast) return [horses]; // only F + return [`-${horses}-`]; + } + return [n]; +}); + } let numbersStr = ''; @@ -1186,7 +1215,7 @@ const winLabels = allRows.map(row => { }).join('\n'); -//------------------------------------EIN LABELS ENDS HERE -------------------------------- +//------------------------------------WIN LABELS ENDS HERE -------------------------------- // ✅ Print preview const printData = {