From 3f1081b0146a46ce3d2b97148570bdd6f5409228 Mon Sep 17 00:00:00 2001 From: karthik Date: Sat, 26 Jul 2025 22:51:49 +0530 Subject: [PATCH] feat : added bkp (working) --- .../touch-pad-menu.component.css | 4 + .../touch-pad-menu.component.html | 4 + .../touch-pad-menu.component.ts | 87 ++++++++++--------- 3 files changed, 56 insertions(+), 39 deletions(-) diff --git a/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.css b/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.css index 77e85d9..11fc5a0 100755 --- a/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.css +++ b/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.css @@ -600,3 +600,7 @@ button.ready-to-print { background-color: #757373; /* border-color: #b1b1b1; */ } +.btn-bkp { + min-width: 60px; + font-weight: bold; +} 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 3069458..4505602 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 @@ -25,6 +25,10 @@ shash ENTER + + + + 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 abe44b0..884439d 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 @@ -85,6 +85,12 @@ export class TouchPadMenuComponent implements OnInit { return false; } + get showBackspace(): boolean { + return this.selectedLabel !== null && + this.selectedNumbers.length > 0 && + this.padValue.length === 0; + } + private chunk(array: T[], size: number): T[][] { return Array.from({ length: Math.ceil(array.length / size) }, (_, i) => array.slice(i * size, i * size + size) @@ -248,60 +254,63 @@ export class TouchPadMenuComponent implements OnInit { this.updateCanPrint(); } - // Calculator methods - openCalculator() { - this.calculatorOpen = true; - this.calcDisplay = ''; - } + // ✅ New method for BKP logic + removeLastNumber() { + if (!this.selectedLabel || this.selectedNumbers.length === 0) return; - closeCalculator() { - this.calculatorOpen = false; - } - - press(val: string) { - if (this.calcDisplay === 'Error') this.calcDisplay = ''; - this.calcDisplay += val; - } - - clearDisplay() { - this.calcDisplay = ''; - } - - backspace() { - this.calcDisplay = this.calcDisplay === 'Error' ? '' : this.calcDisplay.slice(0, -1); - } - - calculate() { - try { - this.calcDisplay = eval(this.calcDisplay).toString(); - } catch { - this.calcDisplay = 'Error'; + if (this.twoGroupLabels.includes(this.selectedLabel)) { + if (!this.isFirstGroupComplete && this.firstGroup.length > 0) { + this.firstGroup.pop(); + this.selectedNumbers = [...this.firstGroup]; + } else if (this.secondGroup.length > 0) { + this.secondGroup.pop(); + this.selectedNumbers = [...this.firstGroup, '-', ...this.secondGroup]; + } + this.selectionService.updatePartial({ numbers: [...this.selectedNumbers] }); + return; } + + if (this.selectedLabel === 'TAN') { + const currentGroup = this.tanGroups[this.tanGroupStage]; + if (currentGroup.length > 0) { + currentGroup.pop(); + let combined: (number | string)[] = [...this.tanGroups[0]]; + if (this.tanGroupStage > 0) combined.push('-', ...this.tanGroups[1]); + if (this.tanGroupStage > 1) combined.push('-', ...this.tanGroups[2]); + this.selectedNumbers = combined; + this.selectionService.updatePartial({ numbers: [...this.selectedNumbers] }); + } + return; + } + + this.selectedNumbers.pop(); + this.selectionService.updatePartial({ numbers: [...this.selectedNumbers] }); + } + + // Calculator and Field Modal methods (unchanged)... + openCalculator() { this.calculatorOpen = true; this.calcDisplay = ''; } + closeCalculator() { this.calculatorOpen = false; } + press(val: string) { if (this.calcDisplay === 'Error') this.calcDisplay = ''; this.calcDisplay += val; } + clearDisplay() { this.calcDisplay = ''; } + backspace() { this.calcDisplay = this.calcDisplay === 'Error' ? '' : this.calcDisplay.slice(0, -1); } + calculate() { + try { this.calcDisplay = eval(this.calcDisplay).toString(); } + catch { this.calcDisplay = 'Error'; } } - // FIELD modal methods canUseField(): boolean { const allowedLabels = ['WIN', 'SHP', 'THP', 'PLC', 'SHW']; return this.selectedLabel !== null && allowedLabels.includes(this.selectedLabel) && this.selectedNumbers.length === 0; } - openFieldModal() { - this.fieldModalOpen = true; - this.fieldInput = ''; - this.fieldFEntered = false; - } - - closeFieldModal() { - this.fieldModalOpen = false; - } - + openFieldModal() { this.fieldModalOpen = true; this.fieldInput = ''; this.fieldFEntered = false; } + closeFieldModal() { this.fieldModalOpen = false; } handleFieldKey(key: string) { if (key === 'BACK') { this.fieldInput = this.fieldInput.slice(0, -1); if (!this.fieldInput.includes('F')) this.fieldFEntered = false; return; } - if (key === 'F') { if (!this.fieldFEntered) { this.fieldFEntered = true;