Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Admin] Add stock_items/edit modal component #5543

Merged
merged 9 commits into from
Dec 12, 2023
Prev Previous commit
Next Next commit
Implement redirect to previous page after stock item saving
Co-Authored-By: Elia Schito <[email protected]>
  • Loading branch information
rainerdema and elia committed Dec 11, 2023
commit d2e55eebaa8fb115fd6eccf971a43db5e83d0f27
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