]> gitweb.hhaalo.de Git - speisekarten-editor.git/commitdiff
add: edit food feature
authorBastian Dehn <hhaalo@arcor.de>
Mon, 6 Jun 2022 13:23:24 +0000 (15:23 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Mon, 6 Jun 2022 13:23:24 +0000 (15:23 +0200)
src/app/app.component.html
src/app/app.component.ts

index 2323d820be87939ff37f3b4327610b045a2d9e82..9454c8c2b72a9dbebbfbc19ffa4d09fc23eb0e54 100644 (file)
        <button class="button"
                type="button"
                id="addFood"
+               [disabled]="edit"
                (click)="addFood()">Hinzufügen</button>
+       <button class="button"
+               type="button"
+               id="editFood"
+               [disabled]="!edit"
+               (click)="saveFood()">Speichern</button>
 </form>
 
 <div *ngFor="let title of foodcard.Titles">
@@ -54,6 +60,8 @@
                        <div class="price">{{food.price}}</div>
                        <button type="button"
                                (click)="removeFood(subtitle, i)">Löschen</button>
+                       <button type="button"
+                               (click)="editFood(food)">Bearbeiten</button>
                </div>
        </div>
 </div>
index da0d94cf1501817dc0425ae6142ec4c9b27e386f..7144ae5b6309b1356fff573bc59a255d5e7a042c 100644 (file)
@@ -25,6 +25,7 @@ export class AppComponent
        public formTitleVisible: boolean = false;
        public formSubtitleVisible: boolean = false;
        public formFoodVisible: boolean = false;
+       public edit: boolean = false;
 
        public changeFormTitleVisible(): void
        {
@@ -88,6 +89,20 @@ export class AppComponent
                this.formFoodVisible = false;
        }
 
+       public saveFood(): void
+       {
+               this.food = { Food: "", sideDish: "", price: "" };
+               this.formFoodVisible = false;
+               this.edit = false;
+       }
+
+       public editFood(food: IFood): void
+       {
+               this.formFoodVisible = true;
+               this.food = food;
+               this.edit = true;
+       }
+
        public removeFood(subtitle: ISubtitle, foodindex: number): void
        {
                subtitle.Foods.splice(foodindex, 1);