Module: CoreNavBarHelper

Defined in:
app/helpers/core_nav_bar_helper.rb

Overview

Helpful methods for navigation bar on the side

Instance Method Summary collapse

Instance Method Details

Determines which css attributes should be assigned to the current menu, options are <ul>

<li>read-only -  the menu is greyed out and disabled</li>
<li>locked - a lock icon appears</li>
<li>active - if the current controller matches either the name or names</li>

</ul>



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/helpers/core_nav_bar_helper.rb', line 16

def nav_css(names, read_only = false, feature_enabled = true, feature_visible = true)
  states = []
  states << 'read-only' if read_only
  states << 'locked' unless feature_enabled
  states << 'hidden' unless feature_visible
  case names
  when String
    states << 'active' if names.eql?(controller.controller_name)
  when Array
    states << 'active' if names.include?(controller.controller_name)
  else
    states << 'active' if names.to_s.eql?(controller.controller_name)
  end
  states.join(' ')
end