feat : added bkp (working)
This commit is contained in:
parent
06bb867dc5
commit
3f1081b014
@ -600,3 +600,7 @@ button.ready-to-print {
|
|||||||
background-color: #757373;
|
background-color: #757373;
|
||||||
/* border-color: #b1b1b1; */
|
/* border-color: #b1b1b1; */
|
||||||
}
|
}
|
||||||
|
.btn-bkp {
|
||||||
|
min-width: 60px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|||||||
@ -25,6 +25,10 @@
|
|||||||
shash ENTER
|
shash ENTER
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-dark">COPY</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">CLEAR</button>
|
||||||
<button class="btn btn-dark">PR</button>
|
<button class="btn btn-dark">PR</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -85,6 +85,12 @@ export class TouchPadMenuComponent implements OnInit {
|
|||||||
return false;
|
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[][] {
|
private chunk<T>(array: T[], size: number): T[][] {
|
||||||
return Array.from({ length: Math.ceil(array.length / size) }, (_, i) =>
|
return Array.from({ length: Math.ceil(array.length / size) }, (_, i) =>
|
||||||
array.slice(i * size, i * size + size)
|
array.slice(i * size, i * size + size)
|
||||||
@ -248,60 +254,63 @@ export class TouchPadMenuComponent implements OnInit {
|
|||||||
this.updateCanPrint();
|
this.updateCanPrint();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculator methods
|
// ✅ New method for BKP logic
|
||||||
openCalculator() {
|
removeLastNumber() {
|
||||||
this.calculatorOpen = true;
|
if (!this.selectedLabel || this.selectedNumbers.length === 0) return;
|
||||||
this.calcDisplay = '';
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
closeCalculator() {
|
if (this.selectedLabel === 'TAN') {
|
||||||
this.calculatorOpen = false;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
press(val: string) {
|
this.selectedNumbers.pop();
|
||||||
if (this.calcDisplay === 'Error') this.calcDisplay = '';
|
this.selectionService.updatePartial({ numbers: [...this.selectedNumbers] });
|
||||||
this.calcDisplay += val;
|
|
||||||
}
|
|
||||||
|
|
||||||
clearDisplay() {
|
|
||||||
this.calcDisplay = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
backspace() {
|
|
||||||
this.calcDisplay = this.calcDisplay === 'Error' ? '' : this.calcDisplay.slice(0, -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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() {
|
calculate() {
|
||||||
try {
|
try { this.calcDisplay = eval(this.calcDisplay).toString(); }
|
||||||
this.calcDisplay = eval(this.calcDisplay).toString();
|
catch { this.calcDisplay = 'Error'; }
|
||||||
} catch {
|
|
||||||
this.calcDisplay = 'Error';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIELD modal methods
|
|
||||||
canUseField(): boolean {
|
canUseField(): boolean {
|
||||||
const allowedLabels = ['WIN', 'SHP', 'THP', 'PLC', 'SHW'];
|
const allowedLabels = ['WIN', 'SHP', 'THP', 'PLC', 'SHW'];
|
||||||
return this.selectedLabel !== null && allowedLabels.includes(this.selectedLabel) && this.selectedNumbers.length === 0;
|
return this.selectedLabel !== null && allowedLabels.includes(this.selectedLabel) && this.selectedNumbers.length === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
openFieldModal() {
|
openFieldModal() { this.fieldModalOpen = true; this.fieldInput = ''; this.fieldFEntered = false; }
|
||||||
this.fieldModalOpen = true;
|
closeFieldModal() { this.fieldModalOpen = false; }
|
||||||
this.fieldInput = '';
|
|
||||||
this.fieldFEntered = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
closeFieldModal() {
|
|
||||||
this.fieldModalOpen = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
handleFieldKey(key: string) {
|
handleFieldKey(key: string) {
|
||||||
if (key === 'BACK') {
|
if (key === 'BACK') {
|
||||||
this.fieldInput = this.fieldInput.slice(0, -1);
|
this.fieldInput = this.fieldInput.slice(0, -1);
|
||||||
if (!this.fieldInput.includes('F')) this.fieldFEntered = false;
|
if (!this.fieldInput.includes('F')) this.fieldFEntered = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key === 'F') {
|
if (key === 'F') {
|
||||||
if (!this.fieldFEntered) {
|
if (!this.fieldFEntered) {
|
||||||
this.fieldFEntered = true;
|
this.fieldFEntered = true;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user