Module: Decidim::BreadcrumbHelper
- Defined in:
- app/helpers/decidim/breadcrumb_helper.rb
Overview
This module includes helpers to manage breadcrumb in layout
Instance Attribute Summary collapse
-
#context_breadcrumb_items ⇒ Object
readonly
Returns the value of attribute context_breadcrumb_items.
-
#controller_breadcrumb_items ⇒ Object
readonly
Returns the value of attribute controller_breadcrumb_items.
-
#secondary_breadcrumb_menus ⇒ Object
readonly
Returns the value of attribute secondary_breadcrumb_menus.
Instance Method Summary collapse
- #active_breadcrumb_item(target_menu) ⇒ Object
-
#breadcrumb_items(context = :public) ⇒ Object
Public: Returns the list of breadcrumb items to be rendered in some context.
Instance Attribute Details
#context_breadcrumb_items ⇒ Object (readonly)
Returns the value of attribute context_breadcrumb_items.
6 7 8 |
# File 'app/helpers/decidim/breadcrumb_helper.rb', line 6 def @context_breadcrumb_items end |
#controller_breadcrumb_items ⇒ Object (readonly)
Returns the value of attribute controller_breadcrumb_items.
6 7 8 |
# File 'app/helpers/decidim/breadcrumb_helper.rb', line 6 def @controller_breadcrumb_items end |
#secondary_breadcrumb_menus ⇒ Object (readonly)
Returns the value of attribute secondary_breadcrumb_menus.
6 7 8 |
# File 'app/helpers/decidim/breadcrumb_helper.rb', line 6 def @secondary_breadcrumb_menus end |
Instance Method Details
#active_breadcrumb_item(target_menu) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/helpers/decidim/breadcrumb_helper.rb', line 48 def () active_item = ::Decidim::MenuPresenter.new(, self).active_item return if active_item.blank? { label: active_item.label, url: active_item.url, active: active_item.active? } end |
#breadcrumb_items(context = :public) ⇒ Object
Public: Returns the list of breadcrumb items to be rendered in some context.
context - The context (public or admin) to display the breadcrumb. It
determines the first element of the
The items are generated as the concatenation of the following 4 sections in order:
-
The root active item: This item comes from the main menu on each context and is the currently active element.
-
context_breadcrumb_items: A list which can be implemented in specific concerns and is used to display items like a participatory space or a component inside a participatory space.
-
secondary_breadcrumb_menus: A list which can be managed from HasBreadcrumbItems concern with the add_breadcrumb_item_from_menu method. The list contains the identifier of a menu to insert its items in the breadcrumb displaying the active element.
-
controller_breadcrumb_items: A list of additional breadcrumb items which is expected to receive its elements from controllers and contains the last items of the breadcrumb.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/helpers/decidim/breadcrumb_helper.rb', line 28 def (context = :public) @breadcrumb_items ||= [].tap do |items| root_active_item = if context == :admin (:admin_menu_modules) || (:admin_menu) else (:menu) end items << root_active_item if root_active_item.present? items.append(*) &.each do || active_item = () items << active_item if active_item.present? end items.append(*) end end |