fix : enabled print and disable enter after 5 rows
This commit is contained in:
parent
cd53b84d0a
commit
7738818b3e
@ -90,10 +90,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<div class="col-6">
|
<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>
|
||||||
<div class="col-6">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -535,41 +535,44 @@ if (this.twoGroupLabels.includes(this.selectedLabel || '')) {
|
|||||||
|
|
||||||
|
|
||||||
onPadEnter() {
|
onPadEnter() {
|
||||||
if (!this.canPrint) {
|
// Disable Enter if maxRowsReached
|
||||||
this.print();
|
if (this.maxRowsReached) return;
|
||||||
}
|
|
||||||
|
|
||||||
const value = parseFloat(this.padValue) || 0;
|
if (!this.canPrint) {
|
||||||
|
this.print();
|
||||||
|
}
|
||||||
|
|
||||||
if (this.selectedLabel === 'WSP') {
|
const value = parseFloat(this.padValue) || 0;
|
||||||
const labels = ['WIN', 'SHP', 'PLC'];
|
|
||||||
const targetLabel = labels[this.wspTicketStage];
|
|
||||||
|
|
||||||
const updatedSelections = this.selectionService.getSelections().map(sel => {
|
if (this.selectedLabel === 'WSP') {
|
||||||
if (sel.label === targetLabel && JSON.stringify(sel.numbers) === JSON.stringify(this.selectedNumbers)) {
|
const labels = ['WIN', 'SHP', 'PLC'];
|
||||||
return {
|
const targetLabel = labels[this.wspTicketStage];
|
||||||
...sel,
|
|
||||||
value,
|
|
||||||
total: value * (sel.numbers?.length || 0) * 10
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return sel;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.selectionService.setSelections(updatedSelections);
|
const updatedSelections = this.selectionService.getSelections().map(sel => {
|
||||||
|
if (sel.label === targetLabel && JSON.stringify(sel.numbers) === JSON.stringify(this.selectedNumbers)) {
|
||||||
|
return {
|
||||||
|
...sel,
|
||||||
|
value,
|
||||||
|
total: value * (sel.numbers?.length || 0) * 10
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return sel;
|
||||||
|
});
|
||||||
|
|
||||||
// Move to next stage
|
this.selectionService.setSelections(updatedSelections);
|
||||||
this.wspTicketStage = (this.wspTicketStage + 1) % 3;
|
|
||||||
this.padValue = '';
|
|
||||||
this.updateCanPrint();
|
|
||||||
|
|
||||||
return;
|
// Move to next stage
|
||||||
|
this.wspTicketStage = (this.wspTicketStage + 1) % 3;
|
||||||
|
this.padValue = '';
|
||||||
|
this.updateCanPrint();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ✅ Default path: finalize row and reset input
|
||||||
|
this.print();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ✅ Default path: finalize row and reset input
|
|
||||||
this.print();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------//
|
||||||
|
|
||||||
@ -672,6 +675,11 @@ if (this.twoGroupLabels.includes(this.selectedLabel || '')) {
|
|||||||
//---------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
updateCanPrint() {
|
updateCanPrint() {
|
||||||
|
// Disable Enter if maxRowsReached
|
||||||
|
if (this.maxRowsReached) {
|
||||||
|
this.canPrint = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.canPrint = this.padValue.trim().length > 0 && /^[0-9]+$/.test(this.padValue);
|
this.canPrint = this.padValue.trim().length > 0 && /^[0-9]+$/.test(this.padValue);
|
||||||
if (this.multiLegLabels.includes(this.selectedLabel || '')) {
|
if (this.multiLegLabels.includes(this.selectedLabel || '')) {
|
||||||
const maxLegs = this.getMaxLegs(this.currentPool || '');
|
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() {
|
print() {
|
||||||
const selectionsTotal = this.currentSelections.reduce((sum, sel) => sum + sel.total, 0);
|
const selectionsTotal = this.currentSelections.reduce((sum, sel) => sum + sel.total, 0);
|
||||||
let currentRowAmount = 0;
|
let currentRowAmount = 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user