diff --git a/admin/app/assets/stylesheets/solidus_admin/application.tailwind.css.erb b/admin/app/assets/stylesheets/solidus_admin/application.tailwind.css.erb index b65e30dfae9..f876640838e 100644 --- a/admin/app/assets/stylesheets/solidus_admin/application.tailwind.css.erb +++ b/admin/app/assets/stylesheets/solidus_admin/application.tailwind.css.erb @@ -3,6 +3,17 @@ @tailwind utilities; @layer base { + summary { + &::marker, + &::-webkit-details-marker { + @apply hidden; + } + + list-style: none; + } +} + +@layer components { .body-tiny { @apply font-sans font-normal text-xs; } diff --git a/admin/app/components/solidus_admin/layout/page_helpers.rb b/admin/app/components/solidus_admin/layout/page_helpers.rb index 5226902d967..7bf7bfb409f 100644 --- a/admin/app/components/solidus_admin/layout/page_helpers.rb +++ b/admin/app/components/solidus_admin/layout/page_helpers.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true module SolidusAdmin::Layout::PageHelpers - def page(&block) - tag.div(capture(&block), class: "px-4 relative", "data-controller": stimulus_id) + def page(**attrs, &block) + tag.div(capture(&block), class: "px-4 relative", "data-controller": stimulus_id, **attrs) end def page_header_actions(&block) 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 fc5ecff6a5e..83578b71a2f 100644 --- a/admin/app/components/solidus_admin/orders/show/component.html.erb +++ b/admin/app/components/solidus_admin/orders/show/component.html.erb @@ -1,4 +1,4 @@ -<%= page do %> +<%= page("data-action": "turbo:before-cache@window->#{stimulus_id}#closeMenus") do %> <%= page_header do %> <%= page_header_back(solidus_admin.orders_path) %> <%= page_header_title(t('.title', number: @order.number)) %> @@ -8,5 +8,68 @@ <% end %> <% end %> - <%= render component('orders/cart').new(order: @order) %> + <%= page_with_sidebar do %> + <%= page_with_sidebar_main do %> + <%= render component("orders/cart").new(order: @order) %> + <% end %> + + <%= page_with_sidebar_aside do %> + <%= render component('ui/panel').new(title: panel_title_with_more_links(t(".customer"), [ + link_to(t(".edit_email"), "#", class: "p-2 hover:bg-gray-25 rounded-sm text-black"), + link_to(t(".edit_shipping"), "#", class: "p-2 hover:bg-gray-25 rounded-sm text-black"), + link_to(t(".edit_billing"), "#", class: "p-2 hover:bg-gray-25 rounded-sm text-black"), + link_to(t(".remove_customer"), "#", 'data-turbo-method': :delete, class: "p-2 hover:bg-gray-25 rounded-sm text-red-500"), + ])) do %> +
+ <%# CUSTOMER %> + <% if @order.user %> +
+
<%= customer_name(@order.user) || tag.span(t('.no_name'), class: "text-gray-500") %>
+ +
<%= t(".orders_count", count: @order.user.orders.count) %>
+
+ <% end %> + + <%# EMAIL %> + <% if @order.email %> +
+ <%= t('.order_email') %> +
<%= @order.email %>
+
+ <% end %> + + <%# SHIPPING %> +
+ <%= @order.class.human_attribute_name(:ship_address) %> +
+ <% if @order.ship_address %> + <%= format_address @order.ship_address %> + <% else %> + <%= t('.no_shipping_address') %> + <% end %> +
+
+ + <%# BILLING %> +
+ <%= @order.class.human_attribute_name(:bill_address) %> +
+ <% if @order.bill_address %> + <% if @order.bill_address == @order.ship_address %> + <%= t('.same_as_shipping') %> + <% else %> + <%= format_address @order.bill_address %> + <% end %> + <% else %> + <%= t('.no_billing_address') %> + <% end %> +
+
+ +
+ + <% end %> + + <% end %> + <% end %> <% end %> diff --git a/admin/app/components/solidus_admin/orders/show/component.js b/admin/app/components/solidus_admin/orders/show/component.js index 6839d36996e..6c6056ac26d 100644 --- a/admin/app/components/solidus_admin/orders/show/component.js +++ b/admin/app/components/solidus_admin/orders/show/component.js @@ -1,5 +1,7 @@ import { Controller } from '@hotwired/stimulus' export default class extends Controller { - + closeMenus() { + this.event.querySelectorAll('details').forEach(details => details.removeAttribute('open')); + } } diff --git a/admin/app/components/solidus_admin/orders/show/component.rb b/admin/app/components/solidus_admin/orders/show/component.rb index b0187d09da8..02718d07761 100644 --- a/admin/app/components/solidus_admin/orders/show/component.rb +++ b/admin/app/components/solidus_admin/orders/show/component.rb @@ -10,4 +10,52 @@ def initialize(order:) def form_id @form_id ||= "#{stimulus_id}--form-#{@order.id}" end + + def format_address(address) + return unless address + safe_join([ + address.name, + tag.br, + address.address1, + tag.br, + address.address2, + address.city, + address.zipcode, + address.state.name, + tag.br, + address.country.name, + tag.br, + address.phone, + ], " ") + end + + def panel_title_with_more_links(title, links) + tag.details( + tag.summary( + tag.div( + safe_join([ + title, + component("ui/button").new( + icon: "more-line", + scheme: :ghost, + tag: :div, + alt: t("spree.edit"), + class: "cursor-pointer" + ).render_in(self), + ]), + class: 'flex items-center justify-between text-black', + ) + ) + tag.div(safe_join(links, " "), class: "body-small absolute border border-gray-100 mt-0.5 right-0 flex min-w-[10rem] flex-col p-2 rounded-sm shadow-lg bg-white z-10"), + class: 'relative', + ) + end + + def customer_name(user) + ( + user.default_user_bill_address || + user.default_user_ship_address || + user.user_addresses.where(default: true).first || + user.user_addresses.first + )&.address&.name + end end diff --git a/admin/app/components/solidus_admin/orders/show/component.yml b/admin/app/components/solidus_admin/orders/show/component.yml index 785996266e6..55755957b02 100644 --- a/admin/app/components/solidus_admin/orders/show/component.yml +++ b/admin/app/components/solidus_admin/orders/show/component.yml @@ -4,3 +4,18 @@ en: save: Save discard: Discard title: "Order %{number}" + customer: Customer + no_name: No name available + order_email: Order contact email + no_billing_address: No billing address + no_shipping_address: No shipping address + same_as_shipping: Same as shipping address + + edit_email: "Edit order email" + edit_shipping: "Edit shipping address" + edit_billing: "Edit billing address" + remove_customer: "Remove customer" + + orders_count: + one: "%{count} order" + other: "%{count} orders" diff --git a/admin/app/components/solidus_admin/sidebar/account_nav/component.html.erb b/admin/app/components/solidus_admin/sidebar/account_nav/component.html.erb index fd4a4d3f359..c5aa95a8da1 100644 --- a/admin/app/components/solidus_admin/sidebar/account_nav/component.html.erb +++ b/admin/app/components/solidus_admin/sidebar/account_nav/component.html.erb @@ -6,8 +6,6 @@ body-small-bold text-gray-500 hover:bg-gray-25 [[open]_>_&]:bg-gray-25 cursor-pointer - [&::marker]:hidden - [&::-webkit-details-marker]:hidden "> <%= icon_tag("user-smile-fill", class: "inline-block align-text-bottom shrink-0 w-6 h-6 rounded-[4.81rem] body-small fill-yellow bg-black") %> diff --git a/admin/app/components/solidus_admin/ui/modal/component.html.erb b/admin/app/components/solidus_admin/ui/modal/component.html.erb index 5ac096d592a..7c8f6f7dd38 100644 --- a/admin/app/components/solidus_admin/ui/modal/component.html.erb +++ b/admin/app/components/solidus_admin/ui/modal/component.html.erb @@ -6,7 +6,7 @@ **@attributes ) %> > - +
diff --git a/admin/app/components/solidus_admin/ui/table/ransack_filter/component.html.erb b/admin/app/components/solidus_admin/ui/table/ransack_filter/component.html.erb index 1a6492f0e30..9838a4d1f47 100644 --- a/admin/app/components/solidus_admin/ui/table/ransack_filter/component.html.erb +++ b/admin/app/components/solidus_admin/ui/table/ransack_filter/component.html.erb @@ -12,8 +12,6 @@ text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 focus:ring-indigo-500 - [&::marker]:hidden - [&::-webkit-details-marker]:hidden cursor-default " data-<%= stimulus_id %>-target="summary"> <%= @presentation %> diff --git a/admin/app/controllers/solidus_admin/line_items_controller.rb b/admin/app/controllers/solidus_admin/line_items_controller.rb index e400bae7546..b4ea905fb58 100644 --- a/admin/app/controllers/solidus_admin/line_items_controller.rb +++ b/admin/app/controllers/solidus_admin/line_items_controller.rb @@ -8,7 +8,7 @@ def destroy @line_item.destroy! - redirect_to cart_order_path(@order), status: :see_other, notice: t('.success') + redirect_to order_path(@order), status: :see_other, notice: t('.success') end def create @@ -17,7 +17,7 @@ def create @variant = Spree::Variant.find(variant_id) @line_item = @order.contents.add(@variant) - redirect_to cart_order_path(@order), status: :see_other, notice: t('.success') + redirect_to order_path(@order), status: :see_other, notice: t('.success') end def update @@ -28,7 +28,7 @@ def update @line_item = @order.contents.add(@line_item.variant, desired_quantity - @line_item.quantity) - redirect_to cart_order_path(@order), status: :see_other, notice: t('.success') + redirect_to order_path(@order), status: :see_other, notice: t('.success') end private diff --git a/admin/app/controllers/solidus_admin/orders_controller.rb b/admin/app/controllers/solidus_admin/orders_controller.rb index 4ebb1af3310..c4150222572 100644 --- a/admin/app/controllers/solidus_admin/orders_controller.rb +++ b/admin/app/controllers/solidus_admin/orders_controller.rb @@ -26,6 +26,10 @@ def show end end + def edit + redirect_to action: :show + end + def variants_for load_order diff --git a/admin/config/routes.rb b/admin/config/routes.rb index f8d2c3b78f7..98db04921c4 100644 --- a/admin/config/routes.rb +++ b/admin/config/routes.rb @@ -18,11 +18,10 @@ get 'states', to: 'countries#states' end - resources :orders, only: [:index] do + resources :orders, only: [:index, :show, :edit] do resources :line_items, only: [:destroy, :create, :update] member do - get :cart, to: "orders#show" get :variants_for end end diff --git a/admin/spec/features/order_spec.rb b/admin/spec/features/order_spec.rb index d2a41852e29..827f29a9ac9 100644 --- a/admin/spec/features/order_spec.rb +++ b/admin/spec/features/order_spec.rb @@ -11,7 +11,8 @@ create(:product, name: "Just another product", slug: 'just-another-prod', price: 29.99) create(:order, number: "R123456789", total: 19.99, state: "cart") - visit "/admin/orders/R123456789/cart" + visit "/admin/orders/R123456789/edit" + expect(page).to have_current_path("/admin/orders/R123456789") expect(page).to have_content("Order R123456789") diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml index 7237e213402..9e97ed2c65e 100644 --- a/core/config/locales/en.yml +++ b/core/config/locales/en.yml @@ -104,6 +104,7 @@ en: additional_tax_total: Tax approved_at: Approved at approver_id: Approver + bill_address: Billing Address canceled_at: Canceled at canceler_id: Canceler checkout_complete: Checkout Complete @@ -117,6 +118,7 @@ en: item_total: Item Total number: Number payment_state: Payment State + ship_address: Shipping Address shipment_state: Shipment State shipment_total: Ship Total special_instructions: Special Instructions