Class: Hyrax::MenuPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/hyrax/menu_presenter.rb

Overview

view-model for the admin menu

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view_context) ⇒ MenuPresenter

Returns a new instance of MenuPresenter.



4
5
6
# File 'app/presenters/hyrax/menu_presenter.rb', line 4

def initialize(view_context)
  @view_context = view_context
end

Instance Attribute Details

#view_contextObject (readonly)

Returns the value of attribute view_context.



8
9
10
# File 'app/presenters/hyrax/menu_presenter.rb', line 8

def view_context
  @view_context
end

Instance Method Details

#collapsable_section(text, id:, icon_class:, open:, &block) ⇒ Object

Draw a collaspable menu section. The passed block should contain <li> items.



29
30
31
32
33
34
35
# File 'app/presenters/hyrax/menu_presenter.rb', line 29

def collapsable_section(text, id:, icon_class:, open:, &block)
  CollapsableSectionPresenter.new(view_context: view_context,
                                  text: text,
                                  id: id,
                                  icon_class: icon_class,
                                  open: open).render(&block)
end


19
20
21
22
23
24
25
26
# File 'app/presenters/hyrax/menu_presenter.rb', line 19

def nav_link(href, **link_options)
  list_options = current_page?(href) ? { class: 'active' } : {}
  (:li, list_options) do
    link_to(href, link_options) do
      yield
    end
  end
end

#workflows_section?Boolean

Returns true if the current controller happens to be one of the controllers that deals with workflow. This is used to keep the parent section on the sidebar open.

Returns:

  • (Boolean)


15
16
17
# File 'app/presenters/hyrax/menu_presenter.rb', line 15

def workflows_section?
  controller.instance_of? Hyrax::Admin::WorkflowRolesController
end