From 572102e607e265ef2d5f8fc52a7d7c56acad3b32 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Thu, 9 Jun 2022 18:33:23 +0200 Subject: [PATCH] change: insert with new component --- src/app/app.component.html | 18 ++---------------- src/app/app.component.ts | 36 +++--------------------------------- 2 files changed, 5 insertions(+), 49 deletions(-) diff --git a/src/app/app.component.html b/src/app/app.component.html index 145c408..a9b192d 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -51,20 +51,6 @@ (click)="saveSubtitle()">Speichern -
- - - - - - - -
-

{{title.Title}}

+ (click)="insertNewFood(subtitle, i)">Speise hinzufügen
+ (click)="insertNewFood(subtitle, i)">Einfügen diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 112b334..02c5921 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -39,14 +39,6 @@ export class AppComponent this.formSubtitleVisible = !this.formSubtitleVisible; } - public addNewFood(title: ITitle, index: number): void - { - let titleIndex = this.foodcard.Titles.indexOf(title); - this.insertIndicies = [ titleIndex, index, - title.Subtitles[index].Foods.length - 1 ]; - this.formFoodVisible = !this.formFoodVisible; - } - public disableFoodButton(): boolean { if (this.foodcard.Titles.length < 1) @@ -182,32 +174,10 @@ export class AppComponent } - public addFood(): void + public insertNewFood(subtitle: ISubtitle, index: number): void { - let lastSubtitle = this.getLastSubtitle(); - lastSubtitle.Foods.push(this.food); - this.food = { Food: "", sideDish: "", price: "" }; - this.formFoodVisible = false; - } - - public insertFoodAfter(): void - { - let title = this.foodcard.Titles[this.insertIndicies[0]]; - let subtitle = title.Subtitles[this.insertIndicies[1]]; - subtitle.Foods.splice(this.insertIndicies[2] + 1, 0, this.food); - this.food = { Food: "", sideDish: "", price: "" }; - this.insertIndicies = [ -1, -1, -1 ]; - this.formFoodVisible = false; - } - - public insertFood(title: ITitle, subtitle: ISubtitle, food: IFood): void - { - let titleIndex = this.foodcard.Titles.indexOf(title); - let subtitleIndex = title.Subtitles.indexOf(subtitle); - let foodIndex = subtitle.Foods.indexOf(food); - - this.insertIndicies = [ titleIndex, subtitleIndex, foodIndex ]; - this.formFoodVisible = true; + subtitle.Foods.splice(index + 1, 0, + { Food: "", sideDish: "", price: "" }); } public removeFood(subtitle: ISubtitle, foodindex: number): void -- 2.39.5