zeus.ugent.be/lib/helpers/nav.rb

23 lines
607 B
Ruby
Raw Normal View History

2017-03-20 14:15:14 +00:00
# frozen_string_literal: true
# Helpers for navbar partial
2016-07-31 17:28:23 +00:00
module NavigationHelper
2017-04-03 20:32:02 +00:00
def child_of(item)
item == @item || children_of(item).include?(@item)
2016-07-31 17:28:23 +00:00
end
2016-10-31 12:48:39 +00:00
2017-03-20 14:15:14 +00:00
# Returns every navigable item
# A navigable item contains the :navigable attribute
# Optionally contains an order attribute, determining the order in the navbar
2016-10-31 12:48:39 +00:00
def navigables
items.select { |i| i[:navigable] }.sort_by { |x| x[:order] || 10_000 }
end
2020-08-06 13:02:14 +00:00
def subnavigables(bar)
items
.select { |i| i.attributes.dig(:subnavigation, :bar) == bar }
.sort_by { |x| x[:subnavigation][:order] || 10_000 }
end
2016-07-31 17:28:23 +00:00
end