make messages plugin work with custom navigation menu
This commit is contained in:
parent
d7938b752c
commit
89f4a18b24
1 changed files with 7 additions and 4 deletions
|
@ -1,11 +1,14 @@
|
||||||
module FoodsoftMessages
|
module FoodsoftMessages
|
||||||
class Engine < ::Rails::Engine
|
class Engine < ::Rails::Engine
|
||||||
def navigation(primary, context)
|
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
|
sub_nav = primary[:foodcoop].sub_navigation
|
||||||
# display right before tasks item
|
sub_nav.items <<
|
||||||
tasks_index = sub_nav.items.index(sub_nav[:tasks])
|
SimpleNavigation::Item.new(primary, :messages, I18n.t('navigation.messages'), context.messages_path)
|
||||||
sub_nav.items.insert(tasks_index, item)
|
# 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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue