diff --git a/portal/menu-builder.html b/portal/menu-builder.html index 7fa9de4..329907d 100644 --- a/portal/menu-builder.html +++ b/portal/menu-builder.html @@ -252,6 +252,27 @@ transform: rotate(90deg); } + /* Item Toggle (for expanding modifiers) */ + .item-toggle { + width: 20px; + height: 20px; + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + transition: transform 0.3s ease; + color: var(--text-muted); + flex-shrink: 0; + } + + .item-toggle:hover { + color: var(--text-primary); + } + + .item-toggle.expanded { + transform: rotate(90deg); + } + .items-list.drag-over { background: rgba(0, 255, 136, 0.02); } @@ -988,6 +1009,8 @@ redoStack: [], idCounter: 1, expandedCategoryId: null, // For accordion - only one category expanded at a time + expandedItemId: null, // For item accordion - only one item expanded at a time + expandedModifierIds: new Set(), // Track which modifiers are expanded // Initialize async init() { @@ -2731,15 +2754,24 @@ return modifiers.map(mod => { const hasOptions = mod.options && mod.options.length > 0; + const modExpanded = this.expandedModifierIds.has(mod.id); return ` -
+ ${hasOptions ? ` +
+ + + +
+ ` : ` + `}
${icon}
-
+
${this.escapeHtml(mod.name)}
${mod.price > 0 ? `+$${mod.price.toFixed(2)}` : ''} @@ -2757,7 +2789,7 @@
- ${hasOptions ? this.renderModifiers(mod.options, mod.id, depth + 1) : ''} + ${hasOptions && modExpanded ? this.renderModifiers(mod.options, mod.id, depth + 1) : ''} `; }).join(''); }, @@ -2817,9 +2849,19 @@
${category.items.length === 0 ? `
Drag items here or click + to add
- ` : category.items.map(item => ` -
{ + const itemExpanded = this.expandedItemId === item.id; + const hasModifiers = item.modifiers && item.modifiers.length > 0; + return ` +
+ ${hasModifiers ? ` +
+ + + +
+ ` : ''}
@@ -2839,11 +2881,11 @@
` : ''}
-
+
${this.escapeHtml(item.name)}
$${(item.price || 0).toFixed(2)} - ${item.modifiers.length > 0 ? `${item.modifiers.length} modifiers` : ''} + ${hasModifiers ? `${item.modifiers.length} modifiers` : ''}
@@ -2860,8 +2902,8 @@
- ${this.renderModifiers(item.modifiers, item.id, 1)} - `).join('')} + ${itemExpanded ? this.renderModifiers(item.modifiers, item.id, 1) : ''} + `}).join('')}
`}).join(''); @@ -2998,9 +3040,34 @@ // Toggle category expanded/collapsed (accordion behavior) toggleCategory(categoryId) { - // If clicking the already expanded category, collapse it - // Otherwise expand the clicked one (auto-collapses any other) - this.expandedCategoryId = (this.expandedCategoryId === categoryId) ? null : categoryId; + if (this.expandedCategoryId === categoryId) { + this.expandedCategoryId = null; + } else { + this.expandedCategoryId = categoryId; + this.expandedItemId = null; + this.expandedModifierIds.clear(); + } + this.render(); + }, + + // Toggle item expanded/collapsed + toggleItem(itemId) { + if (this.expandedItemId === itemId) { + this.expandedItemId = null; + } else { + this.expandedItemId = itemId; + this.expandedModifierIds.clear(); + } + this.render(); + }, + + // Toggle modifier expanded/collapsed + toggleModifier(modifierId) { + if (this.expandedModifierIds.has(modifierId)) { + this.expandedModifierIds.delete(modifierId); + } else { + this.expandedModifierIds.add(modifierId); + } this.render(); },