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-5.11.0 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-6.10.0.pre lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-5.10.0 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-5.9.0 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-5.8.0 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-5.7.0 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-5.6.0 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-5.5.0 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-5.4.0 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-6.3.0.pre lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-5.2.0 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-5.1.1 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-5.1.0 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-5.0.2 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-5.0.1 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-5.0.0 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.10.1 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.10.0 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.9.0 lib/ama_layout/decorators/navigation_item_decorator.rb
ama_layout-4.8.7 lib/ama_layout/decorators/navigation_item_decorator.rb