From 7c83c35d7e4174b1dc0cca792c8e5006e1e3eb89 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Tue, 7 Jun 2022 18:15:38 +0200 Subject: [PATCH] add: insert subsection button --- src/app/app.component.html | 11 +++++++++-- src/app/app.component.ts | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/app/app.component.html b/src/app/app.component.html index a84c462..22ddb98 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -49,12 +49,16 @@ + @@ -95,6 +99,9 @@ +
{{food.Food}}
diff --git a/src/app/app.component.ts b/src/app/app.component.ts index ea1ba9a..7b1a5f0 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -118,6 +118,25 @@ export class AppComponent this.formSubtitleVisible = false; } + public insertSubSectionAfter(): void + { + let title = this.foodcard.Titles[this.insertIndicies[0]]; + title.Subtitles.splice(this.insertIndicies[1] + 1, 0, + this.subtitle); + this.subtitle = { Subtitle: "", Foods: [] }; + this.insertIndicies = [ -1, -1, -1 ]; + this.formSubtitleVisible = false; + } + + public insertSubSection(title: ITitle, subtitle: ISubtitle): void + { + let titleIndex = this.foodcard.Titles.indexOf(title); + let subtitleIndex = title.Subtitles.indexOf(subtitle); + + this.insertIndicies = [ titleIndex, subtitleIndex, -1 ]; + this.formSubtitleVisible = true; + } + public removeSubSection(title: ITitle, index: number) { title.Subtitles.splice(index, 1); -- 2.39.5