fix : disabled some keys in label

This commit is contained in:
karthik 2025-07-24 17:21:21 +05:30
parent 1cb49f2dc4
commit e135911c5e
3 changed files with 30 additions and 11 deletions

View File

@ -25,23 +25,31 @@ export class SelectionService {
// ✅ Update only part of the current row (label / numbers / value) // ✅ Update only part of the current row (label / numbers / value)
updatePartial(update: Partial<SelectionData>) { updatePartial(update: Partial<SelectionData>) {
const current = this.currentRow.value; const current = this.currentRow.value;
const updated: SelectionData = { const updated: SelectionData = {
...current, ...current,
...update ...update
}; };
// Recalculate total only if both value and numbers exist
if (updated.numbers.length > 0 && updated.value > 0) { const multiplyByTenLabels = ['WIN', 'SHP', 'THP', 'PLC'];
if (updated.numbers.length > 0 && updated.value > 0) {
if (multiplyByTenLabels.includes(updated.label)) {
updated.total = updated.numbers.length * updated.value * 10; updated.total = updated.numbers.length * updated.value * 10;
} else { } else {
updated.total = 0; // For other labels, define your logic e.g. no multiply by 10 or another multiplier
updated.total = updated.numbers.length * updated.value;
// Or whatever logic you need here
} }
} else {
this.currentRow.next(updated); updated.total = 0;
} }
this.currentRow.next(updated);
}
// ✅ Finalize the current row and push it to the finalized list // ✅ Finalize the current row and push it to the finalized list
finalizeCurrentRow() { finalizeCurrentRow() {
const completed = this.currentRow.value; const completed = this.currentRow.value;

View File

@ -9,10 +9,12 @@
<button class="btn btn-dark two" (click)="erase()">ERASE</button> <button class="btn btn-dark two" (click)="erase()">ERASE</button>
<button class="btn btn-secondary three">BOX</button> <button class="btn btn-secondary three">BOX</button>
<button class="btn btn-secondary four">FIELD</button> <button class="btn btn-secondary four">FIELD</button>
<!-- <button class="btn btn-secondary four">Enter</button> -->
</div> </div>
<!-- Right Group: COPY, CLEAR, PR --> <!-- Right Group: COPY, CLEAR, PR -->
<div class="d-flex flex-wrap justify-content-center gap-2 second"> <div class="d-flex flex-wrap justify-content-center gap-2 second">
<button class="btn btn-dark">Enter</button>
<button class="btn btn-dark">COPY</button> <button class="btn btn-dark">COPY</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>
@ -31,12 +33,13 @@
<button <button
class="btn w-100 number-button" class="btn w-100 number-button"
[ngClass]="'btn-color-' + i" [ngClass]="'btn-color-' + i"
[disabled]="!ticketingActive || !!selectedLabel || maxRowsReached" [disabled]="!ticketingActive || !!selectedLabel || maxRowsReached || isLabelDisabled(label)"
(click)="selectLabel(label)" (click)="selectLabel(label)"
> >
{{ label }} {{ label }}
</button> </button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -34,6 +34,9 @@ export class TouchPadMenuComponent implements OnInit {
maxRowsReached: boolean = false; maxRowsReached: boolean = false;
// ✅ Disabled labels list
disabledLabels: string[] = ['SHW', 'SJP'];
constructor(private selectionService: SelectionService) {} constructor(private selectionService: SelectionService) {}
ngOnInit() { ngOnInit() {
@ -64,6 +67,11 @@ export class TouchPadMenuComponent implements OnInit {
); );
} }
// ✅ Check if label is disabled
isLabelDisabled(label: string): boolean {
return this.disabledLabels.includes(label);
}
selectLabel(label: string) { selectLabel(label: string) {
this.selectedLabel = label; this.selectedLabel = label;
this.selectedNumbers = []; this.selectedNumbers = [];