fix : enabled print and disable enter after 5 rows

This commit is contained in:
karthik 2025-08-09 16:18:52 +05:30
parent cd53b84d0a
commit 7738818b3e
2 changed files with 50 additions and 29 deletions

View File

@ -90,10 +90,10 @@
</div>
</ng-container>
<div class="col-6">
<button class="btn btn-secondary w-100 number-button" [disabled]="!numericPadEnabled" (click)="onPadEnter()">Enter</button>
<button class="btn btn-secondary w-100 number-button" [disabled]="!numericPadEnabled || maxRowsReached" (click)="onPadEnter()">Enter</button>
</div>
<div class="col-6">
<button class="btn btn-secondary w-100 number-button" [disabled]="!canPrint" (click)="printTicket()">Print</button>
<button class="btn btn-secondary w-100 number-button" [disabled]="!canPrintTicket" (click)="printTicket()">Print</button>
</div>
</div>
</div>

View File

@ -535,6 +535,9 @@ if (this.twoGroupLabels.includes(this.selectedLabel || '')) {
onPadEnter() {
// Disable Enter if maxRowsReached
if (this.maxRowsReached) return;
if (!this.canPrint) {
this.print();
}
@ -672,6 +675,11 @@ if (this.twoGroupLabels.includes(this.selectedLabel || '')) {
//---------------------------------------------------------------------------------------------
updateCanPrint() {
// Disable Enter if maxRowsReached
if (this.maxRowsReached) {
this.canPrint = false;
return;
}
this.canPrint = this.padValue.trim().length > 0 && /^[0-9]+$/.test(this.padValue);
if (this.multiLegLabels.includes(this.selectedLabel || '')) {
const maxLegs = this.getMaxLegs(this.currentPool || '');
@ -679,6 +687,19 @@ if (this.twoGroupLabels.includes(this.selectedLabel || '')) {
}
}
// Add this getter for print button enable logic
get canPrintTicket(): boolean {
// At least one valid row in finalized selections or current row
const selections = this.selectionService.getSelections();
const currentRow = this.selectionService.getCurrentRow();
const hasValidRow = selections.some(
row => !!row.label && !!row.numbers && row.numbers.length > 0 && row.value > 0 && row.total > 0
) || (
!!currentRow.label && !!currentRow.numbers && currentRow.numbers.length > 0 && currentRow.value > 0 && currentRow.total > 0
);
return Boolean(hasValidRow);
}
print() {
const selectionsTotal = this.currentSelections.reduce((sum, sel) => sum + sel.total, 0);
let currentRowAmount = 0;