Class: Alchemy::Admin::MainNavigation::Menu
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Alchemy::Admin::MainNavigation::Menu
- Defined in:
- app/components/alchemy/admin/main_navigation/menu.rb
Instance Method Summary collapse
-
#items ⇒ Object
Entries without a position that were inserted between Alchemy's own entries are listed after the positioned entry preceding them, so
Alchemy.config.menu.insertcan replace the deprecated position.
Instance Method Details
#items ⇒ Object
Entries without a position that were inserted between Alchemy's own
entries are listed after the positioned entry preceding them, so
Alchemy.config.menu.insert can replace the deprecated position.
Appended entries without a position are listed last.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/components/alchemy/admin/main_navigation/menu.rb', line 18 def items = Alchemy.config..to_a core_names = Alchemy::Configurations::Menu::DEFAULT.map { |entry| entry[:name] } last_core_index = .rindex { |item| core_names.include?(item.name) } || -1 preceding_position = 0 .each_with_index.map do |item, index| preceding_position = item.position if item.position key = if item.position [item.position, 0, index] elsif index < last_core_index [preceding_position, 1, index] else [Float::INFINITY, 0, index] end [item, key] end.sort_by(&:last).map(&:first) end |