Class: Spud::Admin::MenuItemsController
- Inherits:
-
CmsController
- Object
- CmsController
- Spud::Admin::MenuItemsController
- Defined in:
- app/controllers/spud/admin/menu_items_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #sort ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
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 |
# File 'app/controllers/spud/admin/menu_items_controller.rb', line 21 def create "New", :new_spud_admin_page_path = SpudMenuItem.new() . = .id if params[:spud_menu_item][:parent_id].blank? .parent_id = .id .parent_type = "SpudMenu" else .parent_type = "SpudMenuItem" end if .name.blank? && !.spud_page.blank? .name = .spud_page.name end if ..blank? highest_sibling = .parent..order("menu_order desc").first if !highest_sibling.blank? . = highest_sibling. + 1 end end flash[:notice] = "Menu Created successfully!" if .save respond_with ,:location => end |
#destroy ⇒ Object
72 73 74 75 76 77 |
# File 'app/controllers/spud/admin/menu_items_controller.rb', line 72 def destroy flash[:notice] = "Menu Item removed!" if .destroy respond_with ,:location => end |
#edit ⇒ Object
48 49 50 51 52 53 54 |
# File 'app/controllers/spud/admin/menu_items_controller.rb', line 48 def edit "Edit #{@menu_item.name}", :edit_spud_admin_menu_menu_item_path if .parent_type == "SpudMenu" .parent_id = nil end respond_with end |
#index ⇒ Object
9 10 11 12 |
# File 'app/controllers/spud/admin/menu_items_controller.rb', line 9 def index = ..order(:menu_order).includes(:spud_menu_items) respond_with end |
#new ⇒ Object
14 15 16 17 18 19 |
# File 'app/controllers/spud/admin/menu_items_controller.rb', line 14 def new "New", :new_spud_admin_page_path = ..new respond_with end |
#sort ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/controllers/spud/admin/menu_items_controller.rb', line 79 def sort = ActiveSupport::JSON.decode(params[:menu_order]) (, ) render :nothing => true, :status => 200 #id param #source position #destination position #parent # @menu_items = @menu.spud_menu_items.order(:menu_order).includes(:spud_menu_items).paginate :page => params[:page] end |
#update ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/spud/admin/menu_items_controller.rb', line 56 def update "Edit #{@menu_item.name}", :edit_spud_admin_menu_menu_item_path if params[:spud_menu_item][:parent_id].blank? params[:spud_menu_item][:parent_type] = "SpudMenu" params[:spud_menu_item][:parent_id] = .id else params[:spud_menu_item][:parent_type] = "SpudMenuItem" end .attributes = . = .id flash[:notice] = "Menu saved successfully!" if .save respond_with ,:location => end |