Skip to content

Commit

Permalink
Remove explicit handling of q and page params
Browse files Browse the repository at this point in the history
With the modal managed via turbo frame and turbo stream refresh,
all this custom explicit params management is not needed anymore.
  • Loading branch information
spaghetticode committed Mar 11, 2024
1 parent b837c1c commit 71569de
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,4 @@ def title
def form_id
"#{stimulus_id}-#{dom_id(@stock_item)}"
end

def permitted_query_params
return params[:q].permit! if params[:q].respond_to?(:permit)
{}
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@ def count_on_hand_column
}
end

def permitted_query_params
return params[:q].permit! if params[:q].respond_to?(:permit)
{}
end

def turbo_frames
%w[edit_stock_item_modal]
end
Expand Down
9 changes: 3 additions & 6 deletions admin/app/controllers/solidus_admin/stock_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ def edit

def update
quantity_adjustment = params[:quantity_adjustment].to_i
@stock_item.assign_attributes(stock_item_params.except(:page, :q))
@stock_item.assign_attributes(stock_item_params)
@stock_item.stock_movements.build(quantity: quantity_adjustment, originator: current_solidus_admin_user)

if @stock_item.save
redirect_to solidus_admin.stock_items_path(
page: stock_item_params[:page].to_i.presence,
q: stock_item_params[:q].presence&.then { |q| JSON.parse(q) }
), status: :see_other
redirect_to solidus_admin.stock_items_path, status: :see_other
else
respond_to do |format|
format.html { render component('stock_items/edit').new(stock_item: @stock_item, page: @page), status: :unprocessable_entity }
Expand Down Expand Up @@ -61,7 +58,7 @@ def load_stock_item
end

def stock_item_params
params.require(:stock_item).permit(:backorderable, :page, :q)
params.require(:stock_item).permit(:backorderable)
end
end
end

0 comments on commit 71569de

Please sign in to comment.