Removed Recipe Template as it was not needed.

Moved host listeners to the component declaration.
Form submit on Return fixed.
This commit is contained in:
2026-08-26 06:00:13 +00:00
parent fe5e4a2308
commit e3719faddd
79 changed files with 737 additions and 990 deletions
@@ -1,5 +1,5 @@
import { CurrencyPipe, DecimalPipe } from '@angular/common';
import { Component, HostListener, inject, linkedSignal, computed, signal, input } from '@angular/core';
import { Component, inject, linkedSignal, computed, signal, input } from '@angular/core';
import { form, FormField, FormRoot } from '@angular/forms/signals';
import { MatButtonModule } from '@angular/material/button';
import { MatDatepickerModule } from '@angular/material/datepicker';
@@ -18,14 +18,17 @@ import { PurchasesItem } from './purchases-item';
import { PurchasesService } from './purchases.service';
export interface PurchasesFormData {
startDate: moment.Moment | null | string;
finishDate: moment.Moment | null | string;
startDate: Date;
finishDate: Date;
}
@Component({
selector: 'app-purchases',
templateUrl: './purchases.component.html',
styleUrls: ['./purchases.component.css'],
host: {
'(window:keydown.f2)': 'focusDate($event)',
},
imports: [
FormField,
@@ -93,10 +96,10 @@ export class PurchasesComponent {
});
formModel = linkedSignal({
source: () => null,
computation: (): PurchasesFormData => ({
startDate: moment(new Date()),
finishDate: moment(new Date()),
source: () => this.info(),
computation: (info: Purchases): PurchasesFormData => ({
startDate: info.startDate ? moment(info.startDate, 'DD-MMM-YYYY').toDate() : new Date(),
finishDate: info.finishDate ? moment(info.finishDate, 'DD-MMM-YYYY').toDate() : new Date(),
}),
});
@@ -106,7 +109,6 @@ export class PurchasesComponent {
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['product', 'quantity', 'rate', 'amount'];
@HostListener('window:keydown.f2', ['$event'])
focusDate(event: Event) {
event.preventDefault();
this.form().focusBoundControl();