fix : labels are enabling after printing success
This commit is contained in:
parent
6d752fcfb2
commit
84d0566d43
@ -4,7 +4,8 @@ import {
|
||||
OnInit,
|
||||
OnDestroy,
|
||||
NgZone,
|
||||
ChangeDetectionStrategy
|
||||
ChangeDetectionStrategy,
|
||||
ChangeDetectorRef // <-- Add this import
|
||||
} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Subscription } from 'rxjs';
|
||||
@ -105,7 +106,8 @@ export class TouchPadMenuComponent implements OnInit, OnDestroy {
|
||||
selectionService: SelectionService,
|
||||
sharedStateService: SharedStateService,
|
||||
labelRestrictionService: LabelRestrictionService,
|
||||
private ngZone: NgZone
|
||||
private ngZone: NgZone,
|
||||
private cdr: ChangeDetectorRef // <-- Inject ChangeDetectorRef
|
||||
) {
|
||||
this.selectionService = selectionService;
|
||||
this.sharedStateService = sharedStateService;
|
||||
@ -976,6 +978,7 @@ async printTicket() {
|
||||
const selectionsTotal = this.currentSelections.reduce((sum, sel) => sum + sel.total, 0);
|
||||
if (selectionsTotal + this.currentTotal > 5000) {
|
||||
this.showLimitPopup = true;
|
||||
this.cdr.markForCheck(); // <-- Ensure popup visibility updates
|
||||
return;
|
||||
}
|
||||
console.log('[DEBUG] Horse numbers for selected race:', this.getHorseNumbersForSelectedRace());
|
||||
@ -1019,6 +1022,7 @@ async printTicket() {
|
||||
|
||||
if (allRows.length === 0) {
|
||||
console.warn("No valid rows to print.");
|
||||
this.cdr.markForCheck(); // <-- Ensure UI updates
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1389,27 +1393,26 @@ try {
|
||||
// If HTTP status not OK, treat as failure
|
||||
if (!commitResp.ok) {
|
||||
console.error('❌ /isr/commit HTTP error', commitResp.status, commitJson ?? txt);
|
||||
this.cdr.markForCheck(); // <-- Ensure UI updates on error
|
||||
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)) {
|
||||
console.error('❌ /isr/commit failed or returned success=false:', commitJson);
|
||||
// Optionally surface error message from server
|
||||
if (commitJson && commitJson.message) {
|
||||
console.error('Server message:', commitJson.message);
|
||||
}
|
||||
this.cdr.markForCheck(); // <-- Ensure UI updates on error
|
||||
return; // do not proceed to printing
|
||||
}
|
||||
|
||||
// If we reach here, commit succeeded
|
||||
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 -----------------------------------------------------
|
||||
// 🖨️ Send to printer API
|
||||
@ -1511,6 +1514,7 @@ try {
|
||||
erase() {
|
||||
this.selectionService.clearSelections();
|
||||
this.resetSelections();
|
||||
this.cdr.markForCheck(); // <-- Force UI update
|
||||
}
|
||||
|
||||
resetSelections() {
|
||||
@ -1535,9 +1539,11 @@ try {
|
||||
this.fieldInput = '';
|
||||
this.fieldFEntered = false;
|
||||
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.cdr.markForCheck(); // <-- Force UI update
|
||||
}
|
||||
|
||||
toggleBoxMode() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user