Module: Decidim::Admin::MenuHelper

Defined in:
app/helpers/decidim/admin/menu_helper.rb

Overview

This module includes helpers to manage menus in admin layout

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#secondary_root_menuObject (readonly)

Returns the value of attribute secondary_root_menu.



80
81
82
# File 'app/helpers/decidim/admin/menu_helper.rb', line 80

def secondary_root_menu
  @secondary_root_menu
end

Instance Method Details

#add_secondary_root_menu(menu) ⇒ Object



76
77
78
# File 'app/helpers/decidim/admin/menu_helper.rb', line 76

def add_secondary_root_menu(menu)
  @secondary_root_menu = menu
end

#admin_tabs(target_menu) ⇒ Object



46
47
48
49
50
51
52
53
# File 'app/helpers/decidim/admin/menu_helper.rb', line 46

def admin_tabs(target_menu)
  ::Decidim::MenuPresenter.new(
    target_menu,
    self,
    container_options: { class: "tab-x-container" },
    active_class: "is-active"
  )
end


55
56
57
58
59
60
61
# File 'app/helpers/decidim/admin/menu_helper.rb', line 55

def breadcrumb_modules_admin_menu
  @breadcrumb_modules_admin_menu ||= ::Decidim::BreadcrumbRootMenuPresenter.new(
    :admin_menu_modules,
    self,
    container_options: { class: "menu-bar__main-dropdown__menu" }
  )
end


63
64
65
66
67
68
69
# File 'app/helpers/decidim/admin/menu_helper.rb', line 63

def breadcrumb_root_admin_menu
  @breadcrumb_root_admin_menu ||= ::Decidim::BreadcrumbRootMenuPresenter.new(
    :admin_menu,
    self,
    container_options: { class: "menu-bar__main-dropdown__menu" }
  )
end


27
28
29
30
31
32
33
34
35
# File 'app/helpers/decidim/admin/menu_helper.rb', line 27

def dropdown_menu(target_menu)
  ::Decidim::Admin::SecondaryMenuPresenter.new(
    target_menu,
    self,
    container_options: { class: "dropdown dropdown__bottom" },
    element_class: "dropdown__item",
    active_class: "is-active"
  )
end

#has_secondary_root_menu?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'app/helpers/decidim/admin/menu_helper.rb', line 82

def has_secondary_root_menu?
  @secondary_root_menu.present?
end

Public: Returns the main menu presenter object



8
9
10
11
12
13
14
15
# File 'app/helpers/decidim/admin/menu_helper.rb', line 8

def main_menu
  @main_menu ||= ::Decidim::MenuPresenter.new(
    :admin_menu,
    self,
    active_class: "is-active",
    label: t("layouts.decidim.header.main_menu")
  )
end


17
18
19
20
21
22
23
24
25
# File 'app/helpers/decidim/admin/menu_helper.rb', line 17

def main_menu_modules
  @main_menu_modules ||= ::Decidim::MenuPresenter.new(
    :admin_menu_modules,
    self,
    container_options: { class: "main-nav__modules" },
    active_class: "is-active",
    label: t("layouts.decidim.header.main_menu")
  )
end


37
38
39
40
41
42
43
44
# File 'app/helpers/decidim/admin/menu_helper.rb', line 37

def sidebar_menu(target_menu)
  ::Decidim::Admin::SecondaryMenuPresenter.new(
    target_menu,
    self,
    element_class: "sidebar-menu__item",
    active_class: "is-active"
  )
end

#simple_menu(target_menu:, options: {}) ⇒ Object



71
72
73
74
# File 'app/helpers/decidim/admin/menu_helper.rb', line 71

def simple_menu(target_menu:, options: {})
  options = { active_class: "is-active" }.merge(options)
  ::Decidim::Admin::SimpleMenuPresenter.new(target_menu, self, options)
end