From 66d6f03a4338cce058c4eeb33b6c1fe50b09f8fa Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Sat, 10 Apr 2021 11:44:35 +0200 Subject: [PATCH] wip: render ingredient editors --- app/decorators/alchemy/element_editor.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/decorators/alchemy/element_editor.rb b/app/decorators/alchemy/element_editor.rb index ff6e11903b..6b647a93b3 100644 --- a/app/decorators/alchemy/element_editor.rb +++ b/app/decorators/alchemy/element_editor.rb @@ -19,6 +19,17 @@ def contents end end + # Returns ingredient editor instances for defined ingredients + # + # Creates ingredient on demand if the ingredient is not yet present on the element + # + # @return Array + def ingredients + element.definition.fetch(:ingredients, []).map do |ingredient| + Alchemy::IngredientEditor.new(find_or_create_ingredient(ingredient[:role])) + end + end + # CSS classes for the element editor partial. def css_classes [