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:
@@ -1,5 +1,5 @@
|
||||
import { CurrencyPipe, DecimalPipe } from '@angular/common';
|
||||
import { signal, Component, HostListener, inject, input, computed, linkedSignal } from '@angular/core';
|
||||
import { signal, Component, inject, input, computed, linkedSignal } from '@angular/core';
|
||||
import { form as createForm, FormField, FormRoot } from '@angular/forms/signals';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatDatepickerModule } from '@angular/material/datepicker';
|
||||
@@ -23,7 +23,7 @@ import { ConfirmDialogComponent } from '../shared/confirm-dialog/confirm-dialog.
|
||||
import { LocalTimePipe } from '../shared/local-time.pipe';
|
||||
|
||||
export interface IncentiveFormData {
|
||||
date: moment.Moment;
|
||||
date: Date;
|
||||
incentives: { points: number }[];
|
||||
}
|
||||
|
||||
@@ -31,6 +31,9 @@ export interface IncentiveFormData {
|
||||
selector: 'app-incentive',
|
||||
templateUrl: './incentive.component.html',
|
||||
styleUrls: ['./incentive.component.css'],
|
||||
host: {
|
||||
'(window:keydown.f2)': 'focusDate($event)',
|
||||
},
|
||||
imports: [
|
||||
FormField,
|
||||
FormRoot,
|
||||
@@ -61,7 +64,7 @@ export class IncentiveComponent {
|
||||
model = linkedSignal({
|
||||
source: this.voucher,
|
||||
computation: (v): IncentiveFormData => ({
|
||||
date: moment(v.date, 'DD-MMM-YYYY'),
|
||||
date: moment(v.date, 'DD-MMM-YYYY').toDate(),
|
||||
incentives: v.incentives.map((x) => ({ points: x.points })),
|
||||
}),
|
||||
});
|
||||
@@ -75,7 +78,6 @@ export class IncentiveComponent {
|
||||
|
||||
displayedColumns = ['name', 'designation', 'department', 'daysWorked', 'points', 'amount'];
|
||||
|
||||
@HostListener('window:keydown.f2', ['$event'])
|
||||
focusDate(event: Event) {
|
||||
event.preventDefault();
|
||||
this.form().focusBoundControl();
|
||||
@@ -159,7 +161,7 @@ export class IncentiveComponent {
|
||||
getVoucher(): Voucher {
|
||||
const formModel = this.model();
|
||||
const v = this.voucher();
|
||||
v.date = formModel.date.format('DD-MMM-YYYY');
|
||||
v.date = moment(formModel.date).format('DD-MMM-YYYY');
|
||||
const array = formModel.incentives;
|
||||
|
||||
v.incentives.forEach((item: Incentive, index: number) => {
|
||||
|
||||
Reference in New Issue
Block a user