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:
tanshu committed 2026-08-26 06:00:13 +00:00
1 parent fe5e4a2308
commit e3719faddd
79 files changed
+737 -990

No files matched your search

@@ -1,6 +1,6 @@
<h2>Purchase Entries</h2>
<form class="flex-col" [formRoot]="form">
<form class="flex-col" [formRoot]="form" (submit)="$event.preventDefault(); show()">
<div class="row-container">
<mat-form-field class="flex-auto basis-2-5">
<mat-label>Start Date</mat-label>
@@ -14,7 +14,7 @@
<mat-datepicker-toggle matSuffix [for]="finishDate"></mat-datepicker-toggle>
<mat-datepicker #finishDate></mat-datepicker>
</mat-form-field>
<button mat-raised-button class="flex-auto basis-1-5" color="primary" (click)="show()">Show</button>
<button mat-raised-button type="submit" class="flex-auto basis-1-5" color="primary">Show</button>
</div>
</form>
@if (resource.isLoading()) {
@@ -1,5 +1,5 @@
import { CurrencyPipe, DecimalPipe, PercentPipe } 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';
@@ -17,14 +17,17 @@ import { PurchaseEntries } from './purchase-entries';
import { PurchaseEntriesService } from './purchase-entries.service';
export interface PurchaseEntriesFormData {
startDate: moment.Moment | null | string;
finishDate: moment.Moment | null | string;
startDate: Date;
finishDate: Date;
}
@Component({
selector: 'app-purchase-entries',
templateUrl: './purchase-entries.component.html',
styleUrls: ['./purchase-entries.component.css'],
host: {
'(window:keydown.f2)': 'focusDate($event)',
},
imports: [
FormField,
@@ -101,10 +104,10 @@ export class PurchaseEntriesComponent {
});
formModel = linkedSignal({
source: () => null,
computation: (): PurchaseEntriesFormData => ({
startDate: moment(new Date()),
finishDate: moment(new Date()),
source: () => this.info(),
computation: (info: PurchaseEntries): PurchaseEntriesFormData => ({
startDate: info.startDate ? moment(info.startDate, 'DD-MMM-YYYY').toDate() : new Date(),
finishDate: info.finishDate ? moment(info.finishDate, 'DD-MMM-YYYY').toDate() : new Date(),
}),
});
@@ -114,7 +117,6 @@ export class PurchaseEntriesComponent {
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['date', 'supplier', 'product', 'quantity', 'rate', 'tax', 'discount', 'amount'];
@HostListener('window:keydown.f2', ['$event'])
focusDate(event: Event) {
event.preventDefault();
this.form().focusBoundControl();