From 478e633a55979b420080d8809d6c6f54dd7183c0 Mon Sep 17 00:00:00 2001 From: andrea longhi Date: Tue, 5 Mar 2024 12:28:13 +0100 Subject: [PATCH] Revisit address modal to work with turbo frames Just like we did a few comments before with the order email modal. --- .../orders/show/address/component.html.erb | 110 +++++++++--------- 1 file changed, 56 insertions(+), 54 deletions(-) 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( + scheme: :secondary, + text: t(".cancel"), + ) %> +
- <%= 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) %>