add submenu
This commit is contained in:
parent
9b0f111f5b
commit
84f18b6141
5 changed files with 91 additions and 19 deletions
|
|
@ -112,12 +112,12 @@
|
||||||
|
|
||||||
<div *ngIf="hasSubmenu()">
|
<div *ngIf="hasSubmenu()">
|
||||||
<div *ngFor="let sub of listSubMenuProductcodes()">
|
<div *ngFor="let sub of listSubMenuProductcodes()">
|
||||||
<button
|
<a
|
||||||
class="btn btn-sm btn-primary m-2"
|
class="btn btn-sm btn-primary m-2"
|
||||||
(click)="selectSubmenu(sub)"
|
href="/{{department}}/recipe/{{ sub }}"
|
||||||
>
|
>
|
||||||
{{ sub }}
|
{{ sub }}
|
||||||
</button>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -326,14 +326,9 @@ export class RecipeDetailsComponent implements OnInit {
|
||||||
this.submenus!.map((recipe) => recipe.productCode);
|
this.submenus!.map((recipe) => recipe.productCode);
|
||||||
|
|
||||||
selectSubmenu(productCode: string) {
|
selectSubmenu(productCode: string) {
|
||||||
if (this.selectedSubProductCode == productCode) {
|
void this._router.navigate([
|
||||||
this.selectedSubProductCode = undefined;
|
'/' + this.department + '/recipes/' + productCode,
|
||||||
console.log('Unselected submenu', productCode);
|
]);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.selectedSubProductCode = productCode;
|
|
||||||
console.log('Selected submenu', productCode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// concat remaining unused keys
|
// concat remaining unused keys
|
||||||
|
|
|
||||||
|
|
@ -279,20 +279,22 @@ export class RecipeToppingComponent implements OnInit {
|
||||||
value.ListGroupID = concatArr;
|
value.ListGroupID = concatArr;
|
||||||
|
|
||||||
// get last element that is not 0
|
// get last element that is not 0
|
||||||
// let lastIndex = concatArr.findIndex((x: any) => x == 0) - 1;
|
let lastIndex = concatArr.findIndex((x: any) => x == 0) - 1;
|
||||||
// if(lastIndex <= -1){
|
if(lastIndex <= -1){
|
||||||
// lastIndex = 0;
|
lastIndex = 0;
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
let overrideDefault = parseInt(this.extraToppingDefault![concatArr[lastIndex]]);
|
||||||
|
|
||||||
// value.defaultIDSelect = parseInt(this.extraToppingDefault![value.groupID]);
|
// value.defaultIDSelect = parseInt(this.extraToppingDefault![value.groupID]);
|
||||||
// console.log("value.defaultIDSelect", value.defaultIDSelect);
|
console.log("value.defaultIDSelect", value.defaultIDSelect, "if override", overrideDefault);
|
||||||
|
// TODO: Turn on if need to overwrite
|
||||||
|
// value.defaultIDSelect = overrideDefault;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
value.ListGroupID = [parseInt(value.groupID), 0, 0, 0];
|
value.ListGroupID = [parseInt(value.groupID), 0, 0, 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// do cat array from list group id
|
|
||||||
// let testSpliceArr = Array(value.ListGroupID).splice(1, value.ListGroupID.length -1 , ...(this.listGroupId[0] as Array<string>).slice(1, value.ListGroupID.length));
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isUse: value.isUse,
|
isUse: value.isUse,
|
||||||
groupID: value.groupID,
|
groupID: value.groupID,
|
||||||
|
|
|
||||||
|
|
@ -186,6 +186,8 @@ func (d *Data) GetRecipe(countryID, filename string) *models.Recipe {
|
||||||
|
|
||||||
d.taoLogger.Log.Debug("invoke GetRecipe", zap.String("countryID", countryID), zap.String("filename", filename))
|
d.taoLogger.Log.Debug("invoke GetRecipe", zap.String("countryID", countryID), zap.String("filename", filename))
|
||||||
|
|
||||||
|
// TODO: concat submenu into recipe
|
||||||
|
|
||||||
if countryID == "" {
|
if countryID == "" {
|
||||||
return d.currentRecipe["tha"]
|
return d.currentRecipe["tha"]
|
||||||
}
|
}
|
||||||
|
|
@ -273,6 +275,12 @@ func (d *Data) GetRecipe01ByProductCode(filename, countryID, productCode string)
|
||||||
for _, v := range d.currentRecipe[countryID].Recipe01 {
|
for _, v := range d.currentRecipe[countryID].Recipe01 {
|
||||||
if v.ProductCode == productCode {
|
if v.ProductCode == productCode {
|
||||||
return v, nil
|
return v, nil
|
||||||
|
} else if len(v.SubMenu) > 0 {
|
||||||
|
for _, subMenu := range v.SubMenu {
|
||||||
|
if subMenu.ProductCode == productCode {
|
||||||
|
return subMenu, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println("No result in current recipe", countryID)
|
fmt.Println("No result in current recipe", countryID)
|
||||||
|
|
@ -282,6 +290,13 @@ func (d *Data) GetRecipe01ByProductCode(filename, countryID, productCode string)
|
||||||
if v.ProductCode == productCode {
|
if v.ProductCode == productCode {
|
||||||
d.taoLogger.Log.Debug("GetRecipe01ByProductCode.getSuccess", zap.Any("fromFile", filename), zap.Any("whereSource", d.recipeMap))
|
d.taoLogger.Log.Debug("GetRecipe01ByProductCode.getSuccess", zap.Any("fromFile", filename), zap.Any("whereSource", d.recipeMap))
|
||||||
return v, nil
|
return v, nil
|
||||||
|
} else if len(v.SubMenu) > 0 {
|
||||||
|
for _, subMenu := range v.SubMenu {
|
||||||
|
if subMenu.ProductCode == productCode {
|
||||||
|
d.taoLogger.Log.Debug("GetRecipe01ByProductCode.getSuccess", zap.Any("fromFile", filename), zap.Any("whereSource", d.recipeMap))
|
||||||
|
return subMenu, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d.taoLogger.Log.Debug("GetRecipe01ByProductCode.getFail", zap.Any("fromFile", filename), zap.Any("whereSource", d.recipeMap))
|
d.taoLogger.Log.Debug("GetRecipe01ByProductCode.getFail", zap.Any("fromFile", filename), zap.Any("whereSource", d.recipeMap))
|
||||||
|
|
@ -312,6 +327,12 @@ func (d *Data) GetRecipe01ByProductCode(filename, countryID, productCode string)
|
||||||
for _, v := range d.currentRecipe[countryID].Recipe01 {
|
for _, v := range d.currentRecipe[countryID].Recipe01 {
|
||||||
if v.ProductCode == productCode {
|
if v.ProductCode == productCode {
|
||||||
return v, fmt.Errorf("[DEFAULT]-ERR")
|
return v, fmt.Errorf("[DEFAULT]-ERR")
|
||||||
|
} else if len(v.SubMenu) > 0 {
|
||||||
|
for _, subMenu := range v.SubMenu {
|
||||||
|
if subMenu.ProductCode == productCode {
|
||||||
|
return subMenu, fmt.Errorf("[DEFAULT]-ERR")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -343,6 +364,13 @@ func (d *Data) GetRecipe01ByProductCode(filename, countryID, productCode string)
|
||||||
if v.ProductCode == productCode {
|
if v.ProductCode == productCode {
|
||||||
// d.taoLogger.Log.Debug("GetRecipe01ByProductCode", zap.Any("productCode", productCode), zap.Any("result", v))
|
// d.taoLogger.Log.Debug("GetRecipe01ByProductCode", zap.Any("productCode", productCode), zap.Any("result", v))
|
||||||
return v, nil
|
return v, nil
|
||||||
|
} else if len(v.SubMenu) > 0 {
|
||||||
|
for _, subMenu := range v.SubMenu {
|
||||||
|
if subMenu.ProductCode == productCode {
|
||||||
|
// d.taoLogger.Log.Debug("GetRecipe01ByProductCode", zap.Any("productCode", productCode), zap.Any("result", subMenu))
|
||||||
|
return subMenu, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -374,6 +402,26 @@ func (d *Data) SetValuesToRecipe(base_recipe []models.Recipe01, recipe models.Re
|
||||||
|
|
||||||
not_found = false
|
not_found = false
|
||||||
break
|
break
|
||||||
|
} else if len(v.SubMenu) > 0 {
|
||||||
|
for _, sub := range v.SubMenu {
|
||||||
|
if sub.ProductCode == recipe.ProductCode {
|
||||||
|
// Log.Debug("SetValuesToRecipe.SubMenu", zap.Any("old", sub), zap.Any("new", recipe))
|
||||||
|
// sub = recipe
|
||||||
|
// TODO: change only changed values
|
||||||
|
|
||||||
|
// transform to map
|
||||||
|
base_recipe01_Map := sub.ToMap()
|
||||||
|
|
||||||
|
recipe01_Map := recipe.ToMap()
|
||||||
|
|
||||||
|
for k, v := range recipe01_Map {
|
||||||
|
if !reflect.DeepEqual(base_recipe01_Map[k], v) {
|
||||||
|
d.taoLogger.Log.Debug("SetValuesToRecipe.SubMenu", zap.Any("key", k), zap.Any("old", base_recipe01_Map[k]), zap.Any("new", v))
|
||||||
|
base_recipe01_Map[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
not_found = true
|
not_found = true
|
||||||
global_idx = index
|
global_idx = index
|
||||||
|
|
|
||||||
|
|
@ -224,6 +224,17 @@ func (rs *recipeService) GetRecipeOverview(request *contracts.RecipeOverviewRequ
|
||||||
strings.Contains(strings.ToLower(v.OtherName), strings.ToLower(request.Search)) {
|
strings.Contains(strings.ToLower(v.OtherName), strings.ToLower(request.Search)) {
|
||||||
searchResult = append(searchResult, v)
|
searchResult = append(searchResult, v)
|
||||||
}
|
}
|
||||||
|
// do seach submenu
|
||||||
|
if len(v.SubMenu) > 0 {
|
||||||
|
for _, sub := range v.SubMenu {
|
||||||
|
if strings.Contains(strings.ToLower(sub.ProductCode), strings.ToLower(request.Search)) ||
|
||||||
|
strings.Contains(strings.ToLower(sub.Name), strings.ToLower(request.Search)) ||
|
||||||
|
strings.Contains(strings.ToLower(sub.OtherName), strings.ToLower(request.Search)) {
|
||||||
|
searchResult = append(searchResult, sub)
|
||||||
|
// rs.taoLogger.Log.Debug("GetRecipeOverview.SubMenu", zap.Any("searchResult::GetSubMenu", sub))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
recipeFilter = searchResult
|
recipeFilter = searchResult
|
||||||
}
|
}
|
||||||
|
|
@ -253,6 +264,22 @@ func (rs *recipeService) GetRecipeOverview(request *contracts.RecipeOverviewRequ
|
||||||
OtherDescription: v.OtherDescription,
|
OtherDescription: v.OtherDescription,
|
||||||
LastUpdated: v.LastChange,
|
LastUpdated: v.LastChange,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// submenu
|
||||||
|
if len(v.SubMenu) > 0 {
|
||||||
|
for _, sub := range v.SubMenu {
|
||||||
|
result.Result = append(result.Result, contracts.RecipeOverview{
|
||||||
|
ID: sub.ID,
|
||||||
|
ProductCode: sub.ProductCode,
|
||||||
|
Name: sub.Name,
|
||||||
|
OtherName: sub.OtherName,
|
||||||
|
Description: sub.Description,
|
||||||
|
OtherDescription: sub.OtherDescription,
|
||||||
|
LastUpdated: sub.LastChange,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.TotalCount = len(result.Result)
|
result.TotalCount = len(result.Result)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue