fix : repeat (f ) is working

This commit is contained in:
karthik 2025-08-17 10:51:23 +05:30
parent 213945b2e9
commit 594bd4ae77

View File

@ -1101,6 +1101,8 @@ printTicket() {
} }
const barcodeId = `1111${day}${month}${year}${timeStr}${millis}`; const barcodeId = `1111${day}${month}${year}${timeStr}${millis}`;
//----------------------------------------WINLABELS START HERE ------------------------------------------------------
const winLabels = allRows.map(row => { const winLabels = allRows.map(row => {
let displayNumbers = row.numbers; let displayNumbers = row.numbers;
@ -1138,11 +1140,25 @@ const winLabels = allRows.map(row => {
let expandedLegs: string[] = legs.map((leg, i) => { let expandedLegs: string[] = legs.map((leg, i) => {
// Find race index for this leg // Find race index for this leg
let raceIdx = raceIndices.length > i ? raceIndices[i] - 1 : (baseRaceIdx - 1 + i); let raceIdx = raceIndices.length > i ? raceIndices[i] - 1 : (baseRaceIdx - 1 + i);
let expanded = leg.flatMap(n => // let expanded = leg.flatMap(n =>
n === 'F' // n === 'F'
? this.getHorseNumbersForRaceIdx(raceIdx).map(num => num.toString()) // ? this.getHorseNumbersForRaceIdx(raceIdx).map(num => num.toString())
: [n] // : [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 // Remove '-' and '#' for display
return expanded.filter(n => n !== '-' && n !== '#').join(','); 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 // 🐎 Expand 'F' to full horse numbers for other pools
if (displayNumbers.includes('F')) { if (displayNumbers.includes('F')) {
displayNumbers = displayNumbers.flatMap(n => // displayNumbers = displayNumbers.flatMap(n =>
n === 'F' ? this.getHorseNumbersForSelectedRace().map(num => num.toString()) : [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 = ''; let numbersStr = '';
@ -1186,7 +1215,7 @@ const winLabels = allRows.map(row => {
}).join('\n'); }).join('\n');
//------------------------------------EIN LABELS ENDS HERE -------------------------------- //------------------------------------WIN LABELS ENDS HERE --------------------------------
// ✅ Print preview // ✅ Print preview
const printData = { const printData = {