Class: Decidim::DecidimAwesome::Menu
- Inherits:
-
Object
- Object
- Decidim::DecidimAwesome::Menu
- Defined in:
- lib/decidim/decidim_awesome/menu.rb
Class Method Summary collapse
-
.config_enabled?(*vars) ⇒ Boolean
ensure boolean value.
- .first_enabled(*vars) ⇒ Object
- .main_path_for(config_var) ⇒ Object
- .menus ⇒ Object
- .register_awesome_admin_menu! ⇒ Object
- .register_custom_fields_submenu! ⇒ Object
- .register_custom_styles_submenu! ⇒ Object
- .register_maintenance_admin_menu! ⇒ Object
- .register_menu_hacks_submenu! ⇒ Object
- .register_simple_entry(menu_registry, name, position, icon, options = {}) ⇒ Object
Class Method Details
.config_enabled?(*vars) ⇒ Boolean
ensure boolean value
208 209 210 |
# File 'lib/decidim/decidim_awesome/menu.rb', line 208 def config_enabled?(*vars) DecidimAwesome.enabled?(*vars) end |
.first_enabled(*vars) ⇒ Object
200 201 202 203 204 205 |
# File 'lib/decidim/decidim_awesome/menu.rb', line 200 def first_enabled(*vars) vars.each do |var| return var if config_enabled?(var) end nil end |
.main_path_for(config_var) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/decidim/decidim_awesome/menu.rb', line 31 def main_path_for(config_var) case config_var.to_sym when :styles [:config_path, [[:styles]]] when :custom_fields [:config_path, [[:custom_fields]]] when :menu_hacks [:menu_hacks_path, [[:menu_hacks]]] when :custom_redirects [:custom_redirects_path, []] when :maintenance [:checks_path, []] else [:config_path, [config_var]] end end |
.menus ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/decidim/decidim_awesome/menu.rb', line 171 def ||= { editors: config_enabled?(:allow_images_in_editors, :allow_videos_in_editors), proposals: config_enabled?( :allow_images_in_proposals, :validate_title_min_length, :validate_title_max_caps_percent, :validate_title_max_marks_together, :validate_title_start_with_caps, :validate_body_min_length, :validate_body_max_caps_percent, :validate_body_max_marks_together, :validate_body_start_with_caps ), surveys: config_enabled?(:auto_save_forms, :user_timezone, :hashcash_signup, :hashcash_login), styles: first_enabled(:scoped_styles, :scoped_admin_styles), scoped_styles: config_enabled?(:scoped_styles), scoped_admin_styles: config_enabled?(:scoped_admin_styles), custom_fields: first_enabled(:proposal_custom_fields, :proposal_private_custom_fields), proposal_custom_fields: config_enabled?(:proposal_custom_fields), proposal_private_custom_fields: config_enabled?(:proposal_private_custom_fields), admins: config_enabled?(:scoped_admins), menu_hacks: first_enabled(:menu, :mobile_menu, :home_content_block_menu), menu_hacks_menu: config_enabled?(:menu), menu_hacks_mobile_menu: config_enabled?(:mobile_menu), menu_hacks_home_content_block_menu: config_enabled?(:home_content_block_menu), custom_redirects: config_enabled?(:custom_redirects), livechat: config_enabled?(:intergram_for_admins, :intergram_for_public), verifications: config_enabled?(:force_authorizations), maintenance: true } end |
.register_awesome_admin_menu! ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/decidim/decidim_awesome/menu.rb', line 48 def register_simple_entry(:awesome_admin_menu, :editors, 1, "editors-text") register_simple_entry(:awesome_admin_menu, :proposals, 2, "documents") register_simple_entry(:awesome_admin_menu, :surveys, 3, "surveys") register_simple_entry(:awesome_admin_menu, :styles, 4, "brush", submenu: { target_menu: :custom_styles_submenu }, active: [[:config_path, :scoped_styles], [:config_path, :scoped_admin_styles]]) register_simple_entry(:awesome_admin_menu, :custom_fields, 5, "layers", i18n_key: "menu.proposal_custom_fields", submenu: { target_menu: :custom_fields_submenu }, active: [[:config_path, :proposal_custom_fields], [:config_path, :proposal_private_custom_fields]]) register_simple_entry(:awesome_admin_menu, :admins, 6, "group-line") register_simple_entry(:awesome_admin_menu, :menu_hacks, 7, "menu-line", submenu: { target_menu: :menu_hacks_submenu }, active: [[:menu_hacks_path, :menu], [:menu_hacks_path, :mobile_menu], [:menu_hacks_path, :home_content_block_menu]]) register_simple_entry(:awesome_admin_menu, :custom_redirects, 8, "external-link-line") register_simple_entry(:awesome_admin_menu, :livechat, 9, "chat-1-line") register_simple_entry(:awesome_admin_menu, :verifications, 10, "fingerprint-line") register_simple_entry(:awesome_admin_menu, :maintenance, 11, "tools-line", i18n_key: "menu.maintenance.maintenance", submenu: { target_menu: :maintenance_submenu }, active: [[:private_data_path], [:hashcashes_path], [:checks_path]]) end |
.register_custom_fields_submenu! ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/decidim/decidim_awesome/menu.rb', line 77 def Decidim. :custom_fields_submenu do || if [:proposal_custom_fields].present? .add_item :proposal_custom_fields, I18n.t("menu.title", scope: "decidim.decidim_awesome.admin.proposal_custom_fields"), decidim_admin_decidim_awesome.config_path(:proposal_custom_fields), position: 5.1, icon_name: "draft-line" end if [:proposal_private_custom_fields].present? .add_item :proposal_private_custom_fields, I18n.t("proposal_private_custom_fields", scope: "decidim.decidim_awesome.admin.proposal_custom_fields"), decidim_admin_decidim_awesome.config_path(:proposal_private_custom_fields), position: 5.2, icon_name: "spy" end end end |
.register_custom_styles_submenu! ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/decidim/decidim_awesome/menu.rb', line 97 def Decidim. :custom_styles_submenu do || if [:scoped_styles].present? .add_item :scoped_styles, I18n.t("menu.title", scope: "decidim.decidim_awesome.admin.scoped_styles"), decidim_admin_decidim_awesome.config_path(:scoped_styles), position: 4.1, icon_name: "computer-line" end if [:scoped_admin_styles].present? .add_item :scoped_admin_styles, I18n.t("menu.title", scope: "decidim.decidim_awesome.admin.scoped_admin_styles"), decidim_admin_decidim_awesome.config_path(:scoped_admin_styles), position: 4.2, icon_name: "file-settings-line" end end end |
.register_maintenance_admin_menu! ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/decidim/decidim_awesome/menu.rb', line 145 def Decidim. :maintenance_submenu do || if config_enabled?(:proposal_private_custom_fields) .add_item :private_data, I18n.t("private_data", scope: "decidim.decidim_awesome.admin.menu.maintenance"), decidim_admin_decidim_awesome.private_data_path, position: 10.1, icon_name: "spy-line" end if config_enabled?(:hashcash_signup, :hashcash_login) .add_item :hashcash, I18n.t("hashcash", scope: "decidim.decidim_awesome.admin.menu.maintenance"), decidim_admin_decidim_awesome.hashcashes_path, position: 10.2, icon_name: "hashtag" end .add_item :checks, I18n.t("checks", scope: "decidim.decidim_awesome.admin.menu.maintenance"), decidim_admin_decidim_awesome.checks_path, position: 10.3, icon_name: "pulse" end end |
.register_menu_hacks_submenu! ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/decidim/decidim_awesome/menu.rb', line 117 def Decidim. :menu_hacks_submenu do || if [:menu_hacks_menu].present? .add_item :main_menu, I18n.t("menu.title", scope: "decidim.decidim_awesome.admin.menu_hacks.index"), decidim_admin_decidim_awesome.(:menu), position: 7.1, icon_name: "global-line" end if [:menu_hacks_mobile_menu].present? .add_item :mobile_menu, I18n.t("mobile_menu.title", scope: "decidim.decidim_awesome.admin.menu_hacks.index"), decidim_admin_decidim_awesome.(:mobile_menu), position: 7.2, icon_name: "smartphone" end if [:menu_hacks_home_content_block_menu].present? .add_item :content_block_main_menu, I18n.t("home_content_block_menu.title", scope: "decidim.decidim_awesome.admin.menu_hacks.index"), decidim_admin_decidim_awesome.(:home_content_block_menu), position: 7.3, icon_name: "layout-masonry-line" end end end |
.register_simple_entry(menu_registry, name, position, icon, options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/decidim/decidim_awesome/menu.rb', line 7 def register_simple_entry(, name, position, icon, = {}) return if [name].blank? Decidim. do || i18n_key = [:i18n_key].presence || "menu.#{name}" extra = {}.tap do |hash| hash[:submenu] = [:submenu] if [:submenu].present? if [:active].present? hash[:active] = false [:active].each do |active_path| hash[:active] ||= is_active_link?(decidim_admin_decidim_awesome.send(active_path[0], *active_path[1..])) end end end path = main_path_for(name) .add_item name, I18n.t(i18n_key, scope: "decidim.decidim_awesome.admin"), decidim_admin_decidim_awesome.send(path[0], path[1]), position:, icon_name: icon, **extra end end |