make messages plugin work with custom navigation menu

This commit is contained in:
wvengen 2014-03-24 17:35:25 +01:00
parent d7938b752c
commit 89f4a18b24

View file

@ -1,11 +1,14 @@
module FoodsoftMessages
class Engine < ::Rails::Engine
def navigation(primary, context)
item = SimpleNavigation::Item.new(primary, :messages, I18n.t('navigation.messages'), context.messages_path)
return if primary[:foodcoop].nil?
sub_nav = primary[:foodcoop].sub_navigation
# display right before tasks item
tasks_index = sub_nav.items.index(sub_nav[:tasks])
sub_nav.items.insert(tasks_index, item)
sub_nav.items <<
SimpleNavigation::Item.new(primary, :messages, I18n.t('navigation.messages'), context.messages_path)
# move to right before tasks item
if i = sub_nav.items.index(sub_nav[:tasks])
sub_nav.items.insert(i, sub_nav.items.delete_at(-1))
end
end
end
end