diff --git a/admin/app/components/solidus_admin/orders/show/address/component.html.erb b/admin/app/components/solidus_admin/orders/show/address/component.html.erb
index 13059d4e6c0..b47c32a6548 100644
--- a/admin/app/components/solidus_admin/orders/show/address/component.html.erb
+++ b/admin/app/components/solidus_admin/orders/show/address/component.html.erb
@@ -1,67 +1,69 @@
- <%= render component("orders/show").new(order: @order) %>
-
- <%= render component("ui/modal").new(title: t(".title.#{@type}"), close_path: solidus_admin.order_path(@order)) do |modal| %>
- <%= form_for @order, url: solidus_admin.send("order_#{@type}_address_path", @order), html: { id: form_id } do |form| %>
-
-
-
- <%= t(".subtitle.#{@type}") %>
-
+ <%= turbo_frame_tag "edit_order_#{params[:type]}_address_modal" do %>
+ <%= render component("ui/modal").new(title: t(".title.#{@type}")) do |modal| %>
+ <%= form_for @order, url: solidus_admin.send("order_#{@type}_address_path", @order), html: { id: form_id } do |form| %>
+
+
+
+ <%= t(".subtitle.#{@type}") %>
+
- <% if @addresses.present? %>
- <%= render component('ui/dropdown').new(
- text: t(".select_address"),
- "data-#{stimulus_id}-target": "addresses",
- class: "max-h-[26rem] overflow-y-auto"
- ) do %>
- <% @addresses.each do |address| %>
- <%= tag.a(
- format_address(address),
- href: solidus_admin.send("order_#{@type}_address_path", @order, address_id: address.id),
- 'data-turbo-frame': address_frame_id,
- 'data-action': "#{component('ui/dropdown').stimulus_id}#close",
- ) %>
+ <% if @addresses.present? %>
+ <%= render component('ui/dropdown').new(
+ text: t(".select_address"),
+ "data-#{stimulus_id}-target": "addresses",
+ class: "max-h-[26rem] overflow-y-auto"
+ ) do %>
+ <% @addresses.each do |address| %>
+ <%= tag.a(
+ format_address(address),
+ href: solidus_admin.send("order_#{@type}_address_path", @order, address_id: address.id),
+ 'data-turbo-frame': address_frame_id,
+ 'data-action': "#{component('ui/dropdown').stimulus_id}#close",
+ ) %>
+ <% end %>
<% end %>
<% end %>
- <% end %>
-
+
-
- <%= turbo_frame_tag address_frame_id do %>
- <%= render component('ui/forms/address').new(address: @address, name: "order[#{@type}_address_attributes]") %>
- <% end %>
-
+
+ <%= turbo_frame_tag address_frame_id do %>
+ <%= render component('ui/forms/address').new(address: @address, name: "order[#{@type}_address_attributes]") %>
+ <% end %>
+
-
- <% end %>
+
+ <%= t(".use_this_address.#{@type}") %>
+
+
+
+ <% end %>
- <% modal.with_actions do %>
- <%= render component("ui/button").new(
- tag: :a,
- scheme: :secondary,
- text: t(".cancel"),
- href: solidus_admin.order_path(@order)
- ) %>
+ <% modal.with_actions do %>
+
- <%= render component("ui/button").new(
- tag: :button,
- text: t(".save"),
- form: form_id
- ) %>
+ <%= render component("ui/button").new(
+ tag: :button,
+ text: t(".save"),
+ form: form_id
+ ) %>
+ <% end %>
<% end %>
<% end %>
+
+ <%= render component("orders/show").new(order: @order) %>
diff --git a/admin/app/components/solidus_admin/orders/show/component.html.erb b/admin/app/components/solidus_admin/orders/show/component.html.erb
index f2e8cbbee8b..e2cdc78df48 100644
--- a/admin/app/components/solidus_admin/orders/show/component.html.erb
+++ b/admin/app/components/solidus_admin/orders/show/component.html.erb
@@ -16,9 +16,9 @@
<%= page_with_sidebar_aside do %>
<%= render component('ui/panel').new do |panel| %>
- <% panel.with_menu t(".edit_email"), solidus_admin.order_customer_path(@order) %>
- <% panel.with_menu t(".edit_shipping"), solidus_admin.edit_order_ship_address_path(@order) %>
- <% panel.with_menu t(".edit_billing"), solidus_admin.edit_order_bill_address_path(@order) %>
+ <% panel.with_menu t(".edit_email"), solidus_admin.order_customer_path(@order), data: { turbo_frame: :edit_order_email_modal } %>
+ <% panel.with_menu t(".edit_shipping"), solidus_admin.edit_order_ship_address_path(@order), data: { turbo_frame: :edit_order_ship_address_modal } %>
+ <% panel.with_menu t(".edit_billing"), solidus_admin.edit_order_bill_address_path(@order), data: { turbo_frame: :edit_order_bill_address_modal } %>
<% panel.with_menu t(".remove_customer"), solidus_admin.order_customer_path(@order), method: :delete, class: "text-red-500" if @order.user %>
<% panel.with_section(class: 'flex flex-col gap-6') do %>
@@ -73,4 +73,8 @@
<% end %>
<% end %>
+
+ <% turbo_frames.each do |frame| %>
+ <%= turbo_frame_tag frame %>
+ <% end %>
<% end %>
diff --git a/admin/app/components/solidus_admin/orders/show/component.rb b/admin/app/components/solidus_admin/orders/show/component.rb
index ba9cf656f0b..7279d93cc70 100644
--- a/admin/app/components/solidus_admin/orders/show/component.rb
+++ b/admin/app/components/solidus_admin/orders/show/component.rb
@@ -29,6 +29,14 @@ def format_address(address)
], " ")
end
+ def turbo_frames
+ %w[
+ edit_order_email_modal
+ edit_order_bill_address_modal
+ edit_order_ship_address_modal
+ ]
+ end
+
def customer_name(user)
(
user.default_user_bill_address ||
diff --git a/admin/app/components/solidus_admin/orders/show/email/component.html.erb b/admin/app/components/solidus_admin/orders/show/email/component.html.erb
index ca6023404e2..3e6c0e52e76 100644
--- a/admin/app/components/solidus_admin/orders/show/email/component.html.erb
+++ b/admin/app/components/solidus_admin/orders/show/email/component.html.erb
@@ -1,18 +1,23 @@
- <%= render component("orders/show").new(order: @order) %>
- <%= render component("ui/modal").new(title: t(".title"), close_path: close_path) do |modal| %>
- <%= form_for @order, url: close_path, html: { id: form_id} do |f| %>
- <%= render component("ui/forms/field").text_field(f, :email) %>
-
- <%= t('.guest_checkout') %>:
-
- <%= render component('ui/toggletip').new(text: t('.guest_checkout_tip'), class: "align-middle") %>
-
- <% end %>
+ <%= turbo_frame_tag "edit_order_email_modal" do %>
+ <%= render component("ui/modal").new(title: t(".title")) do |modal| %>
+ <%= form_for @order, url: solidus_admin.order_path(@order), html: { id: form_id } do |f| %>
+ <%= render component("ui/forms/field").text_field(f, :email) %>
+
+ <%= t('.guest_checkout') %>:
+
+ <%= render component('ui/toggletip').new(text: t('.guest_checkout_tip'), class: "align-middle") %>
+
+ <% end %>
- <% modal.with_actions do %>
- <%= render component("ui/button").new(tag: :a, scheme: :secondary, href: close_path, type: :submit, text: t('.cancel')) %>
- <%= render component("ui/button").new(form: form_id, type: :submit, text: t('.submit')) %>
+ <% modal.with_actions do %>
+
+ <%= render component("ui/button").new(form: form_id, type: :submit, text: t('.submit')) %>
+ <% end %>
<% end %>
<% end %>
+
+ <%= render component("orders/show").new(order: @order) %>
diff --git a/admin/app/components/solidus_admin/orders/show/email/component.rb b/admin/app/components/solidus_admin/orders/show/email/component.rb
index 02dc30f313c..556a332fcfc 100644
--- a/admin/app/components/solidus_admin/orders/show/email/component.rb
+++ b/admin/app/components/solidus_admin/orders/show/email/component.rb
@@ -8,8 +8,4 @@ def initialize(order:)
def form_id
dom_id(@order, "#{stimulus_id}_email_form")
end
-
- def close_path
- @close_path ||= solidus_admin.order_path(@order)
- end
end
diff --git a/admin/app/components/solidus_admin/stock_items/edit/component.html.erb b/admin/app/components/solidus_admin/stock_items/edit/component.html.erb
index 6e6d9f55703..64a8d7cc594 100644
--- a/admin/app/components/solidus_admin/stock_items/edit/component.html.erb
+++ b/admin/app/components/solidus_admin/stock_items/edit/component.html.erb
@@ -3,85 +3,79 @@
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| %>
- <%= form_for @stock_item, url: solidus_admin.stock_item_path(@stock_item), html: { id: form_id } do |f| %>
-
-
- <%= link_to spree.edit_admin_product_variant_path(
- @stock_item.variant.product,
- @stock_item.variant,
- ), class: 'hover:bg-gray-25 rounded p-1 w-1/2 border border-gray-100' do %>
- <%= render component("ui/resource_item").new(
- thumbnail:
- (
- @stock_item.variant.images.first ||
- @stock_item.variant.product.gallery.images.first
- )&.url(:small),
- title: @stock_item.variant.name,
- subtitle:
- "#{@stock_item.variant.sku}#{@stock_item.variant.options_text.presence&.prepend(" - ")}",
- ) %>
- <% end %>
- <%= link_to spree.edit_admin_stock_location_path(@stock_item.stock_location), class: 'hover:bg-gray-25 rounded p-1 w-1/2 border border-gray-100' do %>
- <%= render component("ui/resource_item").new(
- title: @stock_item.stock_location.name,
- subtitle: "#{Spree::StockLocation.model_name.human} #{@stock_item.stock_location.code}",
+ <%= turbo_frame_tag :edit_stock_item_modal do %>
+ <%= 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| %>
+
+
+ <%= link_to spree.edit_admin_product_variant_path(
+ @stock_item.variant.product,
+ @stock_item.variant,
+ ), class: 'hover:bg-gray-25 rounded p-1 w-1/2 border border-gray-100' do %>
+ <%= render component("ui/resource_item").new(
+ thumbnail:
+ (
+ @stock_item.variant.images.first ||
+ @stock_item.variant.product.gallery.images.first
+ )&.url(:small),
+ title: @stock_item.variant.name,
+ subtitle:
+ "#{@stock_item.variant.sku}#{@stock_item.variant.options_text.presence&.prepend(" - ")}",
+ ) %>
+ <% end %>
+ <%= link_to spree.edit_admin_stock_location_path(@stock_item.stock_location), class: 'hover:bg-gray-25 rounded p-1 w-1/2 border border-gray-100' do %>
+ <%= render component("ui/resource_item").new(
+ title: @stock_item.stock_location.name,
+ subtitle: "#{Spree::StockLocation.model_name.human} #{@stock_item.stock_location.code}",
+ ) %>
+ <% end %>
+
+
+ <%= render component("ui/forms/field").text_field(
+ f,
+ :count_on_hand,
+ disabled: true,
+ value: @stock_item.count_on_hand_was || @stock_item.count_on_hand,
+ "data-#{stimulus_id}-target": 'countOnHand',
+ ) %>
+ <%= render component("ui/forms/field").new(
+ label: t(".quantity_adjustment"),
+ hint: t(".quantity_adjustment_hint_html"),
+ ) do %>
+ <%= render component("ui/forms/input").new(
+ value: params[:quantity_adjustment] || 0,
+ name: :quantity_adjustment,
+ type: :number,
+ step: 1,
+ "data-#{stimulus_id}-target": 'quantityAdjustment',
) %>
<% end %>
+
+ <%= render component("ui/forms/switch_field").new(
+ name: "#{f.object_name}[backorderable]",
+ label: Spree::StockItem.human_attribute_name(:backorderable),
+ error: f.object.errors[:backorderable],
+ hint: t(".backorderable_hint_html"),
+ checked: f.object.backorderable?,
+ include_hidden: true,
+ ) %>
+ <% end %>
- <%= render component("ui/forms/field").text_field(
- f,
- :count_on_hand,
- disabled: true,
- value: @stock_item.count_on_hand_was || @stock_item.count_on_hand,
- "data-#{stimulus_id}-target": 'countOnHand',
- ) %>
- <%= render component("ui/forms/field").new(
- label: t(".quantity_adjustment"),
- hint: t(".quantity_adjustment_hint_html"),
- ) do %>
- <%= render component("ui/forms/input").new(
- value: params[:quantity_adjustment] || 0,
- name: :quantity_adjustment,
- type: :number,
- step: 1,
- "data-#{stimulus_id}-target": 'quantityAdjustment',
+ <% modal.with_actions do %>
+
- <%= render component("ui/forms/switch_field").new(
- name: "#{f.object_name}[backorderable]",
- label: Spree::StockItem.human_attribute_name(:backorderable),
- error: f.object.errors[:backorderable],
- hint: t(".backorderable_hint_html"),
- checked: f.object.backorderable?,
- include_hidden: true,
+ <%= render component("ui/button").new(
+ tag: :button,
+ text: t(".submit"),
+ form: form_id,
) %>
-
- <% 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 %>
-
- <% 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]),
- ) %>
-
- <%= render component("ui/button").new(
- tag: :button,
- text: t(".submit"),
- form: form_id,
- ) %>
+ <% end %>
<% end %>
<% end %>
diff --git a/admin/app/components/solidus_admin/stock_items/edit/component.rb b/admin/app/components/solidus_admin/stock_items/edit/component.rb
index 95a63cf2628..3573444d413 100644
--- a/admin/app/components/solidus_admin/stock_items/edit/component.rb
+++ b/admin/app/components/solidus_admin/stock_items/edit/component.rb
@@ -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
diff --git a/admin/app/components/solidus_admin/stock_items/index/component.rb b/admin/app/components/solidus_admin/stock_items/index/component.rb
index 2ad4e782dd7..b9c306f82dc 100644
--- a/admin/app/components/solidus_admin/stock_items/index/component.rb
+++ b/admin/app/components/solidus_admin/stock_items/index/component.rb
@@ -14,7 +14,7 @@ def search_url
end
def row_url(stock_item)
- solidus_admin.edit_stock_item_path(stock_item, page: params[:page], q: permitted_query_params)
+ solidus_admin.edit_stock_item_path(stock_item, _turbo_frame: :edit_stock_item_modal)
end
def scopes
@@ -167,8 +167,7 @@ def count_on_hand_column
}
end
- def permitted_query_params
- return params[:q].permit! if params[:q].respond_to?(:permit)
- {}
+ def turbo_frames
+ %w[edit_stock_item_modal]
end
end
diff --git a/admin/app/components/solidus_admin/ui/table/component.js b/admin/app/components/solidus_admin/ui/table/component.js
index 47065712993..faba92015de 100644
--- a/admin/app/components/solidus_admin/ui/table/component.js
+++ b/admin/app/components/solidus_admin/ui/table/component.js
@@ -104,7 +104,15 @@ export default class extends Controller {
if (this.modeValue === "batch") {
this.toggleCheckbox(event.currentTarget)
} else {
- window.Turbo.visit(event.params.url)
+ const url = new URL(event.params.url, "http://dummy.com")
+ const params = new URLSearchParams(url.search)
+ const frameId = params.get('_turbo_frame')
+ const frame = frameId ? { frame: frameId } : {}
+ // remove the custom _turbo_frame param from url search:
+ params.delete('_turbo_frame')
+ url.search = params.toString()
+
+ window.Turbo.visit(url.pathname + url.search, frame)
}
}
diff --git a/admin/app/controllers/solidus_admin/addresses_controller.rb b/admin/app/controllers/solidus_admin/addresses_controller.rb
index 817d2c1f7be..88749621ae9 100644
--- a/admin/app/controllers/solidus_admin/addresses_controller.rb
+++ b/admin/app/controllers/solidus_admin/addresses_controller.rb
@@ -26,7 +26,12 @@ def edit
def update
if @order.contents.update_cart(order_params)
- redirect_to order_path(@order), status: :see_other, notice: t('.success')
+ respond_to do |format|
+ flash[:notice] = t('.success')
+
+ format.html { redirect_to order_path(@order), status: :see_other }
+ format.turbo_stream { render turbo_stream: '
' }
+ end
else
flash.now[:error] = @order.errors[:base].join(", ") if @order.errors[:base].any?
diff --git a/admin/app/controllers/solidus_admin/customers_controller.rb b/admin/app/controllers/solidus_admin/customers_controller.rb
index 07e34cd95b1..af79d4d483a 100644
--- a/admin/app/controllers/solidus_admin/customers_controller.rb
+++ b/admin/app/controllers/solidus_admin/customers_controller.rb
@@ -4,7 +4,11 @@ class SolidusAdmin::CustomersController < SolidusAdmin::BaseController
before_action :load_order, only: [:show, :destroy]
def show
- render component('orders/show/email').new(order: @order)
+ respond_to do |format|
+ format.html do
+ render component('orders/show/email').new(order: @order)
+ end
+ end
end
def destroy
diff --git a/admin/app/controllers/solidus_admin/orders_controller.rb b/admin/app/controllers/solidus_admin/orders_controller.rb
index 4fd9313bac9..0b2df6cb324 100644
--- a/admin/app/controllers/solidus_admin/orders_controller.rb
+++ b/admin/app/controllers/solidus_admin/orders_controller.rb
@@ -54,7 +54,11 @@ def update
flash[:error] = t('.error')
end
- redirect_to spree.edit_admin_order_path(@order)
+ respond_to do |format|
+ format.html { redirect_to spree.edit_admin_order_path(@order) }
+
+ format.turbo_stream { render turbo_stream: '
' }
+ end
end
def edit
diff --git a/admin/app/controllers/solidus_admin/stock_items_controller.rb b/admin/app/controllers/solidus_admin/stock_items_controller.rb
index 5dbb46b0534..1333dbe672c 100644
--- a/admin/app/controllers/solidus_admin/stock_items_controller.rb
+++ b/admin/app/controllers/solidus_admin/stock_items_controller.rb
@@ -26,14 +26,14 @@ 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
+ respond_to do |format|
+ format.html { redirect_to solidus_admin.stock_items_path, status: :see_other }
+ format.turbo_stream { render turbo_stream: '
' }
+ end
else
respond_to do |format|
format.html { render component('stock_items/edit').new(stock_item: @stock_item, page: @page), status: :unprocessable_entity }
@@ -61,7 +61,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