Class: Hyrax::MenuPresenter
- Inherits:
-
Object
- Object
- Hyrax::MenuPresenter
- Defined in:
- app/presenters/hyrax/menu_presenter.rb
Overview
view-model for the admin menu
Instance Attribute Summary collapse
-
#view_context ⇒ Object
readonly
Returns the value of attribute view_context.
Instance Method Summary collapse
-
#collapsable_section(text, id:, icon_class:, open:, &block) ⇒ Object
Draw a collaspable menu section.
-
#initialize(view_context) ⇒ MenuPresenter
constructor
A new instance of MenuPresenter.
- #nav_link(href, **link_options) ⇒ Object
-
#workflows_section? ⇒ Boolean
Returns true if the current controller happens to be one of the controllers that deals with workflow.
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_context ⇒ Object (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 |
#nav_link(href, **link_options) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/presenters/hyrax/menu_presenter.rb', line 19 def nav_link(href, **) = current_page?(href) ? { class: 'active' } : {} content_tag(:li, ) do link_to(href, ) 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.
15 16 17 |
# File 'app/presenters/hyrax/menu_presenter.rb', line 15 def workflows_section? controller.instance_of? Hyrax::Admin::WorkflowRolesController end |