Module: CamaleonCms::Admin::MenusHelper
- Includes:
- 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 menu item to admin menu at the the end key: key for menu menu: is hash like this: “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 an 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 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 menu before 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_prepend_menu_item(key, menu) ⇒ Object
prepend sub menu to menu with key = key menu: is hash like this: “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 menu item to admin menu at the the end key: key for menu menu: is hash like this: “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 an recursive array of the menus without a key
-
datas: html data text for this menu item
139 140 141 |
# File 'app/helpers/camaleon_cms/admin/menus_helper.rb', line 139 def (key, ) @_admin_menus[key] = end |
#admin_menu_append_menu_item(key, menu) ⇒ Object
append sub menu to menu with key = key menu: is hash like this: “dashboard”, title: “My title”, url: my_path, items: [sub menus]
145 146 147 148 149 150 |
# File 'app/helpers/camaleon_cms/admin/menus_helper.rb', line 145 def (key, ) return unless @_admin_menus[key].present? @_admin_menus[key][:items] = [] unless @_admin_menus[key].key?(:items) @_admin_menus[key][:items] << end |
#admin_menu_draw ⇒ Object
draw admin menu as html
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'app/helpers/camaleon_cms/admin/menus_helper.rb', line 186 def res = [] @_tmp_menu_parents = [] = _get_url_current .each do || res << "<li data-key='#{[:key]}' class='#{if .key?(:items) 'treeview' end} #{if ([:key]) 'active' end}' #{[:datas]}> <a href='#{[:url]}'><i class='fa fa-#{[:icon]}'></i> <span class=''>#{[:title]}</span> #{if .key?(:items) '<i class="fa fa-angle-left pull-right"></i>' end}</a> #{([:items]) if .key?(:items)} </li>" end res.join 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]
176 177 178 179 180 181 182 183 |
# File 'app/helpers/camaleon_cms/admin/menus_helper.rb', line 176 def (key_target, , ) res = {} @_admin_menus.each do |key, val| res[key] = val res[] = if key == key_target end @_admin_menus = res end |
#admin_menu_insert_menu_before(key_target, key_menu, menu) ⇒ Object
add menu before 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]
164 165 166 167 168 169 170 171 |
# File 'app/helpers/camaleon_cms/admin/menus_helper.rb', line 164 def (key_target, , ) res = {} @_admin_menus.each do |key, val| res[] = if key == key_target res[key] = val end @_admin_menus = res end |
#admin_menu_prepend_menu_item(key, menu) ⇒ Object
prepend sub menu to menu with key = key menu: is hash like this: “dashboard”, title: “My title”, url: my_path, items: [sub menus]
154 155 156 157 158 159 |
# File 'app/helpers/camaleon_cms/admin/menus_helper.rb', line 154 def (key, ) return unless @_admin_menus[key].present? @_admin_menus[key][:items] = [] unless @_admin_menus[key].key?(:items) @_admin_menus[key][:items] = [] + @_admin_menus[key][:items] end |
#admin_menus_add_commons ⇒ Object
6 7 8 9 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 |
# File 'app/helpers/camaleon_cms/admin/menus_helper.rb', line 6 def ('dashboard', { icon: 'dashboard', title: t('camaleon_cms.admin.sidebar.dashboard'), url: cama_admin_dashboard_path }) items = [] current_site.post_types.eager_load(:metas)..all.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 items << { icon: 'list', title: t('camaleon_cms.admin.sidebar.menus'), url: , datas: "data-intro='#{t('camaleon_cms.admin.intro.menus', image: view_context.asset_path('camaleon_cms/admin/intro/menus.png'))}' 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 ('plugins', { icon: 'plug', title: "#{t('camaleon_cms.admin.sidebar.plugins')} <small class='label label-primary'>#{PluginRoutes.all_plugins.clone.delete_if do |plugin| plugin[:domain].present? && !plugin[:domain].split(',').include?(current_site.the_slug) end.size}</small>", 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 unless items.present? ('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 |