Sha256: 4adc25a4c785a30a79c4a54a410531c305552b9772c1c391d2f76d902d0800fa

Contents?: true

Size: 850 Bytes

Versions: 9

Compression:

Stored size: 850 Bytes

Contents

module Viewable
  class LinkListPresenter < ViewableListPresenter
    def wrapped_menu(name)
      h.content_tag :li do
        h.concat h.active_link_to(name, '#', active: active_menu?)
        h.concat(h.content_tag(:ul, sortable) do
          menu
        end)
      end
    end

    def menu
      each do |link|
        h.concat link.li_link_to_with_edit
      end
      h.concat(add_link) if h.cms_edit_mode?
    end

    def active_menu?
      !!active_link
    end

    def active_link
      @active_link ||= begin
        breadcrumbs
        @active_link
      end
    end

    def breadcrumbs
      @breadcrumbs ||= begin
        @active_link = nil
        take_while do |link|
          if link.active?
            @active_link = link
            false
          else
            true
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rails_admin_cms-0.1.1 app/presenters/viewable/link_list_presenter.rb
rails_admin_cms-0.0.9 app/presenters/viewable/link_list_presenter.rb
rails_admin_cms-0.0.7 app/presenters/viewable/link_list_presenter.rb
rails_admin_cms-0.0.6 app/presenters/viewable/link_list_presenter.rb
rails_admin_cms-0.0.5 app/presenters/viewable/link_list_presenter.rb
rails_admin_cms-0.0.4 app/presenters/viewable/link_list_presenter.rb
rails_admin_cms-0.0.3 app/presenters/viewable/link_list_presenter.rb
rails_admin_cms-0.0.2 app/presenters/viewable/link_list_presenter.rb
rails_admin_cms-0.0.1 app/presenters/viewable/link_list_presenter.rb