diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-11-19 10:30:02 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-11-19 10:30:02 +0000 |
commit | 124a459d55858cecd65e57ae7f312d99bcbcbb96 (patch) | |
tree | 090e11125e905e9ede7534c3e80c4521d14ba301 /lib/redmine/menu_manager.rb | |
parent | 33d78d605d0b6582512b5bca24c087730635e928 (diff) | |
download | redmine-124a459d55858cecd65e57ae7f312d99bcbcbb96.tar.gz redmine-124a459d55858cecd65e57ae7f312d99bcbcbb96.zip |
Use the main menu for project related actions that support cross-project display.
git-svn-id: http://svn.redmine.org/redmine/trunk@15983 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/menu_manager.rb')
-rw-r--r-- | lib/redmine/menu_manager.rb | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/redmine/menu_manager.rb b/lib/redmine/menu_manager.rb index 3d19edce7..9f90f681a 100644 --- a/lib/redmine/menu_manager.rb +++ b/lib/redmine/menu_manager.rb @@ -22,6 +22,9 @@ module Redmine module MenuController def self.included(base) + base.class_attribute :main_menu + base.main_menu = true + base.extend(ClassMethods) end @@ -51,6 +54,14 @@ module Redmine self.class.menu_items end + def current_menu(project) + if project && !project.new_record? + :project_menu + elsif self.class.main_menu + :application_menu + end + end + # Returns the menu item name according to the current action def current_menu_item @current_menu_item ||= menu_items[controller_name.to_sym][:actions][action_name.to_sym] || @@ -77,12 +88,14 @@ module Redmine # Renders the application main menu def render_main_menu(project) - render_menu((project && !project.new_record?) ? :project_menu : :application_menu, project) + if menu_name = controller.current_menu(project) + render_menu(menu_name, project) + end end def display_main_menu?(project) - menu_name = project && !project.new_record? ? :project_menu : :application_menu - Redmine::MenuManager.items(menu_name).children.present? + menu_name = controller.current_menu(project) + menu_name.present? && Redmine::MenuManager.items(menu_name).children.present? end def render_menu(menu, project=nil) |