Sha256: e22920139337d3abf2ce10d6f029840bd896fa4d8913bbf6c49774d91908528b

Contents?: true

Size: 954 Bytes

Versions: 33

Compression:

Stored size: 954 Bytes

Contents

# frozen_string_literal: true

#
# Helpful methods for navigation bar on the side
#
module CoreNavBarHelper
  #
  # 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>
  #
  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
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
web47core-3.2.20 app/helpers/core_nav_bar_helper.rb
web47core-3.2.19 app/helpers/core_nav_bar_helper.rb
web47core-3.2.18 app/helpers/core_nav_bar_helper.rb
web47core-3.2.17 app/helpers/core_nav_bar_helper.rb
web47core-3.2.16 app/helpers/core_nav_bar_helper.rb
web47core-3.2.15 app/helpers/core_nav_bar_helper.rb
web47core-3.2.14 app/helpers/core_nav_bar_helper.rb
web47core-3.2.13 app/helpers/core_nav_bar_helper.rb
web47core-3.2.12 app/helpers/core_nav_bar_helper.rb
web47core-3.2.9 app/helpers/core_nav_bar_helper.rb
web47core-3.2.8 app/helpers/core_nav_bar_helper.rb
web47core-3.2.7 app/helpers/core_nav_bar_helper.rb
web47core-3.2.6 app/helpers/core_nav_bar_helper.rb
web47core-3.2.5 app/helpers/core_nav_bar_helper.rb
web47core-3.2.4 app/helpers/core_nav_bar_helper.rb
web47core-2.2.20 app/helpers/core_nav_bar_helper.rb
web47core-2.2.19 app/helpers/core_nav_bar_helper.rb
web47core-3.2.3 app/helpers/core_nav_bar_helper.rb
web47core-3.2.2 app/helpers/core_nav_bar_helper.rb
web47core-2.2.15 app/helpers/core_nav_bar_helper.rb