<button class="button"
type="button"
id="addSubtitle"
- [disabled]="edit"
+ [disabled]="edit || disableByInsertMode()"
(click)="addSubtitle()">Hinzufügen</button>
+ <button class="button"
+ type="button"
+ [disabled]="edit || !disableByInsertMode()"
+ (click)="insertSubSectionAfter()">Einfügen</button>
<button class="button"
type="button"
id="saveSubtitle"
- [disabled]="!edit"
+ [disabled]="!edit || disableByInsertMode()"
(click)="saveSubtitle()">Speichern</button>
</form>
<button class="button"
type="button"
(click)="removeSubSection(title, i)">Lösche Unterteil</button>
+ <button class="button"
+ type="button"
+ (click)="insertSubSection(title, subtitle)">Einfügen Unterteil</button>
<div *ngFor="let food of subtitle.Foods; let i = index"
class="foodmenu grid">
<div class="food">{{food.Food}}</div>
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);