fix : label part (restriction) ✅
This commit is contained in:
parent
06aaa13e00
commit
ff263099c7
@ -143,7 +143,10 @@ export class TouchPadMenuComponent implements OnInit, OnDestroy {
|
|||||||
this.maxRowsReached = selections.length >= 5;
|
this.maxRowsReached = selections.length >= 5;
|
||||||
const totalAmount = selections.reduce((sum: number, selection: SelectionData) => sum + (selection.total || 0), 0);
|
const totalAmount = selections.reduce((sum: number, selection: SelectionData) => sum + (selection.total || 0), 0);
|
||||||
this.totalAmountLimitReached = totalAmount >= 5000;
|
this.totalAmountLimitReached = totalAmount >= 5000;
|
||||||
this.blockedLabels = this.labelRestrictionService.getBlockedLabels(selections);
|
|
||||||
|
// NEW:
|
||||||
|
this.refreshBlockedLabels(this.selectedLabel);
|
||||||
|
|
||||||
if (!this.totalAmountLimitReached) {
|
if (!this.totalAmountLimitReached) {
|
||||||
this.showLimitPopup = false;
|
this.showLimitPopup = false;
|
||||||
}
|
}
|
||||||
@ -389,6 +392,8 @@ export class TouchPadMenuComponent implements OnInit, OnDestroy {
|
|||||||
this.runnerCount = this.getRunnerCountForLeg(this.multiLegBaseRaceIdx, 0) || 12;
|
this.runnerCount = this.getRunnerCountForLeg(this.multiLegBaseRaceIdx, 0) || 12;
|
||||||
this.numbers = Array.from({ length: 30 }, (_, i) => i + 1);
|
this.numbers = Array.from({ length: 30 }, (_, i) => i + 1);
|
||||||
this.numbersFlat = this.numberRows.flat();
|
this.numbersFlat = this.numberRows.flat();
|
||||||
|
// Call after pool change
|
||||||
|
this.refreshBlockedLabels(label);
|
||||||
} else {
|
} else {
|
||||||
this.currentPool = null;
|
this.currentPool = null;
|
||||||
this.multiLegBaseRaceIdx = 0;
|
this.multiLegBaseRaceIdx = 0;
|
||||||
@ -399,6 +404,8 @@ export class TouchPadMenuComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
// --- NEW: Update actualRunners for single race ---
|
// --- NEW: Update actualRunners for single race ---
|
||||||
this.setActualRunners();
|
this.setActualRunners();
|
||||||
|
// Call after pool change
|
||||||
|
this.refreshBlockedLabels(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------ADDED THIS -----------------------------------------------------
|
//----------------------------------ADDED THIS -----------------------------------------------------
|
||||||
@ -421,9 +428,13 @@ export class TouchPadMenuComponent implements OnInit, OnDestroy {
|
|||||||
const totalExisting = currentSelections.reduce((sum, r) => sum + r.total, 0);
|
const totalExisting = currentSelections.reduce((sum, r) => sum + r.total, 0);
|
||||||
if (totalExisting + totalNew <= 5000) {
|
if (totalExisting + totalNew <= 5000) {
|
||||||
this.selectionService.setSelections([...currentSelections, ...blankRows]);
|
this.selectionService.setSelections([...currentSelections, ...blankRows]);
|
||||||
|
// Call after setSelections
|
||||||
|
this.refreshBlockedLabels(label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.selectionService.updatePartial({ label: '', numbers: [], value: 0, total: 0 });
|
this.selectionService.updatePartial({ label: '', numbers: [], value: 0, total: 0 });
|
||||||
|
// Call before return in WSP
|
||||||
|
this.refreshBlockedLabels(label);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//----------------------------------ended here----------------------------------------------------
|
//----------------------------------ended here----------------------------------------------------
|
||||||
@ -440,6 +451,8 @@ export class TouchPadMenuComponent implements OnInit, OnDestroy {
|
|||||||
this.multiLegGroups = [[], [], [], [], []];
|
this.multiLegGroups = [[], [], [], [], []];
|
||||||
|
|
||||||
this.selectionService.updatePartial({ label });
|
this.selectionService.updatePartial({ label });
|
||||||
|
// recompute blocked labels including newly-selected label
|
||||||
|
this.refreshBlockedLabels(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getBaseRaceIndexForPool(poolName: string): number {
|
private getBaseRaceIndexForPool(poolName: string): number {
|
||||||
@ -564,6 +577,8 @@ if (this.twoGroupLabels.includes(this.selectedLabel || '')) {
|
|||||||
return sel;
|
return sel;
|
||||||
});
|
});
|
||||||
this.selectionService.setSelections(updated);
|
this.selectionService.setSelections(updated);
|
||||||
|
// Call after setSelections
|
||||||
|
this.refreshBlockedLabels(this.selectedLabel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -630,6 +645,8 @@ if (this.twoGroupLabels.includes(this.selectedLabel || '')) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.selectionService.setSelections(updatedSelections);
|
this.selectionService.setSelections(updatedSelections);
|
||||||
|
// Call after setSelections
|
||||||
|
this.refreshBlockedLabels(this.selectedLabel);
|
||||||
this.padValue = '';
|
this.padValue = '';
|
||||||
this.updateCanPrint();
|
this.updateCanPrint();
|
||||||
}
|
}
|
||||||
@ -662,6 +679,8 @@ if (this.twoGroupLabels.includes(this.selectedLabel || '')) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.selectionService.setSelections(updatedSelections);
|
this.selectionService.setSelections(updatedSelections);
|
||||||
|
// Call after setSelections
|
||||||
|
this.refreshBlockedLabels(this.selectedLabel);
|
||||||
// Only increment stage if not at the last stage (PLP)
|
// Only increment stage if not at the last stage (PLP)
|
||||||
|
|
||||||
if (this.wspTicketStage < 2) {
|
if (this.wspTicketStage < 2) {
|
||||||
@ -759,6 +778,8 @@ if (this.twoGroupLabels.includes(this.selectedLabel || '')) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.selectionService.setSelections(updatedSelections);
|
this.selectionService.setSelections(updatedSelections);
|
||||||
|
// Call after setSelections
|
||||||
|
this.refreshBlockedLabels(this.selectedLabel);
|
||||||
|
|
||||||
const currentTotal = updatedSelections.find(sel => sel.label === targetLabel)?.total || 0;
|
const currentTotal = updatedSelections.find(sel => sel.label === targetLabel)?.total || 0;
|
||||||
if (currentTotal === 0 && value > 0) {
|
if (currentTotal === 0 && value > 0) {
|
||||||
@ -766,6 +787,8 @@ if (this.twoGroupLabels.includes(this.selectedLabel || '')) {
|
|||||||
this.selectionService.setSelections(
|
this.selectionService.setSelections(
|
||||||
updatedSelections.filter(sel => sel.label !== targetLabel || sel.numbers.length > 0)
|
updatedSelections.filter(sel => sel.label !== targetLabel || sel.numbers.length > 0)
|
||||||
);
|
);
|
||||||
|
// Call after setSelections
|
||||||
|
this.refreshBlockedLabels(this.selectedLabel);
|
||||||
this.wspTicketStage = 0;
|
this.wspTicketStage = 0;
|
||||||
this.padValue = '';
|
this.padValue = '';
|
||||||
this.selectedNumbers = [];
|
this.selectedNumbers = [];
|
||||||
@ -937,9 +960,13 @@ if (this.twoGroupLabels.includes(this.selectedLabel || '')) {
|
|||||||
const currentSelections = this.selectionService.getSelections();
|
const currentSelections = this.selectionService.getSelections();
|
||||||
const nonWSPSelections = currentSelections.filter(sel => !['WNP', 'SHP', 'PLP'].includes(sel.label));
|
const nonWSPSelections = currentSelections.filter(sel => !['WNP', 'SHP', 'PLP'].includes(sel.label));
|
||||||
this.selectionService.setSelections([...nonWSPSelections, ...virtualRows]);
|
this.selectionService.setSelections([...nonWSPSelections, ...virtualRows]);
|
||||||
|
// Call after setSelections
|
||||||
|
this.refreshBlockedLabels(this.selectedLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.selectionService.finalizeCurrentRow();
|
this.selectionService.finalizeCurrentRow();
|
||||||
|
// Call after finalizeCurrentRow
|
||||||
|
this.refreshBlockedLabels(null);
|
||||||
this.resetSelections();
|
this.resetSelections();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1092,7 +1119,23 @@ 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 =>
|
||||||
|
// 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];
|
||||||
|
// });
|
||||||
let expanded = leg.flatMap((n) => {
|
let expanded = leg.flatMap((n) => {
|
||||||
if (n === 'F') {
|
if (n === 'F') {
|
||||||
// Expand F → horse numbers, no extra dashes
|
// Expand F → horse numbers, no extra dashes
|
||||||
@ -1116,7 +1159,21 @@ 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 =>
|
||||||
|
// 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];
|
||||||
|
// });
|
||||||
displayNumbers = displayNumbers.flatMap((n) => {
|
displayNumbers = displayNumbers.flatMap((n) => {
|
||||||
if (n === 'F') {
|
if (n === 'F') {
|
||||||
// Expand F → horse numbers, no extra dashes
|
// Expand F → horse numbers, no extra dashes
|
||||||
@ -1392,7 +1449,6 @@ try {
|
|||||||
// this.erase(); // Uncomment if you want to clear on error
|
// this.erase(); // Uncomment if you want to clear on error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------- BACK END ENDS HERE -----------------------------------------------------
|
//---------------------------------------------- BACK END ENDS HERE -----------------------------------------------------
|
||||||
// read issueT from localStorage
|
// read issueT from localStorage
|
||||||
let issueT: any = null;
|
let issueT: any = null;
|
||||||
@ -1500,6 +1556,8 @@ try {
|
|||||||
//--------------------Ended Print here -----------------------------
|
//--------------------Ended Print here -----------------------------
|
||||||
|
|
||||||
this.selectionService.finalizeCurrentRow();
|
this.selectionService.finalizeCurrentRow();
|
||||||
|
// Call after finalizeCurrentRow
|
||||||
|
this.refreshBlockedLabels(null);
|
||||||
this.resetSelections();
|
this.resetSelections();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1507,6 +1565,7 @@ try {
|
|||||||
erase() {
|
erase() {
|
||||||
this.selectionService.clearSelections();
|
this.selectionService.clearSelections();
|
||||||
this.resetSelections();
|
this.resetSelections();
|
||||||
|
this.refreshBlockedLabels(null);
|
||||||
this.cdr.markForCheck(); // <-- Force UI update
|
this.cdr.markForCheck(); // <-- Force UI update
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1532,8 +1591,8 @@ try {
|
|||||||
this.fieldInput = '';
|
this.fieldInput = '';
|
||||||
this.fieldFEntered = false;
|
this.fieldFEntered = false;
|
||||||
this.wspTicketStage = 0;
|
this.wspTicketStage = 0;
|
||||||
// Explicitly reset blocked labels
|
// Explicitly reset blocked labels (no current label)
|
||||||
this.blockedLabels = this.labelRestrictionService.getBlockedLabels([]);
|
this.refreshBlockedLabels(null);
|
||||||
this.updateCanPrint();
|
this.updateCanPrint();
|
||||||
this.sharedStateService.updateSharedData({ type: 'multiLegPoolEnd', value: null });
|
this.sharedStateService.updateSharedData({ type: 'multiLegPoolEnd', value: null });
|
||||||
this.cdr.markForCheck(); // <-- Force UI update
|
this.cdr.markForCheck(); // <-- Force UI update
|
||||||
@ -1816,6 +1875,8 @@ try {
|
|||||||
this.poolReplaceOpen = false;
|
this.poolReplaceOpen = false;
|
||||||
// Update selection service with new label
|
// Update selection service with new label
|
||||||
this.selectionService.updatePartial({ label });
|
this.selectionService.updatePartial({ label });
|
||||||
|
// recompute blocked labels including newly-selected label
|
||||||
|
this.refreshBlockedLabels(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
closePoolReplaceModal() { this.poolReplaceOpen = false; }
|
closePoolReplaceModal() { this.poolReplaceOpen = false; }
|
||||||
@ -1856,6 +1917,8 @@ try {
|
|||||||
this.runnerCount = this.getRunnerCountForLeg(this.multiLegBaseRaceIdx, 0) || 12;
|
this.runnerCount = this.getRunnerCountForLeg(this.multiLegBaseRaceIdx, 0) || 12;
|
||||||
this.numbers = Array.from({ length: 30 }, (_, i) => i + 1);
|
this.numbers = Array.from({ length: 30 }, (_, i) => i + 1);
|
||||||
this.numbersFlat = this.numberRows.flat();
|
this.numbersFlat = this.numberRows.flat();
|
||||||
|
// Call after pool change
|
||||||
|
this.refreshBlockedLabels('TRE');
|
||||||
}
|
}
|
||||||
|
|
||||||
closeTrePopup() { this.trePopupVisible = false; }
|
closeTrePopup() { this.trePopupVisible = false; }
|
||||||
@ -1920,6 +1983,14 @@ try {
|
|||||||
currentRow.value <= 100 &&
|
currentRow.value <= 100 &&
|
||||||
currentRow.total > 0;
|
currentRow.total > 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
// add this in the component class (near other helpers)
|
||||||
|
private refreshBlockedLabels(currentLabel?: string | null) {
|
||||||
|
// Pass finalized selections and optionally the in-progress/current label
|
||||||
|
const finalized = this.selectionService.getSelections();
|
||||||
|
this.blockedLabels = this.labelRestrictionService.getBlockedLabels(finalized, currentLabel ?? this.selectedLabel);
|
||||||
|
console.log('[DEBUG] refreshBlockedLabels -> selectedLabel:', currentLabel ?? this.selectedLabel, 'blocked:', Array.from(this.blockedLabels));
|
||||||
|
// Ensure OnPush UI updates
|
||||||
|
try { this.cdr.markForCheck(); } catch (e) { /* ignore */ }
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user