Module: Katalyst::Navigation::EditorHelper

Defined in:
app/helpers/katalyst/navigation/editor_helper.rb

Instance Method Summary collapse

Instance Method Details

Generate a turbo stream fragment that will show structural errors to the user.



29
30
31
32
# File 'app/helpers/katalyst/navigation/editor_helper.rb', line 29

def navigation_editor_errors(menu:, **options)
  turbo_stream.replace(dom_id(menu, :errors),
                       Editor::Errors.new(self, menu).build(**options))
end


39
40
41
# File 'app/helpers/katalyst/navigation/editor_helper.rb', line 39

def navigation_editor_item(item:, menu: item.menu, **options, &block)
  Editor::Item.new(self, menu).build(item, **options, &block)
end


43
44
45
# File 'app/helpers/katalyst/navigation/editor_helper.rb', line 43

def navigation_editor_item_fields(item:, menu: item.menu)
  Editor::Item.new(self, menu).fields(item)
end

Generate items without their list wrapper, similar to form_with/fields



24
25
26
# File 'app/helpers/katalyst/navigation/editor_helper.rb', line 24

def navigation_editor_items(item:, menu: item.menu)
  Editor::List.new(self, menu).items(item)
end


17
18
19
20
21
# File 'app/helpers/katalyst/navigation/editor_helper.rb', line 17

def navigation_editor_list(menu:, items: menu.draft_items, **options)
  Editor::List.new(self, menu).build(options) do |list|
    list.items(*items) if items.present?
  end
end


13
14
15
# File 'app/helpers/katalyst/navigation/editor_helper.rb', line 13

def navigation_editor_menu(menu:, **options, &block)
  Editor::Menu.new(self, menu).build(options, &block)
end

Generate a new item template.



35
36
37
# File 'app/helpers/katalyst/navigation/editor_helper.rb', line 35

def navigation_editor_new_item(item:, menu: item.menu, **options, &block)
  Editor::NewItem.new(self, menu).build(item, **options, &block)
end


6
7
8
9
10
11
# File 'app/helpers/katalyst/navigation/editor_helper.rb', line 6

def navigation_editor_new_items(menu)
  Katalyst::Navigation.config.items.map do |item_class|
    item_class = item_class.is_a?(String) ? item_class.safe_constantize : item_class
    item_class.new(menu: menu)
  end
end


47
48
49
# File 'app/helpers/katalyst/navigation/editor_helper.rb', line 47

def navigation_editor_status_bar(menu:, **options)
  Editor::StatusBar.new(self, menu).build(**options)
end