Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Remove moving to root form API.

Matthew Kennedy599c858eda6e
diff --git a/api/app/controllers/spree/api/v2/platform/menu_items_controller.rb b/api/app/controllers/spree/api/v2/platform/menu_items_controller.rb
index 83894d5516..28e00dbd91 100644
--- a/api/app/controllers/spree/api/v2/platform/menu_items_controller.rb
+++ b/api/app/controllers/spree/api/v2/platform/menu_items_controller.rb
@@ -5,14 +5,11 @@ module Spree
class MenuItemsController < ResourceController
def reposition
@moved_item = scope.find(params[:moved_item_id])
- @new_parent = if params[:new_parent_id].nil?
- nil
- else
- scope.find(params[:new_parent_id])
- end
+ @new_parent = scope.find(params[:new_parent_id])
+ new_index = params[:new_position_idx].to_i
- if @moved_item && @new_parent
- @moved_item.move_to_child_with_index(@new_parent, params[:new_position_idx].to_i)
+ if @moved_item && @new_parent && new_index
+ @moved_item.move_to_child_with_index(@new_parent, new_index)
else
head :bad_request
end