Sha256: 434f09298c50f3ba1e1136208023e9c2ec0c8724028606378ac48e2ca5ef8b34

Contents?: true

Size: 840 Bytes

Versions: 47

Compression:

Stored size: 840 Bytes

Contents

module AmaLayout
  class NavigationItemDecorator < Draper::Decorator
    delegate_all

    def sub_nav
      object.sub_nav.map { |sn| sn.decorate }
    end

    def sub_nav_class
      "has-dropdown" if sub_nav.any?
    end

    def top_sub_nav
      h.render partial: "ama_layout/top_sub_nav", locals: { sub_nav: sub_nav } if sub_nav.any?
    end

    def sidebar_sub_nav
      h.render partial: "ama_layout/sub_nav", locals: { sub_nav: sub_nav } if sub_nav.any?
    end

    def active_class
      "side-nav__child-link--active-page" if active_link?
    end

  private
    def active_link?
      sub_nav.map(&:link).push(link).include? current_url_without_query
    end

    def current_url_without_query
      URI.parse(current_url).tap { |uri| uri.query = nil }.to_s
    rescue URI::InvalidURIError
      current_url
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
ama_layout-4.8.6 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.8.5 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.8.4 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.8.3 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.8.2 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.8.1 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.8.0 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.7.1 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.7.0 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.6.5 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.6.4 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.6.3 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.6.2 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.6.1 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.5.1 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.5.0 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.4.2 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.4.1 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.4.0 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.3.1 lib/ama_layout/decorators/navigation_item_decorator.rb