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

index da669804269ef568d4011795dc4fc8681503e904..939457f0fd0c8299f9af31f0250c916fea8692d8 100644 (file)
        <button class="button"
                type="button"
                id="addTitle"
-               [disabled]="edit"
+               [disabled]="edit || disableByInsertMode()"
                (click)="addTitle()">Hinzufügen</button>
+       <button class="button"
+               type="button"
+               [disabled]="edit || !disableByInsertMode()"
+               (click)="insertMainSectionAfter()">Einfügen</button>
        <button class="button"
                type="button"
                id="saveTitle"
-               [disabled]="!edit"
+               [disabled]="!edit || disableByInsertMode()"
                (click)="saveTitle()">Speichern</button>
 </form>
 
                (click)="saveFood()">Speichern</button>
 </form>
 
-<div *ngFor="let title of foodcard.Titles">
+<div *ngFor="let title of foodcard.Titles; let i = index">
        <h1>{{title.Title}}</h1>
        <button class="button"
                type="button"
                (click)="editTitle(title)">Bearbeiten</button>
+       <button class="button"
+               type="button"
+               (click)="insertMainSection(i)">Einfügen Hauptteil</button>
        <div *ngFor="let subtitle of title.Subtitles; let i = index">
                <h2>{{subtitle.Subtitle}}</h2>
                <button class="button"
index 7b1a5f01a498b296a71c96041a6ec0a37532b2b0..cf71ee3693a1eb75b57d601adc4c6571f5168276 100644 (file)
@@ -110,6 +110,21 @@ export class AppComponent
                this.edit = true;
        }
 
+       public insertMainSectionAfter(): void
+       {
+               this.foodcard.Titles.splice(this.insertIndicies[0] + 1, 0,
+                       this.title);
+               this.title = { Title: "", Subtitles: [] };
+               this.insertIndicies = [ -1, -1, -1 ];
+               this.formTitleVisible = false;
+       }
+
+       public insertMainSection(index: number): void
+       {
+               this.insertIndicies = [ index, -1, -1 ];
+               this.formTitleVisible = true;
+       }
+
        public addSubtitle(): void
        {
                let lastTitle = this.getLastTitle()