Module: CamaleonCms::Admin::MenusHelper
- Includes:
- ActionView::Helpers::OutputSafetyHelper, ActionView::Helpers::TagHelper, BreadcrumbHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/camaleon_cms/admin/menus_helper.rb
Instance Method Summary collapse
-
#admin_menu_add_menu(key, menu) ⇒ Object
add a menu item to the menu at the end key: key for the menu menu: is hash like this: { icon: "dashboard", title: "My title", url: my_path, items: [sub menus] } - icon: font-awesome icon (it is already included "fa fa-") - title: title for the menu - url: url for the menu - items: is a recursive array of the menus without a key - datas: HTML data text for this menu item.
-
#admin_menu_append_menu_item(key, menu) ⇒ Object
append sub menu to menu with a key = key menu: is hash like this: "dashboard", title: "My title", url: my_path, items: [sub menus].
-
#admin_menu_draw ⇒ Object
draw admin menu as html.
-
#admin_menu_insert_menu_after(key_target, key_menu, menu) ⇒ Object
add menu after menu with key = key_target key_menu: key for menu menu: is hash like this: "dashboard", title: "My title", url: my_path, items: [sub menus].
-
#admin_menu_insert_menu_before(key_target, key_menu, menu) ⇒ Object
add the menu before the menu with key = key_target key_menu: key for menu menu: is hash like this: { icon: "dashboard", title: "My title", url: my_path, items: [sub menus] }.
-
#admin_menu_prepend_menu_item(key, menu) ⇒ Object
prepend submenu to menu with key = key menu: is hash like this: { icon: "dashboard", title: "My title", url: my_path, items: [sub menus] }.
- #admin_menus_add_commons ⇒ Object
Methods included from BreadcrumbHelper
#admin_breadcrumb_add, #cama_admin_title_draw
Instance Method Details
#admin_menu_add_menu(key, menu) ⇒ Object
add a menu item to the menu at the end key: key for the menu menu: is hash like this: { icon: "dashboard", title: "My title", url: my_path, items: [sub menus] }
- icon: font-awesome icon (it is already included "fa fa-")
- title: title for the menu
- url: url for the menu
- items: is a recursive array of the menus without a key
- datas: HTML data text for this menu item
199 200 201 202 |
# File 'app/helpers/camaleon_cms/admin/menus_helper.rb', line 199 def (key, ) CurrentRequest. ||= {} CurrentRequest.[key] = end |
#admin_menu_append_menu_item(key, menu) ⇒ Object
append sub menu to menu with a key = key menu: is hash like this: "dashboard", title: "My title", url: my_path, items: [sub menus]
206 207 208 209 210 211 212 |
# File 'app/helpers/camaleon_cms/admin/menus_helper.rb', line 206 def (key, ) CurrentRequest. ||= {} return if CurrentRequest.[key].blank? CurrentRequest.[key][:items] = [] unless CurrentRequest.[key].key?(:items) CurrentRequest.[key][:items] << end |
#admin_menu_draw ⇒ Object
draw admin menu as html
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'app/helpers/camaleon_cms/admin/menus_helper.rb', line 249 def CurrentRequest. ||= {} = [] = _get_url_current(CurrentRequest., ) safe_join(.map do || css_class = +'' css_class << 'treeview ' if .key?(:items) css_class << 'active' if ([:key], ) css_class.strip! data_attrs = parse_datas([:datas]) content_tag( :li, ''.html_safe, class: css_class.presence, data: { key: [:key] }.merge!(data_attrs.presence || {}) ) do safe_join([ content_tag(:a, href: [:url]) do safe_join([ content_tag(:i, nil, class: "fa fa-#{[:icon]}"), ' ', content_tag(:span, ([:title])), (content_tag(:i, nil, class: 'fa fa-angle-left pull-right') if .key?(:items)) ].compact) end, (([:items], ) if .key?(:items)) ].compact) end end) end |
#admin_menu_insert_menu_after(key_target, key_menu, menu) ⇒ Object
add menu after menu with key = key_target key_menu: key for menu menu: is hash like this: "dashboard", title: "My title", url: my_path, items: [sub menus]
239 240 241 242 243 244 245 246 |
# File 'app/helpers/camaleon_cms/admin/menus_helper.rb', line 239 def (key_target, , ) CurrentRequest. ||= {} res = CurrentRequest..each_with_object({}) do |(key, val), hsh| hsh[key] = val hsh[] = if key == key_target end CurrentRequest..replace(res) # mutate in place so @_admin_menus stays a live alias (M19) end |
#admin_menu_insert_menu_before(key_target, key_menu, menu) ⇒ Object
add the menu before the menu with key = key_target key_menu: key for menu menu: is hash like this: { icon: "dashboard", title: "My title", url: my_path, items: [sub menus] }
227 228 229 230 231 232 233 234 |
# File 'app/helpers/camaleon_cms/admin/menus_helper.rb', line 227 def (key_target, , ) CurrentRequest. ||= {} res = CurrentRequest..each_with_object({}) do |(key, val), hsh| hsh[] = if key == key_target hsh[key] = val end CurrentRequest..replace(res) # mutate in place so @_admin_menus stays a live alias (M19) end |
#admin_menu_prepend_menu_item(key, menu) ⇒ Object
prepend submenu to menu with key = key menu: is hash like this: { icon: "dashboard", title: "My title", url: my_path, items: [sub menus] }
216 217 218 219 220 221 222 |
# File 'app/helpers/camaleon_cms/admin/menus_helper.rb', line 216 def (key, ) CurrentRequest. ||= {} return if CurrentRequest.[key].blank? CurrentRequest.[key][:items] = [] unless CurrentRequest.[key].key?(:items) CurrentRequest.[key][:items] = [] + CurrentRequest.[key][:items] end |
#admin_menus_add_commons ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 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 144 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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'app/helpers/camaleon_cms/admin/menus_helper.rb', line 10 def ( 'dashboard', { icon: 'dashboard', title: t('camaleon_cms.admin.sidebar.dashboard'), url: cama_admin_dashboard_path } ) items = [] current_site.post_types.eager_load(:metas)..find_each do |pt| pt = pt.decorate items_i = [] if can? :posts, pt items_i << { icon: 'list', title: t('camaleon_cms.admin.post_type.all').to_s, url: cama_admin_post_type_posts_path(pt.id) } end if can? :create_post, pt items_i << { icon: 'plus', title: t('camaleon_cms.admin.post_type.add_new', type_title: pt.the_title).to_s, url: new_cama_admin_post_type_post_path(pt.id) } end if pt.manage_categories? && (can? :categories, pt) items_i << { icon: 'folder-open', title: t('camaleon_cms.admin.post_type.categories'), url: cama_admin_post_type_categories_path(pt.id) } end if pt. && (can? :post_tags, pt) items_i << { icon: 'tags', title: t('camaleon_cms.admin.post_type.tags'), url: (pt.id) } end if items_i.present? items << { icon: pt.get_option('icon', 'copy'), title: pt.the_title, url: '', items: items_i } end end if items.present? ( 'content', { icon: 'database', title: t('camaleon_cms.admin.sidebar.contents'), url: '', items: items, datas: "data-intro='#{t('camaleon_cms.admin.intro.content')}' data-position='right' data-wait='600'" } ) end # end if can? :manage, :media ( 'media', { icon: 'picture-o', title: t('camaleon_cms.admin.sidebar.media'), url: cama_admin_media_path, datas: "data-intro='#{t('camaleon_cms.admin.intro.media')}' data-position='right'" } ) end if can? :manage, :comments ( 'comments', { icon: 'comments', title: t('camaleon_cms.admin.sidebar.comments'), url: cama_admin_comments_path, datas: "data-intro='#{t('camaleon_cms.admin.intro.comments')}' data-position='right'" } ) end items = [] if can? :manage, :themes items << { icon: 'desktop', title: t('camaleon_cms.admin.sidebar.themes'), url: cama_admin_appearances_themes_path, datas: "data-intro='#{t('camaleon_cms.admin.intro.themes')}' data-position='right'" } end if can? :manage, :widgets items << { icon: 'archive', title: t('camaleon_cms.admin.sidebar.widgets'), url: , datas: "data-intro='#{t('camaleon_cms.admin.intro.widgets')}' data-position='right'" } end if can? :manage, :nav_menu = t('camaleon_cms.admin.intro.menus', image: view_context.asset_path('camaleon_cms/admin/intro/menus.png')) items << { icon: 'list', title: t('camaleon_cms.admin.sidebar.menus'), url: , datas: "data-intro='#{}' data-position='right'" } end if can? :manage, :shortcodes items << { icon: 'code', title: t('camaleon_cms.admin.sidebar.shortcodes', default: 'Shortcodes'), url: cama_admin_settings_shortcodes_path, datas: "data-intro='#{t('camaleon_cms.admin.intro.shortcodes')}' data-position='right'" } end if items.present? ( 'appearance', { icon: 'paint-brush', title: t('camaleon_cms.admin.sidebar.appearance'), url: '', items: items, datas: "data-intro='#{t('camaleon_cms.admin.intro.appearance')}' data-position='right' data-wait='500'" } ) end if can? :manage, :plugins plugin_count = PluginRoutes.all_plugins.count do |plugin| !(plugin[:domain].present? && !plugin[:domain].split(',').include?(current_site.the_slug)) end ( 'plugins', { icon: 'plug', title: safe_join([ t('camaleon_cms.admin.sidebar.plugins'), ' ', content_tag(:small, plugin_count, class: 'label label-primary') ]), url: cama_admin_plugins_path, datas: "data-intro='#{t('camaleon_cms.admin.intro.plugins')}' data-position='right'" } ) end if can? :manage, :users items = [] items << { icon: 'list', title: t('camaleon_cms.admin.users.all_users'), url: cama_admin_users_path } items << { icon: 'plus', title: t('camaleon_cms.admin.users.add_user'), url: new_cama_admin_user_path } items << { icon: 'group', title: t('camaleon_cms.admin.users.user_roles'), url: cama_admin_user_roles_path } ( 'users', { icon: 'users', title: t('camaleon_cms.admin.sidebar.users'), url: '', items: items, datas: "data-intro='#{t('camaleon_cms.admin.intro.users')}' data-position='right' data-wait='500'" } ) end items = [] if can? :manage, :settings items << { icon: 'desktop', title: t('camaleon_cms.admin.sidebar.general_site'), url: cama_admin_settings_site_path, datas: "data-intro='#{t('camaleon_cms.admin.intro.gral_site')}' data-position='right'" } if current_site.manage_sites? items << { icon: 'cog', title: t('camaleon_cms.admin.sidebar.sites'), url: cama_admin_settings_sites_path, datas: "data-intro='#{t('camaleon_cms.admin.intro.sites')}' data-position='right'" } end items << { icon: 'files-o', title: t('camaleon_cms.admin.sidebar.content_groups'), url: cama_admin_settings_post_types_path, datas: "data-intro='#{t('camaleon_cms.admin.intro.post_type')}' data-position='right'" } items << { icon: 'cog', title: t('camaleon_cms.admin.sidebar.custom_fields'), url: cama_admin_settings_custom_fields_path, datas: "data-intro='#{t('camaleon_cms.admin.intro.custom_fields')}' data-position='right'" } items << { icon: 'language', title: t('camaleon_cms.admin.sidebar.languages'), url: cama_admin_settings_languages_path, datas: "data-intro='#{t('camaleon_cms.admin.intro.languages')}' data-position='right'" } end if can? :manage, :theme_settings items << { icon: 'windows', title: t('camaleon_cms.admin.settings.theme_setting', default: 'Theme Settings'), url: cama_admin_settings_theme_path } end return if items.blank? ( 'settings', { icon: 'cogs', title: t('camaleon_cms.admin.sidebar.settings'), url: '', items: items, datas: "data-intro='#{t('camaleon_cms.admin.intro.settings')}' data-position='right' data-wait='500'" } ) end |