-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5688 from nebulab/spaghetticode/convert-modals-to…
…-turbo-frames Convert existing Admin modals to Turbo frames
- Loading branch information
Showing
13 changed files
with
189 additions
and
165 deletions.
There are no files selected for viewing
110 changes: 56 additions & 54 deletions
110
admin/app/components/solidus_admin/orders/show/address/component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,69 @@ | ||
<div class="<%= stimulus_id %>" data-controller="<%= stimulus_id %>"> | ||
<%= 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| %> | ||
<div class="w-full flex flex-col mb-4"> | ||
<div class="flex justify-between items-center mb-4 relative"> | ||
<h2 class="text-sm font-semibold"> | ||
<%= t(".subtitle.#{@type}") %> | ||
</h2> | ||
<%= 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| %> | ||
<div class="w-full flex flex-col mb-4"> | ||
<div class="flex justify-between items-center mb-4 relative"> | ||
<h2 class="text-sm font-semibold"> | ||
<%= t(".subtitle.#{@type}") %> | ||
</h2> | ||
|
||
<% 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 %> | ||
</div> | ||
</div> | ||
|
||
<div class="w-full flex gap-4"> | ||
<%= turbo_frame_tag address_frame_id do %> | ||
<%= render component('ui/forms/address').new(address: @address, name: "order[#{@type}_address_attributes]") %> | ||
<% end %> | ||
</div> | ||
<div class="w-full flex gap-4"> | ||
<%= turbo_frame_tag address_frame_id do %> | ||
<%= render component('ui/forms/address').new(address: @address, name: "order[#{@type}_address_attributes]") %> | ||
<% end %> | ||
</div> | ||
|
||
<label class="flex gap-2 items-center"> | ||
<%= form.hidden_field use_attribute, value: '0', id: false %> | ||
<label class="flex gap-2 items-center"> | ||
<%= form.hidden_field use_attribute, value: '0', id: false %> | ||
|
||
<%= render component("ui/forms/checkbox").new( | ||
name: "#{form.object_name}[#{use_attribute}]", | ||
checked: @address == (@type == 'ship' ? @order.bill_address : @order.ship_address), | ||
value: '1' | ||
) %> | ||
<%= render component("ui/forms/checkbox").new( | ||
name: "#{form.object_name}[#{use_attribute}]", | ||
checked: @address == (@type == 'ship' ? @order.bill_address : @order.ship_address), | ||
value: '1' | ||
) %> | ||
|
||
<span class="font-normal text-xs"> | ||
<%= t(".use_this_address.#{@type}") %> | ||
</span> | ||
</label> | ||
</div> | ||
<% end %> | ||
<span class="font-normal text-xs"> | ||
<%= t(".use_this_address.#{@type}") %> | ||
</span> | ||
</label> | ||
</div> | ||
<% 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 %> | ||
<form method="dialog"> | ||
<%= render component("ui/button").new( | ||
scheme: :secondary, | ||
text: t(".cancel"), | ||
) %> | ||
</form> | ||
|
||
<%= 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) %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 18 additions & 13 deletions
31
admin/app/components/solidus_admin/orders/show/email/component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
<div class="<%= stimulus_id %>"> | ||
<%= 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) %> | ||
<label class="font-normal text-sm mt-4 block"> | ||
<%= t('.guest_checkout') %>: | ||
<output class="font-semibold text-sm"><%= @order.user ? t('.no') : t('.yes') %></output> | ||
<%= render component('ui/toggletip').new(text: t('.guest_checkout_tip'), class: "align-middle") %> | ||
</label> | ||
<% 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) %> | ||
<label class="font-normal text-sm mt-4 block"> | ||
<%= t('.guest_checkout') %>: | ||
<output class="font-semibold text-sm"><%= @order.user ? t('.no') : t('.yes') %></output> | ||
<%= render component('ui/toggletip').new(text: t('.guest_checkout_tip'), class: "align-middle") %> | ||
</label> | ||
<% 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 %> | ||
<form method="dialog"> | ||
<%= render component("ui/button").new(scheme: :secondary, text: t('.cancel')) %> | ||
</form> | ||
<%= render component("ui/button").new(form: form_id, type: :submit, text: t('.submit')) %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
|
||
<%= render component("orders/show").new(order: @order) %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.