Class: CamaleonCms::Admin::Appearances::NavMenusController
- Inherits:
-
CamaleonCms::AdminController
- Object
- ApplicationController
- CamaleonController
- CamaleonCms::AdminController
- CamaleonCms::Admin::Appearances::NavMenusController
- Includes:
- Frontend::NavMenuHelper
- Defined in:
- app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb
Constant Summary
Constants included from UploaderHelper
UploaderHelper::SUSPICIOUS_PATTERNS
Instance Method Summary collapse
-
#add_items ⇒ Object
add items to specific nav-menu.
- #create ⇒ Object
- #custom_settings ⇒ Object
- #delete_menu_item ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
-
#edit_menu_item ⇒ Object
render edit external menu item.
- #index ⇒ Object
- #new ⇒ Object
-
#reorder_items(items = nil, parent_id = nil, is_root = true) ⇒ Object
update the reorder of items.
- #save_custom_settings ⇒ Object
- #update ⇒ Object
-
#update_menu_item ⇒ Object
update an external menu item.
Methods included from Frontend::NavMenuHelper
#breadcrumb_add, #breadcrumb_draw, #cama_menu_draw_items, #cama_menu_parse_items, #cama_parse_menu_item, #draw_menu, #get_nav_menu
Methods inherited from CamaleonCms::AdminController
Methods included from CamaleonCms::Admin::ApplicationHelper
#cama_do_pagination, #cama_get_i18n_frontend, #cama_shortcode_print
Methods included from CustomFieldsHelper
#cama_custom_field_elements, #cf_add_model
Methods included from CategoryHelper
#cama_category_get_options_html
Methods included from PostTypeHelper
#cama_hierarchy_post_list, #post_type_html_inputs, #post_type_list_taxonomy, #post_type_status
Methods included from MenusHelper
#admin_menu_add_menu, #admin_menu_append_menu_item, #admin_menu_draw, #admin_menu_insert_menu_after, #admin_menu_insert_menu_before, #admin_menu_prepend_menu_item, #admin_menus_add_commons
Methods included from BreadcrumbHelper
#admin_breadcrumb_add, #cama_admin_title_draw
Methods inherited from CamaleonController
Methods included from EmailHelper
#cama_send_email, #cama_send_mail_to_admin, #send_email, #send_password_reset_email, #send_user_confirm_email
Methods included from HooksHelper
#hook_run, #hook_skip, #hooks_run
Methods included from PluginsHelper
#current_plugin, #plugin_asset_path, #plugin_asset_url, #plugin_destroy, #plugin_install, #plugin_layout, #plugin_load_helpers, #plugin_uninstall, #plugin_upgrade, #plugin_view, #plugins_initialize, #self_plugin_key
Methods included from SiteHelper
#cama_current_site_host_port, #cama_get_list_layouts_files, #cama_get_list_template_files, #cama_is_test_request?, #current_locale, #current_site, #current_theme, #site_after_install, #site_install_theme, #site_uninstall_theme
Methods included from UploaderHelper
#cama_crop_image, #cama_file_path_to_url, #cama_resize_and_crop, #cama_resize_upload, #cama_tmp_upload, #cama_uploader, #cama_uploader_generate_thumbnail, #cama_url_to_file_path, #slugify, #slugify_folder, #upload_file, #uploader_verify_name
Methods included from CamaleonHelper
#cama_cache_fetch, #cama_draw_timer, #cama_edit_link, #cama_is_admin_request?, #cama_pluralize_text, #cama_requestAction, #cama_sitemap_cats_generator, #cama_t, #ct
Methods included from CaptchaHelper
#cama_captcha_build, #cama_captcha_increment_attack, #cama_captcha_reset_attack, #cama_captcha_tag, #cama_captcha_tags_if_under_attack, #cama_captcha_total_attacks, #cama_captcha_under_attack?, #cama_captcha_verified?, #captcha_verify_if_under_attack
Methods included from ContentHelper
#cama_content_after_draw, #cama_content_append, #cama_content_before_draw, #cama_content_init, #cama_content_prepend
Methods included from ThemeHelper
#self_theme_key, #theme_asset_file_path, #theme_asset_path, #theme_asset_url, #theme_home_page, #theme_init, #theme_layout, #theme_view
Methods included from ShortCodeHelper
#cama_strip_shortcodes, #do_shortcode, #render_shortcode, #shortcode_add, #shortcode_change_template, #shortcode_delete, #shortcodes_init
Methods included from UserRolesHelper
Methods included from HtmlHelper
#append_asset_content, #append_asset_libraries, #append_pre_asset_content, #cama_assets_library_register, #cama_draw_custom_assets, #cama_draw_pre_asset_contents, #cama_get_options_html_from_items, #cama_html_helpers_init, #cama_html_tooltip, #cama_load_libraries
Methods included from SessionHelper
#cama_authenticate, #cama_current_role, #cama_current_user, #cama_get_session_id, #cama_logout_user, #cama_on_heroku?, #cama_register_user, #cama_sign_in?, #cookie_auth_token_complete?, #cookie_split_auth_token, #login_user, #login_user_with_password, #session_back_to_parent, #session_switch_user, #user_auth_token_from_cookie
Instance Method Details
#add_items ⇒ Object
add items to specific nav-menu
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 |
# File 'app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb', line 103 def add_items items = [] @nav_menu = current_site..find(params[:nav_menu_id]) external_params = params[:external] if external_params.present? external_item = @nav_menu.((external_params)) external_item.(external_params.require(:options).permit!) if external_params[:options].present? items << external_item end if params[:custom_items].present? # custom menu items params[:custom_items].each_value do |custom_item| type = custom_item['kind'].present? ? custom_item['kind'] : 'external' items << @nav_menu.({ label: custom_item['label'], link: custom_item['url'], type: type }) end end if params[:items].present? params[:items].each_value do |item| item = @nav_menu.({ label: 'auto', link: item['id'], type: item['kind'] }) items << item end end render partial: 'menu_items', locals: { items: items, nav_menu: @nav_menu } end |
#create ⇒ Object
29 30 31 32 33 34 |
# File 'app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb', line 29 def create = current_site..new(params.require(:nav_menu).permit!) .save flash[:notice] = t('.created_menu', default: 'Created Menu') redirect_to action: :index, id: .id end |
#custom_settings ⇒ Object
54 55 56 57 58 |
# File 'app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb', line 54 def custom_settings @nav_menu = current_site..find(params[:nav_menu_id]) @nav_menu_item = current_site..find(params[:id]) render '_custom_fields', layout: 'camaleon_cms/admin/_ajax' end |
#delete_menu_item ⇒ Object
84 85 86 87 88 |
# File 'app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb', line 84 def # @nav_menu = current_site.nav_menus.find(params[:nav_menu_id]) current_site..find(params[:id]).destroy head :ok end |
#destroy ⇒ Object
48 49 50 51 52 |
# File 'app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb', line 48 def destroy current_site..find(params[:id]).destroy flash[:notice] = t('.deleted_menu', default: 'Menu destroyed') redirect_to action: :index end |
#edit ⇒ Object
43 44 45 46 |
# File 'app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb', line 43 def edit @nav_menu = current_site..find(params[:id]) render partial: 'form' end |
#edit_menu_item ⇒ Object
render edit external menu item
67 68 69 70 71 72 73 |
# File 'app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb', line 67 def render '_external_menu', layout: false, locals: { nav_menu: current_site..find(params[:nav_menu_id]), menu_item: current_site..find(params[:id]) } end |
#index ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb', line 11 def index @nav_menu = if params[:id].present? current_site..find_by_id(params[:id]) elsif params[:slug].present? current_site..find_by_slug(params[:slug]) else current_site..first end @post_types = current_site.post_types add_asset_library('nav_menu') render 'index' end |
#new ⇒ Object
24 25 26 27 |
# File 'app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb', line 24 def new @nav_menu = current_site..new render partial: 'form' end |
#reorder_items(items = nil, parent_id = nil, is_root = true) ⇒ Object
update the reorder of items
91 92 93 94 95 96 97 98 99 100 |
# File 'app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb', line 91 def reorder_items(items = nil, parent_id = nil, is_root = true) items = params[:items] if items.nil? parent_id = params[:nav_menu_id] if parent_id.nil? items.each do |index, _item| item = current_site..find(_item['id']) item.update(parent_id: parent_id, term_order: index) reorder_items(_item['children'], _item['id'], false) if _item['children'].present? end render(inline: '') if is_root end |
#save_custom_settings ⇒ Object
60 61 62 63 64 |
# File 'app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb', line 60 def save_custom_settings @nav_menu_item = current_site..find(params[:id]) @nav_menu_item.set_field_values(params.require(:field_options).permit!) head :ok end |
#update ⇒ Object
36 37 38 39 40 41 |
# File 'app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb', line 36 def update = current_site..find(params[:id]) .update(params.require(:nav_menu).permit!) flash[:notice] = t('.updated_menu', default: 'Menu updated') redirect_to action: :index, id: .id end |
#update_menu_item ⇒ Object
update an external menu item
76 77 78 79 80 81 82 |
# File 'app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb', line 76 def @nav_menu = current_site..find(params[:nav_menu_id]) item = current_site..find(params[:id]) item.((params)) item.(params.require(:options).permit!) if params[:options].present? render partial: 'menu_items', locals: { items: [item], nav_menu: @nav_menu } end |