fix : labels are enabling after printing success
This commit is contained in:
parent
6d752fcfb2
commit
84d0566d43
@ -4,7 +4,8 @@ import {
|
|||||||
OnInit,
|
OnInit,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
NgZone,
|
NgZone,
|
||||||
ChangeDetectionStrategy
|
ChangeDetectionStrategy,
|
||||||
|
ChangeDetectorRef // <-- Add this import
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
@ -105,7 +106,8 @@ export class TouchPadMenuComponent implements OnInit, OnDestroy {
|
|||||||
selectionService: SelectionService,
|
selectionService: SelectionService,
|
||||||
sharedStateService: SharedStateService,
|
sharedStateService: SharedStateService,
|
||||||
labelRestrictionService: LabelRestrictionService,
|
labelRestrictionService: LabelRestrictionService,
|
||||||
private ngZone: NgZone
|
private ngZone: NgZone,
|
||||||
|
private cdr: ChangeDetectorRef // <-- Inject ChangeDetectorRef
|
||||||
) {
|
) {
|
||||||
this.selectionService = selectionService;
|
this.selectionService = selectionService;
|
||||||
this.sharedStateService = sharedStateService;
|
this.sharedStateService = sharedStateService;
|
||||||
@ -976,6 +978,7 @@ async printTicket() {
|
|||||||
const selectionsTotal = this.currentSelections.reduce((sum, sel) => sum + sel.total, 0);
|
const selectionsTotal = this.currentSelections.reduce((sum, sel) => sum + sel.total, 0);
|
||||||
if (selectionsTotal + this.currentTotal > 5000) {
|
if (selectionsTotal + this.currentTotal > 5000) {
|
||||||
this.showLimitPopup = true;
|
this.showLimitPopup = true;
|
||||||
|
this.cdr.markForCheck(); // <-- Ensure popup visibility updates
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log('[DEBUG] Horse numbers for selected race:', this.getHorseNumbersForSelectedRace());
|
console.log('[DEBUG] Horse numbers for selected race:', this.getHorseNumbersForSelectedRace());
|
||||||
@ -1019,6 +1022,7 @@ async printTicket() {
|
|||||||
|
|
||||||
if (allRows.length === 0) {
|
if (allRows.length === 0) {
|
||||||
console.warn("No valid rows to print.");
|
console.warn("No valid rows to print.");
|
||||||
|
this.cdr.markForCheck(); // <-- Ensure UI updates
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1389,27 +1393,26 @@ try {
|
|||||||
// If HTTP status not OK, treat as failure
|
// If HTTP status not OK, treat as failure
|
||||||
if (!commitResp.ok) {
|
if (!commitResp.ok) {
|
||||||
console.error('❌ /isr/commit HTTP error', commitResp.status, commitJson ?? txt);
|
console.error('❌ /isr/commit HTTP error', commitResp.status, commitJson ?? txt);
|
||||||
|
this.cdr.markForCheck(); // <-- Ensure UI updates on error
|
||||||
return; // stop — don't print
|
return; // stop — don't print
|
||||||
}
|
}
|
||||||
} catch (err) {
|
|
||||||
console.error('❌ Network/error while calling /isr/commit:', err);
|
|
||||||
return; // stop — don't print
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check API-level success flag before proceeding to print
|
|
||||||
// Adjust this line if your API uses a different success indicator.
|
|
||||||
if (!(commitJson && commitJson.success === true)) {
|
if (!(commitJson && commitJson.success === true)) {
|
||||||
console.error('❌ /isr/commit failed or returned success=false:', commitJson);
|
console.error('❌ /isr/commit failed or returned success=false:', commitJson);
|
||||||
// Optionally surface error message from server
|
|
||||||
if (commitJson && commitJson.message) {
|
if (commitJson && commitJson.message) {
|
||||||
console.error('Server message:', commitJson.message);
|
console.error('Server message:', commitJson.message);
|
||||||
}
|
}
|
||||||
|
this.cdr.markForCheck(); // <-- Ensure UI updates on error
|
||||||
return; // do not proceed to printing
|
return; // do not proceed to printing
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we reach here, commit succeeded
|
// If we reach here, commit succeeded
|
||||||
console.log('✅ /isr/commit success:', commitJson);
|
console.log('✅ /isr/commit success:', commitJson);
|
||||||
|
this.erase(); // <-- Clear selections after successful print
|
||||||
|
} catch (error) {
|
||||||
|
console.error("❌ Print failed:", error);
|
||||||
|
this.cdr.markForCheck(); // <-- Ensure UI updates on error
|
||||||
|
// Optionally, decide whether to clear selections on failure
|
||||||
|
// this.erase(); // Uncomment if you want to clear on error
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------- BACK END ENDS HERE -----------------------------------------------------
|
//---------------------------------------------- BACK END ENDS HERE -----------------------------------------------------
|
||||||
// 🖨️ Send to printer API
|
// 🖨️ Send to printer API
|
||||||
@ -1511,6 +1514,7 @@ try {
|
|||||||
erase() {
|
erase() {
|
||||||
this.selectionService.clearSelections();
|
this.selectionService.clearSelections();
|
||||||
this.resetSelections();
|
this.resetSelections();
|
||||||
|
this.cdr.markForCheck(); // <-- Force UI update
|
||||||
}
|
}
|
||||||
|
|
||||||
resetSelections() {
|
resetSelections() {
|
||||||
@ -1535,9 +1539,11 @@ try {
|
|||||||
this.fieldInput = '';
|
this.fieldInput = '';
|
||||||
this.fieldFEntered = false;
|
this.fieldFEntered = false;
|
||||||
this.wspTicketStage = 0;
|
this.wspTicketStage = 0;
|
||||||
// Clear multi-leg display in Navbar
|
// Explicitly reset blocked labels
|
||||||
|
this.blockedLabels = this.labelRestrictionService.getBlockedLabels([]);
|
||||||
|
this.updateCanPrint();
|
||||||
this.sharedStateService.updateSharedData({ type: 'multiLegPoolEnd', value: null });
|
this.sharedStateService.updateSharedData({ type: 'multiLegPoolEnd', value: null });
|
||||||
|
this.cdr.markForCheck(); // <-- Force UI update
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleBoxMode() {
|
toggleBoxMode() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user