Feature: Download nutritional information and store description and allergen information in products
This commit is contained in:
@ -21,6 +21,7 @@ export class Product {
|
||||
id: string | undefined;
|
||||
code: number;
|
||||
name: string;
|
||||
description: string | undefined;
|
||||
skus: StockKeepingUnit[];
|
||||
fractionUnits: string | undefined;
|
||||
|
||||
@ -30,6 +31,7 @@ export class Product {
|
||||
isSold: boolean;
|
||||
productGroup?: ProductGroup;
|
||||
|
||||
allergen: string;
|
||||
protein: number;
|
||||
carbohydrate: number;
|
||||
totalSugar: number;
|
||||
@ -55,6 +57,7 @@ export class Product {
|
||||
this.isPurchased = true;
|
||||
this.isSold = false;
|
||||
|
||||
this.allergen = '';
|
||||
this.protein = 0;
|
||||
this.carbohydrate = 0;
|
||||
this.totalSugar = 0;
|
||||
|
||||
@ -20,6 +20,12 @@
|
||||
<input matInput formControlName="fractionUnits" />
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="flex flex-row justify-around content-start items-start">
|
||||
<mat-form-field class="flex-auto">
|
||||
<mat-label>Description</mat-label>
|
||||
<input matInput #nameElement formControlName="description" />
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="flex flex-row justify-around content-start items-start">
|
||||
<mat-checkbox formControlName="isPurchased" class="flex-auto mr-5">Is Purchased?</mat-checkbox>
|
||||
<mat-checkbox formControlName="isSold" class="flex-auto mr-5">Is Sold?</mat-checkbox>
|
||||
@ -35,6 +41,12 @@
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="flex flex-row justify-around content-start items-start">
|
||||
<mat-form-field class="flex-auto">
|
||||
<mat-label>Allergen</mat-label>
|
||||
<input matInput #nameElement formControlName="allergen" />
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<h2 *ngIf="item.productGroup?.nutritional ?? false">Nutritional Information</h2>
|
||||
<div
|
||||
class="flex flex-row justify-around content-start items-start"
|
||||
|
||||
@ -23,6 +23,7 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
form: FormGroup<{
|
||||
code: FormControl<string | number>;
|
||||
name: FormControl<string | null>;
|
||||
description: FormControl<string | null>;
|
||||
fractionUnits: FormControl<string | null>;
|
||||
addRow: FormGroup<{
|
||||
units: FormControl<string | null>;
|
||||
@ -36,6 +37,7 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
isActive: FormControl<boolean>;
|
||||
productGroup: FormControl<string | null>;
|
||||
|
||||
allergen: FormControl<string | null>;
|
||||
protein: FormControl<number>;
|
||||
carbohydrate: FormControl<number>;
|
||||
totalSugar: FormControl<number>;
|
||||
@ -69,6 +71,7 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
this.form = new FormGroup({
|
||||
code: new FormControl<string | number>({ value: 0, disabled: true }, { nonNullable: true }),
|
||||
name: new FormControl<string | null>(null),
|
||||
description: new FormControl<string | null>(null),
|
||||
fractionUnits: new FormControl<string | null>(null),
|
||||
addRow: new FormGroup({
|
||||
units: new FormControl<string | null>(null),
|
||||
@ -82,6 +85,7 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
isActive: new FormControl<boolean>(true, { nonNullable: true }),
|
||||
productGroup: new FormControl<string | null>(null),
|
||||
|
||||
allergen: new FormControl<string | null>(null),
|
||||
protein: new FormControl<number>(0, { nonNullable: true }),
|
||||
carbohydrate: new FormControl<number>(0, { nonNullable: true }),
|
||||
totalSugar: new FormControl<number>(0, { nonNullable: true }),
|
||||
@ -116,6 +120,7 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
this.form.setValue({
|
||||
code: this.item.code || '(Auto)',
|
||||
name: this.item.name,
|
||||
description: this.item.description || '',
|
||||
fractionUnits: this.item.fractionUnits ?? '',
|
||||
addRow: {
|
||||
units: '',
|
||||
@ -129,6 +134,7 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
isActive: this.item.isActive,
|
||||
productGroup: this.item.productGroup ? this.item.productGroup.id ?? '' : '',
|
||||
|
||||
allergen: this.item.allergen ?? '',
|
||||
protein: this.item.protein,
|
||||
carbohydrate: this.item.carbohydrate,
|
||||
totalSugar: this.item.totalSugar,
|
||||
@ -266,11 +272,13 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
getItem(): Product {
|
||||
const formModel = this.form.value;
|
||||
this.item.name = formModel.name ?? '';
|
||||
this.item.description = formModel.description ?? '';
|
||||
this.item.fractionUnits = formModel.fractionUnits ?? '';
|
||||
this.item.isPurchased = formModel.isPurchased ?? true;
|
||||
this.item.isSold = formModel.isSold ?? false;
|
||||
this.item.isActive = formModel.isActive ?? true;
|
||||
|
||||
this.item.allergen = formModel.allergen ?? '';
|
||||
this.item.protein = formModel.protein ?? 0;
|
||||
this.item.carbohydrate = formModel.carbohydrate ?? 0;
|
||||
this.item.totalSugar = formModel.totalSugar ?? 0;
|
||||
|
||||
@ -5,6 +5,9 @@
|
||||
<a mat-icon-button [href]="'/api/recipes/xlsx?t=' + period.id">
|
||||
<mat-icon>save_alt</mat-icon>
|
||||
</a>
|
||||
<a mat-icon-button href="/api/recipes/nutrition">
|
||||
<mat-icon>save_alt</mat-icon>
|
||||
</a>
|
||||
<a mat-button [routerLink]="['/recipes', 'new']">
|
||||
<mat-icon>add_box</mat-icon>
|
||||
Add
|
||||
|
||||
Reference in New Issue
Block a user