Class: Redmine::MenuManager::MenuItem
- Inherits:
-
Object
- Object
- Redmine::MenuManager::MenuItem
- Includes:
- I18n
- Defined in:
- lib/redmine/menu_manager.rb
Instance Attribute Summary (collapse)
-
- (Object) condition
readonly
Returns the value of attribute condition.
-
- (Object) name
readonly
Returns the value of attribute name.
-
- (Object) param
readonly
Returns the value of attribute param.
-
- (Object) url
readonly
Returns the value of attribute url.
Instance Method Summary (collapse)
- - (Object) caption(project = nil)
- - (Object) html_options(options = {})
-
- (MenuItem) initialize(name, url, options)
constructor
A new instance of MenuItem.
Methods included from 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
181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/redmine/menu_manager.rb', line 181 def initialize(name, url, ) raise "Invalid option :if for menu item '#{name}'" if [:if] && ![:if].respond_to?(:call) raise "Invalid option :html for menu item '#{name}'" if [:html] && ![:html].is_a?(Hash) @name = name @url = url @condition = [:if] @param = [:param] || :id @caption = [:caption] @html_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(' ') end |
Instance Attribute Details
- (Object) condition (readonly)
Returns the value of attribute condition
179 180 181 |
# File 'lib/redmine/menu_manager.rb', line 179 def condition @condition end |
- (Object) name (readonly)
Returns the value of attribute name
179 180 181 |
# File 'lib/redmine/menu_manager.rb', line 179 def name @name end |
- (Object) param (readonly)
Returns the value of attribute param
179 180 181 |
# File 'lib/redmine/menu_manager.rb', line 179 def param @param end |
- (Object) url (readonly)
Returns the value of attribute url
179 180 181 |
# File 'lib/redmine/menu_manager.rb', line 179 def url @url end |
Instance Method Details
- (Object) caption(project = nil)
194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/redmine/menu_manager.rb', line 194 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 = {})
208 209 210 211 212 213 214 215 216 |
# File 'lib/redmine/menu_manager.rb', line 208 def (={}) if [:selected] o = @html_options.dup o[:class] += ' selected' o else @html_options end end |