Feature: Recording the nutritional and ice cream related values in the database
This commit is contained in:
+4
@@ -10,6 +10,10 @@
|
||||
<input matInput #nameElement formControlName="name" (keyup.enter)="save()" />
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="flex flex-row justify-around content-start items-start">
|
||||
<mat-checkbox formControlName="nutritional" class="flex-auto mr-5">Nutritional Information?</mat-checkbox>
|
||||
<mat-checkbox formControlName="iceCream" class="flex-auto">Ice Cream?</mat-checkbox>
|
||||
</div>
|
||||
</form>
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { NgModule } from '@angular/core';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatPaginatorModule } from '@angular/material/paginator';
|
||||
@@ -23,6 +24,7 @@ import { ProductGroupRoutingModule } from './product-group-routing.module';
|
||||
MatPaginatorModule,
|
||||
MatSortModule,
|
||||
MatCardModule,
|
||||
MatCheckboxModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatInputModule,
|
||||
MatButtonModule,
|
||||
|
||||
Reference in New Issue
Block a user