feat : added bkp (working)
This commit is contained in:
parent
06bb867dc5
commit
3f1081b014
@ -600,3 +600,7 @@ button.ready-to-print {
|
||||
background-color: #757373;
|
||||
/* border-color: #b1b1b1; */
|
||||
}
|
||||
.btn-bkp {
|
||||
min-width: 60px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@ -25,6 +25,10 @@
|
||||
shash ENTER
|
||||
</button>
|
||||
<button class="btn btn-dark">COPY</button>
|
||||
|
||||
<button class="btn btn-danger btn-bkp" *ngIf="showBackspace" (click)="removeLastNumber()">BKP</button>
|
||||
|
||||
|
||||
<button class="btn btn-dark">CLEAR</button>
|
||||
<button class="btn btn-dark">PR</button>
|
||||
</div>
|
||||
|
||||
@ -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<T>(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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user