Add parent/child category hierarchy for Toast menus

Toast pages with multiple menus (e.g. "Food", "Beverages", "Merchandise")
now produce parent categories from the menu names with subcategories from
the groups within each menu, using the parentCategoryName field the wizard
already supports.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
John Mizerek 2026-03-01 18:18:13 -08:00
parent aca3ba18a1
commit 4684936595

View file

@ -1015,13 +1015,13 @@
<!--- Use menu name as parent category if multiple menus --->
<cfset menuName = structKeyExists(menu, "name") ? menu.name : "">
<cfif len(menuName)><cfset arrayAppend(menuNames, menuName)></cfif>
<cfset isMultiMenu = structCount(ooState) GT 0><!--- will check later --->
<cfloop array="#menu.groups#" index="group">
<cfset groupName = structKeyExists(group, "name") ? trim(group.name) : "Menu">
<cfif NOT structKeyExists(categorySet, groupName)>
<cfset categorySet[groupName] = true>
<cfset catObj = { "name": groupName, "itemCount": 0 }>
<!--- Store menu name for parent category assignment later --->
<cfset catObj["menuName"] = menuName>
<cfset arrayAppend(toastCategories, catObj)>
</cfif>
@ -1178,6 +1178,24 @@
<cfset toastBusiness["name"] = trim(reReplace(toastBusiness.name, "^[\-\|]+", ""))>
</cfif>
<!--- Build parent/child category hierarchy if multiple menus --->
<cfif arrayLen(menuNames) GT 1>
<cfset hierarchicalCategories = arrayNew(1)>
<cfloop array="#menuNames#" index="mn">
<!--- Add parent category (the menu name) --->
<cfset parentCat = { "name": mn, "itemCount": 0 }>
<cfset arrayAppend(hierarchicalCategories, parentCat)>
<!--- Add subcategories under this parent --->
<cfloop array="#toastCategories#" index="tc">
<cfif structKeyExists(tc, "menuName") AND tc.menuName EQ mn>
<cfset tc["parentCategoryName"] = mn>
<cfset arrayAppend(hierarchicalCategories, tc)>
</cfif>
</cfloop>
</cfloop>
<cfset toastCategories = hierarchicalCategories>
</cfif>
<!--- Update category item counts --->
<cfloop from="1" to="#arrayLen(toastCategories)#" index="ci">
<cfset catName = toastCategories[ci].name>