From: Bastian Dehn Date: Mon, 6 Jun 2022 11:33:41 +0000 (+0200) Subject: add: food to subtitle X-Git-Tag: v1.0^2~45 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=0fa6458d0ad630628cd4dcef3d63fb01ef5e5857;p=speisekarten-editor.git add: food to subtitle --- diff --git a/src/app/app.component.html b/src/app/app.component.html index 5de8a5b..9a712ea 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -38,12 +38,18 @@ + id="addFood" + (click)="addFood()">Hinzufügen

{{title.Title}}

{{subtitle.Subtitle}}

+
+
{{food.Food}}
+
{{food.sideDish}}
+
{{food.price}}
+
diff --git a/src/app/app.component.ts b/src/app/app.component.ts index a4bf9a9..900d1a4 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,4 +1,6 @@ import { Component } from '@angular/core'; +import { ITitle } from './ititle'; +import { ISubtitle } from './isubtitle'; import { IFood } from './ifood'; import { IFoodCard } from './ifood-card'; @@ -50,11 +52,30 @@ export class AppComponent public addSubtitle(): void { - let lastIndex = this.foodcard.Titles.length - 1; - this.foodcard.Titles[lastIndex].Subtitles.push({ + let lastTitle = this.getLastTitle() + lastTitle.Subtitles.push({ Subtitle: this.subtitle, Foods: [] }); this.formSubtitleVisible = false; } + + public addFood(): void + { + let lastSubtitle = this.getLastSubtitle(); + lastSubtitle.Foods.push(this.food); + } + + private getLastTitle(): ITitle + { + let lastIndex = this.foodcard.Titles.length - 1; + return this.foodcard.Titles[lastIndex]; + } + + private getLastSubtitle(): ISubtitle + { + let lastTitle = this.getLastTitle(); + let lastIndex = lastTitle.Subtitles.length - 1; + return lastTitle.Subtitles[lastIndex]; + } }