add carousel & test submenu

This commit is contained in:
pakintada@gmail.com 2024-01-15 11:48:25 +07:00
parent edcccaaab9
commit 7102f644d4
7 changed files with 242 additions and 314 deletions

View file

@ -92,6 +92,7 @@ export class RecipeDetailsComponent implements OnInit {
tpl = []
toppingSet: ToppingSet[] | null = null;
submenus: Recipe01[] | null = null;
ngOnInit() {
this.productCode = this._route.snapshot.params['productCode'];
@ -101,13 +102,18 @@ export class RecipeDetailsComponent implements OnInit {
.pipe(first());
this.recipeDetail$.subscribe((detail) => {
console.log('Recipe Detail', detail);
// console.log('Recipe Detail', detail);
this.recipeDetailForm.patchValue(detail);
this.isLoaded = true;
this.recipeOriginalDetail = { ...this.recipeDetailForm.getRawValue() };
});
this._recipeService.getSubMenus(this._recipeService.getCurrentCountry(), this._recipeService.getCurrentFile(), this.productCode).subscribe((data) => {
console.log('Submenus', data);
this.submenus = data;
});
this.recipeDetailForm.valueChanges.subscribe(this.onRecipeDetailFormChange);
@ -243,4 +249,21 @@ export class RecipeDetailsComponent implements OnInit {
this.changedProductCode = event.target.value;
}
}
// Submenus
selectedSubProductCode: string | undefined = undefined;
hasSubmenu = () => this.submenus != null && this.submenus!.length > 0;
listSubMenuProductcodes = () => this.submenus!.map((recipe) => recipe.productCode);
selectSubmenu(productCode: string) {
if (this.selectedSubProductCode == productCode) {
this.selectedSubProductCode = undefined;
console.log('Unselected submenu', productCode);
return;
}
this.selectedSubProductCode = productCode;
console.log('Selected submenu', productCode);
}
}