From 7738818b3e83db6586398e30e62e7c321ddaee98 Mon Sep 17 00:00:00 2001 From: karthik Date: Sat, 9 Aug 2025 16:18:52 +0530 Subject: [PATCH] fix : enabled print and disable enter after 5 rows --- .../touch-pad-menu.component.html | 4 +- .../touch-pad-menu.component.ts | 75 ++++++++++++------- 2 files changed, 50 insertions(+), 29 deletions(-) diff --git a/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.html b/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.html index 27ea318..4bbc70b 100755 --- a/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.html +++ b/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.html @@ -90,10 +90,10 @@
- +
- +
diff --git a/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.ts b/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.ts index 00fcd3b..b359a36 100755 --- a/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.ts +++ b/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.ts @@ -535,41 +535,44 @@ if (this.twoGroupLabels.includes(this.selectedLabel || '')) { onPadEnter() { - if (!this.canPrint) { - this.print(); - } + // Disable Enter if maxRowsReached + if (this.maxRowsReached) return; - const value = parseFloat(this.padValue) || 0; + if (!this.canPrint) { + this.print(); + } - if (this.selectedLabel === 'WSP') { - const labels = ['WIN', 'SHP', 'PLC']; - const targetLabel = labels[this.wspTicketStage]; + const value = parseFloat(this.padValue) || 0; - 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; - }); + if (this.selectedLabel === 'WSP') { + const labels = ['WIN', 'SHP', 'PLC']; + const targetLabel = labels[this.wspTicketStage]; - 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.wspTicketStage = (this.wspTicketStage + 1) % 3; - this.padValue = ''; - this.updateCanPrint(); + this.selectionService.setSelections(updatedSelections); - 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() { + // 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;