Feature: Recording the nutritional and ice cream related values in the database

This commit is contained in:
2023-12-25 10:57:44 +05:30
parent efaaf9d431
commit cd6a5e129f
14 changed files with 391 additions and 8 deletions
@@ -15,6 +15,8 @@ export class ProductGroupDetailComponent implements OnInit, AfterViewInit {
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
form: FormGroup<{
name: FormControl<string | null>;
nutritional: FormControl<boolean>;
iceCream: FormControl<boolean>;
}>;
item: ProductGroup = new ProductGroup();
@@ -27,6 +29,8 @@ export class ProductGroupDetailComponent implements OnInit, AfterViewInit {
) {
this.form = new FormGroup({
name: new FormControl<string | null>(null),
nutritional: new FormControl<boolean>(false, { nonNullable: true }),
iceCream: new FormControl<boolean>(false, { nonNullable: true }),
});
}
@@ -42,6 +46,8 @@ export class ProductGroupDetailComponent implements OnInit, AfterViewInit {
this.item = item;
this.form.setValue({
name: this.item.name,
nutritional: this.item.nutritional,
iceCream: this.item.iceCream,
});
}
@@ -68,6 +74,8 @@ export class ProductGroupDetailComponent implements OnInit, AfterViewInit {
getItem(): ProductGroup {
const formModel = this.form.value;
this.item.name = formModel.name ?? '';
this.item.nutritional = formModel.nutritional ?? false;
this.item.iceCream = formModel.iceCream ?? false;
return this.item;
}
}