Skip to content

Commit b23d083

Browse files
author
LexCoder17
committed
add keyboard events to the cashier component
1 parent 2d51b45 commit b23d083

6 files changed

Lines changed: 269 additions & 33 deletions

File tree

package-lock.json

Lines changed: 39 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/components/calculator/calculator.component.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<div #calculatorContainer class="calculator" tabindex="-1">
2-
<div class="display" (dblclick)="selectAll()" [class.selected]="isSelected()">
2+
<div
3+
class="display"
4+
(dblclick)="selectAll()"
5+
[class.selected]="isSelected()"
6+
[class.editing]="selectedItemId() !== null"
7+
>
38
<ng-container *ngIf="isMultiplying()">
49
<div class="multiply-label">
510
<span *ngIf="multiplyMode() === 'add'">{{

src/app/components/calculator/calculator.component.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@
3838
}
3939
}
4040

41+
&.editing {
42+
background: rgba($success, 0.2);
43+
box-shadow:
44+
inset 0 2px 8px rgba(0, 0, 0, 0.2),
45+
0 0 0 3px rgba($success, 0.6);
46+
border: 2px solid $success;
47+
48+
.display-value,
49+
.quantity-display {
50+
color: $success;
51+
font-weight: 800;
52+
}
53+
}
54+
4155
.multiply-label {
4256
font-size: 0.875rem;
4357
font-weight: 600;

src/app/components/calculator/calculator.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export class CalculatorComponent implements AfterViewInit {
3434
// Inputs
3535
lastItemPrice = input<number | null>(null);
3636
itemsCount = input<number>(0);
37+
selectedItemId = input<number | null>(null);
3738

3839
// Outputs
3940
addItem = output<CalculatorAddEvent>();

src/app/components/cashier/cashier.component.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<app-calculator
4242
[lastItemPrice]="getLastItemPrice()"
4343
[itemsCount]="items().length"
44+
[selectedItemId]="selectedItemId()"
4445
(addItem)="onCalculatorAdd($event)"
4546
(multiplyConfirm)="onCalculatorMultiplyConfirm($event)"
4647
(looseProductRequest)="openLooseProductModal()"
@@ -409,6 +410,7 @@ <h2>
409410
<div class="form-group">
410411
<label for="weight">Weight (kg):</label>
411412
<input
413+
#weightInput
412414
id="weight"
413415
type="number"
414416
step="0.001"
@@ -420,6 +422,7 @@ <h2>
420422
looseProductWeight() && parseFloat(looseProductWeight()) <= 0
421423
"
422424
[readonly]="useScaleWeight() && scaleConnected()"
425+
(keydown.enter)="handleLooseProductEnter($event)"
423426
/>
424427
<small *ngIf="useScaleWeight() && scaleConnected()" class="help-text">
425428
<i class="fas fa-info-circle"></i>
@@ -430,6 +433,7 @@ <h2>
430433
<div class="form-group">
431434
<label for="pricePerKg">Price per kg ($):</label>
432435
<input
436+
#pricePerKgInput
433437
id="pricePerKg"
434438
type="number"
435439
step="0.01"
@@ -441,6 +445,7 @@ <h2>
441445
looseProductPricePerKg() &&
442446
parseFloat(looseProductPricePerKg()) <= 0
443447
"
448+
(keydown.enter)="handleLooseProductEnter($event)"
444449
/>
445450
</div>
446451

0 commit comments

Comments
 (0)