|
@ -110,20 +110,25 @@ export class IngredientFormBasicComponent implements OnChanges { |
|
|
// });
|
|
|
// });
|
|
|
this.api.getStandard().subscribe((res) => { |
|
|
this.api.getStandard().subscribe((res) => { |
|
|
this.standardOfOption = res; |
|
|
this.standardOfOption = res; |
|
|
|
|
|
if (this.menu) { |
|
|
|
|
|
this.onStandardChange(String(this.menu.nutrient)); |
|
|
|
|
|
this.setValues(); |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
this.setValues(); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ngOnChanges(changes: SimpleChanges): void {} |
|
|
ngOnChanges(changes: SimpleChanges): void {} |
|
|
|
|
|
|
|
|
setValues() { |
|
|
setValues() { |
|
|
let weekday = []; |
|
|
let weekday = []; |
|
|
|
|
|
// console.log("this.menu", this.menu);
|
|
|
if (this.menu) { |
|
|
if (this.menu) { |
|
|
this.standardSearch$.next({ id: this.menu.nutrient }); |
|
|
this.standardSearch$.next({ id: this.menu.nutrient }); |
|
|
this.meals = this.meals.map((i) => (this.menu.meals.includes(i.value) ? { ...i, checked: true } : i)); |
|
|
this.meals = this.meals.map((i) => (this.menu.meals.includes(i.value) ? { ...i, checked: true } : i)); |
|
|
weekday = this.weekday.map((i) => (this.menu.day.includes(i.value) ? { ...i, checked: true } : i)); |
|
|
weekday = this.weekday.map((i) => (this.menu.day.includes(i.value) ? { ...i, checked: true } : i)); |
|
|
this.formGroup.patchValue({ |
|
|
this.formGroup.patchValue({ |
|
|
...this.menu, |
|
|
...this.menu, |
|
|
|
|
|
nutrient: String(this.menu.nutrient), |
|
|
vendors: [String(this.menu.vender)], |
|
|
vendors: [String(this.menu.vender)], |
|
|
}); |
|
|
}); |
|
|
} else { |
|
|
} else { |
|
@ -147,6 +152,9 @@ export class IngredientFormBasicComponent implements OnChanges { |
|
|
|
|
|
|
|
|
onStandardChange(v: any) { |
|
|
onStandardChange(v: any) { |
|
|
const currentStandard = this.standardOfOption.find((f) => f.value === v); |
|
|
const currentStandard = this.standardOfOption.find((f) => f.value === v); |
|
|
|
|
|
this.formGroup.patchValue({ |
|
|
|
|
|
vendors: [], |
|
|
|
|
|
}); |
|
|
if (currentStandard) { |
|
|
if (currentStandard) { |
|
|
this.currentPeoples = Object.entries(currentStandard["ingredient"] ?? {}).map(([k, v]) => { |
|
|
this.currentPeoples = Object.entries(currentStandard["ingredient"] ?? {}).map(([k, v]) => { |
|
|
return { |
|
|
return { |
|
|