fix : added print view

This commit is contained in:
karthik 2025-08-06 15:21:19 +05:30
parent e2673edbfa
commit 87fa43bbe2

View File

@ -116,20 +116,7 @@ export class TouchPadMenuComponent implements OnInit, OnDestroy {
});
// --- NEW: Subscribe to race changes ---
// this.sharedStateService.selectedRace$.subscribe(() => {
// this.setActualRunners();
// // If currently in a multi-leg pool, update the numbers for the active leg
// if (this.currentPool && this.multiLegLabels.includes(this.selectedLabel || '')) {
// this.updateLegRaceDisplay(this.currentPool);
// const runnerCount = this.getRunnerCountForLeg(this.multiLegBaseRaceIdx, this.multiLegStage);
// this.runnerCount = runnerCount || 12;
// this.numbers = Array.from({ length: 30 }, (_, i) => i + 1);
// this.numbersFlat = this.numberRows.flat();
// this.actualRunners = this.getActualRunnersForCurrentPoolLeg();
// } else {
// this.setActualRunners();
// }
// });
this.sharedStateService.selectedRace$.subscribe(race => {
this.selectedRaceNumber = String(race || '1');
this.setActualRunners();
@ -407,8 +394,8 @@ export class TouchPadMenuComponent implements OnInit, OnDestroy {
const group2 = allBoxed.slice(group1.length, group1.length + groupSize);
const group3 = allBoxed.slice(group1.length + group2.length);
const combined: (number | string)[] = [...group1];
if (group2.length) combined.push('-', ...group2);
if (group3.length) combined.push('-', ...group3);
if (group2.length) combined.push( ...group2);
if (group3.length) combined.push( ...group3);
this.selectedNumbers = combined;
this.selectionService.updatePartial({
numbers: [...this.selectedNumbers],
@ -442,21 +429,54 @@ export class TouchPadMenuComponent implements OnInit, OnDestroy {
}
// FOR/QUI logic
if (this.twoGroupLabels.includes(this.selectedLabel || '')) {
// if (this.twoGroupLabels.includes(this.selectedLabel || '')) {
// if (!this.isFirstGroupComplete) {
// if (!this.firstGroup.includes(number)) {
// this.firstGroup.push(number);
// this.selectedNumbers = [...this.firstGroup];
// }
// } else {
// if (!this.secondGroup.includes(number)) {
// this.secondGroup.push(number);
// this.selectedNumbers = [...this.firstGroup, '-', ...this.secondGroup];
// }
// }
// this.selectionService.updatePartial({ numbers: [...this.selectedNumbers] });
// return;
// }
// FOR/QUI logic
if (this.twoGroupLabels.includes(this.selectedLabel || '')) {
console.log('Selected label:', this.selectedLabel);
console.log('Current number clicked:', number);
if (!this.isFirstGroupComplete) {
console.log('First group not complete. Current firstGroup:', this.firstGroup);
if (!this.firstGroup.includes(number)) {
console.log(`Adding ${number} to firstGroup`);
this.firstGroup.push(number);
this.selectedNumbers = [...this.firstGroup];
}
} else {
console.log(`${number} already exists in firstGroup`);
}
} else {
console.log('First group complete. Moving to secondGroup. Current secondGroup:', this.secondGroup);
if (!this.secondGroup.includes(number)) {
console.log(`Adding ${number} to secondGroup`);
this.secondGroup.push(number);
this.selectedNumbers = [...this.firstGroup, '-', ...this.secondGroup];
} else {
console.log(`${number} already exists in secondGroup`);
}
}
console.log('Updated selectedNumbers:', this.selectedNumbers);
this.selectionService.updatePartial({ numbers: [...this.selectedNumbers] });
return;
}
}
// Default single-number selection (WIN, SHP, THP, etc.)
if (!this.selectedNumbers.includes(number)) {
@ -587,27 +607,7 @@ export class TouchPadMenuComponent implements OnInit, OnDestroy {
//-----------------------------ENTER PAD VALUE-------------------------------------
// enterPadVal(key: string) {
// if (!this.numericPadEnabled || this.totalAmountLimitReached) return;
// if (key === 'X') {
// this.padValue = '';
// } else if (/[0-9]/.test(key)) {
// const currentValue = parseInt(this.padValue + key) || 0;
// if (currentValue > 100) return;
// this.padValue += key;
// }
// this.updateCanPrint();
// const value = parseFloat(this.padValue) || 0;
// this.selectionService.updatePartial({
// value,
// isBoxed: this.isBoxed,
// label: this.selectedLabel || '',
// numbers: [...this.selectedNumbers]
// });
// }
enterPadVal(key: string) {
if (!this.numericPadEnabled || this.totalAmountLimitReached) return;
@ -809,29 +809,41 @@ printTicket() {
const ticketId = `${venue}/${fullYear}${month}${day}/${this.selectedRaceNumber}`;
const barcodeId = `1111${day}${month}${year}${timeStr}${millis}`;
// const winLabels = allRows.map(row => {
// const label = row.label.padEnd(10);
// const numbers = row.numbers.join(',').padEnd(15);
// const value = (`*${row.value || 0}`).padEnd(8);
// const total = `Rs ${row.total || 0}`.padStart(8);
// return `${label}${numbers}${value}${total}`;
// }).join('\n');
const winLabels = allRows.map(row => {
const winLabels = allRows.map(row => {
let displayNumbers = row.numbers;
// 🔁 If 'F', expand to all horses
if (row.numbers.length === 1 && row.numbers[0] === 'F') {
displayNumbers = this.getHorseNumbersForSelectedRace().map(n => n.toString());
// 🐎 Expand 'F' to full horse numbers
if (displayNumbers.includes('F')) {
displayNumbers = displayNumbers.flatMap(n =>
n === 'F' ? this.getHorseNumbersForSelectedRace().map(num => num.toString()) : [n]
);
}
let numbersStr = '';
// 🎯 FOR, QUI, TAN logic with box check
if (['FOR', 'QUI', 'TAN'].includes(row.label)) {
const actualNumbers = displayNumbers.filter(n => n !== '#' && n !== '-').join(',');
if (row.numbers.includes('#') || row.isBoxed) { // ✅ box condition
numbersStr = `${actualNumbers} - ${actualNumbers}`;
} else {
numbersStr = actualNumbers;
}
} else {
// 📝 All other pools
numbersStr = displayNumbers.filter(n => n !== '#' && n !== '-').join(',');
}
const label = row.label.padEnd(10);
const numbers = displayNumbers.join(',').padEnd(15);
const numbers = numbersStr.padEnd(15);
const value = (`*${row.value || 0}`).padEnd(8);
const total = `Rs ${row.total || 0}`.padStart(8);
return `${label}${numbers}${value}${total}`;
}).join('\n');
// const total = `Rs ${row.total || 0}`.padStart(8);
return `${label}${numbers} ${value}`;
}).join('\n');
//------------------------------------EIN LABELS ENDS HERE --------------------------------
// ✅ Print preview
const printData = {
@ -897,10 +909,9 @@ printTicket() {
.catch(error => {
console.error("❌ Print failed:", error);
this.erase(); // ✅ Clear selections after successful print
});
this.erase(); // ✅ Clear selections after successful print
// this.erase(); // ✅ Clear selections after successful print
//--------------------Ended Print here -----------------------------