Skip to content

Commit

Permalink
Implement redirect to previous page after stock item saving
Browse files Browse the repository at this point in the history
Co-Authored-By: Elia Schito <[email protected]>
  • Loading branch information
rainerdema and elia committed Dec 7, 2023
1 parent cbd7afd commit ac4ccc5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@
checked: f.object.backorderable?,
include_hidden: true,
) %>

<% if params[:q] %>
<%= f.hidden_field :q, value: params[:q].to_json, id: false %>
<% end %>

<% if params[:page] %>
<%= f.hidden_field :page, value: params[:page], id: false %>
<% end %>
</div>
<% end %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ def update
@stock_item.stock_movements.build(quantity: quantity_adjustment, originator: current_solidus_admin_user)

if @stock_item.save
redirect_to solidus_admin.stock_items_path, status: :see_other
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
else
respond_to do |format|
format.html { render component('stock_items/edit').new(stock_item: @stock_item, page: @page), status: :unprocessable_entity }
Expand Down

0 comments on commit ac4ccc5

Please sign in to comment.