Skip to content

Commit

Permalink
Rework stock item form modal
Browse files Browse the repository at this point in the history
Since the modal open and closes on the current page, close links are
not needed anymore. Same goes for the explicit q and page params.

The `Cancel` button is simplified to use dialog standards.
  • Loading branch information
spaghetticode committed Mar 11, 2024
1 parent 8f9f333 commit 2257d9b
Showing 1 changed file with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
data-<%= stimulus_id %>-initial-count-on-hand-value="<%= @stock_item.count_on_hand_was || @stock_item.count_on_hand %>"
data-action="input-><%= stimulus_id %>#updateCountOnHand"
>
<%= render component("ui/modal").new(title: t(".title"), close_path: solidus_admin.stock_items_path(page: params[:page], q: permitted_query_params)) do |modal| %>
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
<%= form_for @stock_item, url: solidus_admin.stock_item_path(@stock_item), html: { id: form_id } do |f| %>
<div class="flex flex-col gap-6 pb-4">
<div class="flex gap-4">
Expand Down Expand Up @@ -58,24 +58,16 @@
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 %>
<% modal.with_actions do %>
<%= render component("ui/button").new(
tag: :a,
scheme: :secondary,
text: t(".cancel"),
href: solidus_admin.stock_items_path(page: params[:page], q: params[:q]),
) %>
<form method="dialog">
<%= render component("ui/button").new(
scheme: :secondary,
text: t(".cancel"),
) %>
</form>

<%= render component("ui/button").new(
tag: :button,
Expand Down

0 comments on commit 2257d9b

Please sign in to comment.