fix : added different logic to enter and print

This commit is contained in:
karthik 2025-07-31 12:23:08 +05:30
parent e66842d510
commit de01c3f9d1
2 changed files with 46 additions and 6 deletions

View File

@ -104,10 +104,22 @@
</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)="print()">Print</button>
<button
class="btn btn-secondary w-100 number-button"
[disabled]="!canPrint || currentSelections.length === 0"
(click)="print()"
>
Print
</button>
</div>
</div>
</div>

View File

@ -299,9 +299,31 @@ export class TouchPadMenuComponent implements OnInit, OnDestroy {
}
onPadEnter() {
if (this.canPrint) {
this.print();
}
// Only allows entry if less than 5 rows are filled
if (this.maxRowsReached) return;
const value = parseFloat(this.padValue) || 0;
if (!this.selectedLabel || !this.selectedNumbers.length || value === 0) return; // Basic validation
// Finalize current row selection
this.selectionService.finalizeCurrentRow();
// Clear current row selection, but do NOT clear the existing rows,
// so user can keep filling rows up to 5
this.selectedLabel = null;
this.selectedNumbers = [];
this.padValue = '';
this.canPrint = false;
this.isBoxed = false;
// Reset all group stages
this.tanGroupStage = 0;
this.tanGroups = [[], [], []];
this.isFirstGroupComplete = false;
this.firstGroup = [];
this.secondGroup = [];
this.multiLegStage = 0;
this.multiLegGroups = [[], [], [], [], []];
}
onShashEnter() {
@ -369,13 +391,19 @@ export class TouchPadMenuComponent implements OnInit, OnDestroy {
}
print() {
// Don't print if no rows
if (this.currentSelections.length === 0) return;
const selectionsTotal = this.currentSelections.reduce((sum, sel) => sum + sel.total, 0);
if (selectionsTotal + this.currentTotal > 5000) {
this.showLimitPopup = true;
return;
}
// Submit all rows
this.selectionService.finalizeCurrentRow();
this.resetSelections();
// Clear everything after print
this.erase();
}
erase() {