Class: Redmine::MenuManager::MenuItem
- Inherits:
-
Tree::TreeNode
- Object
- Tree::TreeNode
- Redmine::MenuManager::MenuItem
- Includes:
- Redmine::I18n
- Defined in:
- lib/redmine/menu_manager.rb
Instance Attribute Summary
-
- (Object) child_menus
readonly
Returns the value of attribute child_menus.
-
- (Object) condition
readonly
Returns the value of attribute condition.
-
- (Object) last
readonly
Returns the value of attribute last.
-
- (Object) name
readonly
Returns the value of attribute name.
-
- (Object) param
readonly
Returns the value of attribute param.
-
- (Object) parent
readonly
Returns the value of attribute parent.
-
- (Object) url
readonly
Returns the value of attribute url.
Instance Method Summary
- - (Object) caption(project = nil)
- - (Object) html_options(options = {})
-
- (MenuItem) initialize(name, url, options)
constructor
A new instance of MenuItem.
Methods included from Redmine::I18n
#current_language, #day_name, #find_language, #format_date, #format_time, included, #l, #l_hours, #l_or_humanize, #ll, #month_name, #set_language_if_valid, #valid_languages
Constructor Details
- (MenuItem) initialize(name, url, options)
A new instance of MenuItem
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 |
# File 'lib/redmine/menu_manager.rb', line 404 def initialize(name, url, ) raise ArgumentError, "Invalid option :if for menu item '#{name}'" if [:if] && ![:if].respond_to?(:call) raise ArgumentError, "Invalid option :html for menu item '#{name}'" if [:html] && ![:html].is_a?(Hash) raise ArgumentError, "Cannot set the :parent to be the same as this item" if [:parent] == name.to_sym raise ArgumentError, "Invalid option :children for menu item '#{name}'" if [:children] && ![:children].respond_to?(:call) @name = name @url = url @condition = [:if] @param = [:param] || :id @caption = [:caption] = [:html] || {} # Adds a unique class to each menu item based on its name [:class] = [[:class], @name.to_s.dasherize].compact.join(' ') @parent = [:parent] = [:children] @last = [:last] || false super @name.to_sym end |
Instance Attribute Details
Returns the value of attribute child_menus
402 403 404 |
# File 'lib/redmine/menu_manager.rb', line 402 def end |
- (Object) condition (readonly)
Returns the value of attribute condition
402 403 404 |
# File 'lib/redmine/menu_manager.rb', line 402 def condition @condition end |
- (Object) last (readonly)
Returns the value of attribute last
402 403 404 |
# File 'lib/redmine/menu_manager.rb', line 402 def last @last end |
- (Object) name (readonly)
Returns the value of attribute name
402 403 404 |
# File 'lib/redmine/menu_manager.rb', line 402 def name @name end |
- (Object) param (readonly)
Returns the value of attribute param
402 403 404 |
# File 'lib/redmine/menu_manager.rb', line 402 def param @param end |
- (Object) parent (readonly)
Returns the value of attribute parent
402 403 404 |
# File 'lib/redmine/menu_manager.rb', line 402 def parent @parent end |
- (Object) url (readonly)
Returns the value of attribute url
402 403 404 |
# File 'lib/redmine/menu_manager.rb', line 402 def url @url end |
Instance Method Details
- (Object) caption(project = nil)
423 424 425 426 427 428 429 430 431 432 433 434 435 |
# File 'lib/redmine/menu_manager.rb', line 423 def caption(project=nil) if @caption.is_a?(Proc) c = @caption.call(project).to_s c = @name.to_s.humanize if c.blank? c else if @caption.nil? l_or_humanize(name, :prefix => 'label_') else @caption.is_a?(Symbol) ? l(@caption) : @caption end end end |
- (Object) html_options(options = {})
437 438 439 440 441 442 443 444 445 |
# File 'lib/redmine/menu_manager.rb', line 437 def (={}) if [:selected] o = .dup o[:class] += ' selected' o else end end |