]> gitweb.hhaalo.de Git - speisekarten-editor.git/commitdiff
add: insert subsection button
authorBastian Dehn <hhaalo@arcor.de>
Tue, 7 Jun 2022 16:15:38 +0000 (18:15 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Tue, 7 Jun 2022 16:15:38 +0000 (18:15 +0200)
src/app/app.component.html
src/app/app.component.ts

index a84c46203cbb863d622d1723452162d0879e5267..22ddb98404600e48d939b09fbbb5b8c8fdde6d49 100644 (file)
        <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>
 
@@ -95,6 +99,9 @@
                <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>
index ea1ba9a844d1c759ccef211c13e96f90cd783926..7b1a5f01a498b296a71c96041a6ec0a37532b2b0 100644 (file)
@@ -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);