Sha256: 2aa94532268fd1eaf0ece3059d2c919b5ce71953df18f96c196463b0614a2419

Contents?: true

Size: 982 Bytes

Versions: 62

Compression:

Stored size: 982 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
    if names.is_a? String
      states << 'active' if names.eql?(controller.controller_name)
    elsif names.is_a? Symbol
      states << 'active' if names.to_s.eql?(controller.controller_name)
    elsif names.is_a? Array
      states << 'active' if names.include?(controller.controller_name)
    end
    states.join(' ')
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
web47core-1.1.16 app/helpers/core_nav_bar_helper.rb
web47core-1.1.15 app/helpers/core_nav_bar_helper.rb
web47core-1.1.14 app/helpers/core_nav_bar_helper.rb
web47core-1.1.13 app/helpers/core_nav_bar_helper.rb
web47core-1.1.12 app/helpers/core_nav_bar_helper.rb
web47core-1.1.11 app/helpers/core_nav_bar_helper.rb
web47core-2.0.1 app/helpers/core_nav_bar_helper.rb
web47core-2.0.0 app/helpers/core_nav_bar_helper.rb
web47core-1.1.10 app/helpers/core_nav_bar_helper.rb
web47core-1.1.9 app/helpers/core_nav_bar_helper.rb
web47core-1.1.8 app/helpers/core_nav_bar_helper.rb
web47core-1.1.7 app/helpers/core_nav_bar_helper.rb
web47core-1.1.6 app/helpers/core_nav_bar_helper.rb
web47core-1.1.5 app/helpers/core_nav_bar_helper.rb
web47core-1.1.4 app/helpers/core_nav_bar_helper.rb
web47core-1.1.3 app/helpers/core_nav_bar_helper.rb
web47core-1.1.2 app/helpers/core_nav_bar_helper.rb
web47core-1.1.1 app/helpers/core_nav_bar_helper.rb
web47core-1.1.0 app/helpers/core_nav_bar_helper.rb
web47core-1.0.18 app/helpers/core_nav_bar_helper.rb