summaryrefslogtreecommitdiffstats
path: root/lib/redmine/menu_manager.rb
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2009-11-25 05:36:56 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2009-11-25 05:36:56 +0000
commitb75e0382557ad89069f03807d423338d906fa485 (patch)
treec23556af54c25037927b9418ba5ac5462403193c /lib/redmine/menu_manager.rb
parentb0999e3764f0554d40d243f273f23fe53e164066 (diff)
downloadredmine-b75e0382557ad89069f03807d423338d906fa485.tar.gz
redmine-b75e0382557ad89069f03807d423338d906fa485.zip
Updated menus from JPL's feedback.
* Updated Mapper#push documentation * Renamed :parent_menu to :parent * Renamed the external API for :child_menus to :children. Internally it needs to stay :child_menus because Tree::TreeNode already defines a children method for another purpose #4250 git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3092 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/menu_manager.rb')
-rw-r--r--lib/redmine/menu_manager.rb17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/redmine/menu_manager.rb b/lib/redmine/menu_manager.rb
index 320d4a655..af7d67b77 100644
--- a/lib/redmine/menu_manager.rb
+++ b/lib/redmine/menu_manager.rb
@@ -313,13 +313,16 @@ module Redmine
# * a String
# * a Proc that can take the project as argument
# * before, after: specify where the menu item should be inserted (eg. :after => :activity)
+ # * parent: menu item will be added as a child of another named menu (eg. :parent => :issues)
+ # * children: a Proc that is called before rendering the item. The Proc should return an array of MenuItems, which will be added as children to this item.
+ # eg. :children => Proc.new {|project| [Redmine::MenuManager::MenuItem.new(...)] }
# * last: menu item will stay at the end (eg. :last => true)
# * html_options: a hash of html options that are passed to link_to
def push(name, url, options={})
options = options.dup
- if options[:parent_menu]
- subtree = self.find(options[:parent_menu])
+ if options[:parent]
+ subtree = self.find(options[:parent])
if subtree
target_root = subtree
else
@@ -383,13 +386,13 @@ module Redmine
class MenuItem < Tree::TreeNode
include Redmine::I18n
- attr_reader :name, :url, :param, :condition, :parent_menu, :child_menus
+ attr_reader :name, :url, :param, :condition, :parent, :child_menus
def initialize(name, url, options)
raise ArgumentError, "Invalid option :if for menu item '#{name}'" if options[:if] && !options[:if].respond_to?(:call)
raise ArgumentError, "Invalid option :html for menu item '#{name}'" if options[:html] && !options[:html].is_a?(Hash)
- raise ArgumentError, "Cannot set the :parent_menu to be the same as this item" if options[:parent_menu] == name.to_sym
- raise ArgumentError, "Invalid option :child_menus for menu item '#{name}'" if options[:child_menus] && !options[:child_menus].respond_to?(:call)
+ raise ArgumentError, "Cannot set the :parent to be the same as this item" if options[:parent] == name.to_sym
+ raise ArgumentError, "Invalid option :children for menu item '#{name}'" if options[:children] && !options[:children].respond_to?(:call)
@name = name
@url = url
@condition = options[:if]
@@ -398,8 +401,8 @@ module Redmine
@html_options = options[:html] || {}
# Adds a unique class to each menu item based on its name
@html_options[:class] = [@html_options[:class], @name.to_s.dasherize].compact.join(' ')
- @parent_menu = options[:parent_menu]
- @child_menus = options[:child_menus]
+ @parent = options[:parent]
+ @child_menus = options[:children]
super @name.to_sym
end