From 9fa6c30d3f7d83603b1483b97a0f89621adb6c53 Mon Sep 17 00:00:00 2001 From: "pakintada@gmail.com" Date: Tue, 23 Jan 2024 14:16:26 +0700 Subject: [PATCH] add sync after removing topping --- .../recipe-topping/recipe-topping.component.html | 1 + .../recipe-topping/recipe-topping.component.ts | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/client/src/app/features/recipes/recipe-details/recipe-topping/recipe-topping.component.html b/client/src/app/features/recipes/recipe-details/recipe-topping/recipe-topping.component.html index 278cd16..7e7e0be 100644 --- a/client/src/app/features/recipes/recipe-details/recipe-topping/recipe-topping.component.html +++ b/client/src/app/features/recipes/recipe-details/recipe-topping/recipe-topping.component.html @@ -64,6 +64,7 @@ [multiple]="true" [maxSelectedItems]="3" (close)="registerExtraTopping(extraTopping)" + (remove)="triggerValueChange()" [(ngModel)]="extraTopping" > 0){ let concatArr = [value.ListGroupID[0], ...((this.extraTopping).map((x: string) => parseInt(x)))]; - if(concatArr.length < 4){ + if(concatArr.length < value.ListGroupID.length){ // fill with 0 - while (concatArr.length < 4) { + while (concatArr.length < value.ListGroupID.length) { concatArr.push(0); } } @@ -279,13 +279,15 @@ export class RecipeToppingComponent implements OnInit { value.ListGroupID = concatArr; // get last element that is not 0 - let lastIndex = concatArr.findIndex((x: any) => x == 0) - 1; - if(lastIndex <= -1){ - lastIndex = 0; - } + // let lastIndex = concatArr.findIndex((x: any) => x == 0) - 1; + // if(lastIndex <= -1){ + // lastIndex = 0; + // } - value.defaultIDSelect = parseInt(this.extraToppingDefault![value.groupID]); + // value.defaultIDSelect = parseInt(this.extraToppingDefault![value.groupID]); // console.log("value.defaultIDSelect", value.defaultIDSelect); + } else { + value.ListGroupID = [parseInt(value.groupID), 0, 0, 0]; } // do cat array from list group id