From 71f4f0b42c93479a102caee66d7e32b70632ba90 Mon Sep 17 00:00:00 2001 From: andrea longhi Date: Tue, 5 Mar 2024 11:31:31 +0100 Subject: [PATCH 01/13] Manage order email dialog with turbo frame tag --- .../components/solidus_admin/orders/show/component.html.erb | 6 +++++- admin/app/components/solidus_admin/orders/show/component.rb | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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..274d35f6a02 100644 --- a/admin/app/components/solidus_admin/orders/show/component.html.erb +++ b/admin/app/components/solidus_admin/orders/show/component.html.erb @@ -16,7 +16,7 @@ <%= 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_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) %> <% panel.with_menu t(".edit_billing"), solidus_admin.edit_order_bill_address_path(@order) %> <% panel.with_menu t(".remove_customer"), solidus_admin.order_customer_path(@order), method: :delete, class: "text-red-500" if @order.user %> @@ -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..20b1df72c03 100644 --- a/admin/app/components/solidus_admin/orders/show/component.rb +++ b/admin/app/components/solidus_admin/orders/show/component.rb @@ -29,6 +29,10 @@ def format_address(address) ], " ") end + def turbo_frames + %w[edit_order_email_modal] + end + def customer_name(user) ( user.default_user_bill_address || From 8b0bfbe00c885d235a1abddfaa1caff5fe585253 Mon Sep 17 00:00:00 2001 From: andrea longhi Date: Tue, 5 Mar 2024 11:34:54 +0100 Subject: [PATCH 02/13] Close email edit modal on current page We can remove all this custom behavior since we want the modal to be rendered async on top of the current page. --- .../solidus_admin/orders/show/email/component.html.erb | 8 +++++--- .../solidus_admin/orders/show/email/component.rb | 4 ---- 2 files changed, 5 insertions(+), 7 deletions(-) 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..74861ee6d61 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,7 +1,7 @@
<%= 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/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) %>