Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from solidusio:main #379

Merged
merged 24 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8dcd0ba
Implement `use_shipping` to sync addresses in Order
rainerdema Nov 3, 2023
619250b
Implement routes for address creation and update
rainerdema Nov 3, 2023
704763a
Incorporate address component in new `orders/show/address` component
rainerdema Nov 7, 2023
c8bc9ba
Adjust field styles in `ui/forms/address` component
rainerdema Nov 7, 2023
b58646b
Implement server-side state preloading for address form
rainerdema Nov 7, 2023
2dd113b
Disable state field for countries without states
rainerdema Nov 7, 2023
ae29975
Remove max height for modal content to accommodate larger forms
rainerdema Nov 8, 2023
3a5daf8
Fix turbo cache event handling for details dropdown
rainerdema Nov 8, 2023
378ed49
Merge pull request #5461 from nebulab/rainerd/admin/order/address-form
rainerdema Nov 8, 2023
f49525b
Allow detaching a customer from an order
elia Nov 8, 2023
dcfde2a
Don't show billing and shipping sections if the addresses are not set
elia Nov 8, 2023
ac8d8e7
Split the panel from the search component
elia Nov 8, 2023
3e5cf05
Use a 22px high icon for the customer sidebar menu
elia Nov 9, 2023
e65924b
Add a missing translation for /admin/orders#update
elia Nov 9, 2023
4b69511
Fix search result spacing
elia Nov 9, 2023
48db753
Fix information about being a guest order
elia Nov 10, 2023
5bbcc05
Don't let modal go over the screen height
elia Nov 10, 2023
9762fde
Move the panel menu inside the `ui/panel` component
elia Nov 10, 2023
fa98eee
Only show the number of complete order in the customer widget
elia Nov 10, 2023
1fb1f98
Reorganize the orders/show customer sidebar
elia Nov 10, 2023
de59f4a
Add a customer picker for the order page
elia Nov 10, 2023
e636fe0
Move layout related components under `layout/`
elia Nov 10, 2023
6bbb872
Merge pull request #5462 from solidusio/elia/admin/customer-picker
elia Nov 13, 2023
9ed9a07
Merge pull request #5510 from solidusio/elia/admin/layout-namespace
elia Nov 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions admin/app/components/solidus_admin/feedback/component.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

class SolidusAdmin::Layout::Feedback::Component < SolidusAdmin::BaseComponent
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

# Account navigation
class SolidusAdmin::Sidebar::AccountNav::Component < SolidusAdmin::BaseComponent
class SolidusAdmin::Layout::Navigation::Account::Component < SolidusAdmin::BaseComponent
# @param user_label [String]
# @param account_path [String]
# @param logout_path [String]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<% end %>

<ul>
<%= render component("sidebar/item").with_collection(items, fullpath: request.fullpath) %>
<%= render component("layout/navigation/item").with_collection(items, fullpath: request.fullpath) %>
</ul>

<div class="mt-auto">
Expand All @@ -29,7 +29,7 @@
</div>
</label>
</div>
<%= render component("sidebar/account_nav").new(
<%= render component("layout/navigation/account").new(
user_label: helpers.current_solidus_admin_user.email,
account_path: solidus_admin.account_path,
logout_path: helpers.solidus_admin_logout_path,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

# Renders the sidebar
class SolidusAdmin::Sidebar::Component < SolidusAdmin::BaseComponent
class SolidusAdmin::Layout::Navigation::Component < SolidusAdmin::BaseComponent
def initialize(
store:,
logo_path: SolidusAdmin::Config.logo_path,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

# Menu item within a {Sidebar}
class SolidusAdmin::Sidebar::Item::Component < SolidusAdmin::BaseComponent
class SolidusAdmin::Layout::Navigation::Item::Component < SolidusAdmin::BaseComponent
with_collection_parameter :item

# @param item [SolidusAdmin::MainNavItem
Expand Down
2 changes: 1 addition & 1 deletion admin/app/components/solidus_admin/layout/page_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def page(**attrs, &block)

def page_header_actions(&block)
tag.div(safe_join([
render(component("feedback").new),
render(component("layout/feedback").new),
capture(&block),
]), class: "flex gap-2 items-center")
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

# Skip to content link
class SolidusAdmin::SkipLink::Component < SolidusAdmin::BaseComponent
class SolidusAdmin::Layout::SkipLink::Component < SolidusAdmin::BaseComponent
# @param href [String] the href attribute for the skip link
def initialize(href:)
@href = href
Expand Down
145 changes: 76 additions & 69 deletions admin/app/components/solidus_admin/orders/cart/component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,77 +3,84 @@
data-controller="<%= stimulus_id %>"
data-<%= stimulus_id %>-products-url-value="<%= solidus_admin.variants_for_order_path(@order) %>"
data-action="
<%= component('ui/search_panel').stimulus_id %>:search-><%= stimulus_id %>#search
<%= component('ui/search_panel').stimulus_id %>:submit-><%= stimulus_id %>#selectResult
<%= component('ui/forms/search').stimulus_id %>:search-><%= stimulus_id %>#search
<%= component('ui/forms/search').stimulus_id %>:submit-><%= stimulus_id %>#selectResult
"
>
<%= render component('ui/search_panel').new(
title: t('.title'),
search_placeholder: t('.search_placeholder'),
id: :order_cart,
) do |panel| %>
<table class="table-auto w-full" <%= :hidden if @order.line_items.empty? %>>
<thead>
<tr class="border-gray-100 border-t">
<th class="text-left body-small-bold text-gray-800 bg-gray-15 px-6 py-3 leading-none">Product</th>
<th class="text-left body-small-bold text-gray-800 bg-gray-15 px-6 py-3 leading-none w-16">Quantity</th>
<th class="text-left body-small-bold text-gray-800 bg-gray-15 px-6 py-3 leading-none w-16">Price</th>
<th class="text-left body-small-bold text-gray-800 bg-gray-15 px-6 py-3 leading-none w-16"><span class="sr-only">Actions</span></th>
</tr>
</thead>
<tbody>
<% @order.line_items.each do |line_item| %>
<tr class="border-gray-100 border-t">
<td class="px-6 py-4">
<div class="flex gap-2 grow">
<% variant = line_item.variant %>
<%= render component("ui/thumbnail").new(
src: (variant.images.first || variant.product.gallery.images.first)&.url(:small),
alt: variant.name
) %>
<div class="flex-col">
<div class="leading-5 text-black body-small-bold"><%= variant.name %></div>
<div class="leading-5 text-gray-500 body-small">
SKU: <%= variant.sku %>
<%= variant.options_text.presence&.prepend("- ") %>
<%= render component('ui/panel').new(title: t('.title')) do |panel| %>
<% panel.with_section do %>
<%= render component('ui/forms/search').new(
placeholder: t('.search_placeholder'),
id: :order_cart,
) %>
<% end %>

<% panel.with_section(wide: true, high: true) do %>
<div class="rounded-b-lg overflow-hidden">
<table class="table-auto w-full" <%= :hidden if @order.line_items.empty? %>>
<thead>
<tr>
<th class="text-left body-small-bold text-gray-800 bg-gray-15 px-6 py-3 leading-none">Product</th>
<th class="text-left body-small-bold text-gray-800 bg-gray-15 px-6 py-3 leading-none w-16">Quantity</th>
<th class="text-left body-small-bold text-gray-800 bg-gray-15 px-6 py-3 leading-none w-16">Price</th>
<th class="text-left body-small-bold text-gray-800 bg-gray-15 px-6 py-3 leading-none w-16"><span class="sr-only">Actions</span></th>
</tr>
</thead>
<tbody>
<% @order.line_items.each do |line_item| %>
<tr class="border-gray-100 border-t">
<td class="px-6 py-4">
<div class="flex gap-2 grow">
<% variant = line_item.variant %>
<%= render component("ui/thumbnail").new(
src: (variant.images.first || variant.product.gallery.images.first)&.url(:small),
alt: variant.name
) %>
<div class="flex-col">
<div class="leading-5 text-black body-small-bold"><%= variant.name %></div>
<div class="leading-5 text-gray-500 body-small">
SKU: <%= variant.sku %>
<%= variant.options_text.presence&.prepend("- ") %>
</div>
</div>
</div>
</div>
</div>
</td>
<td class="px-6 py-4">
<%= form_for(line_item, url: solidus_admin.order_line_item_path(@order, line_item), html: {
"data-controller": "readonly-when-submitting"
}) do |f| %>
<%= render component("ui/forms/input").new(
name: "#{f.object_name}[quantity]",
type: :number,
value: line_item.quantity,
"aria-label": "Quantity",
min: 0,
class: "!w-16 inline-block",
"data-action": "input->#{stimulus_id}#updateLineItem",
) %>
<% render component("ui/button").new(type: :submit, text: "Update", class: "inline-block") %>
<% end %>
</td>
<td class="px-6 py-4">
<span class="text-gray-500 body-small"><%= line_item.single_money.to_html %></span>
</td>
<td class="px-6 py-4 text-right">
<%= form_for(line_item, url: solidus_admin.order_line_item_path(@order, line_item), method: :delete) do |f| %>
<%= render component('ui/button').new(
scheme: :ghost,
size: :s,
title: t("spree.delete"),
icon: 'close-line',
"data-controller": "confirm",
"data-confirm-text-value": t("spree.are_you_sure"),
) %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</td>
<td class="px-6 py-4">
<%= form_for(line_item, url: solidus_admin.order_line_item_path(@order, line_item), html: {
"data-controller": "readonly-when-submitting"
}) do |f| %>
<%= render component("ui/forms/input").new(
name: "#{f.object_name}[quantity]",
type: :number,
value: line_item.quantity,
"aria-label": "Quantity",
min: 0,
class: "!w-16 inline-block",
"data-action": "input->#{stimulus_id}#updateLineItem",
) %>
<% render component("ui/button").new(type: :submit, text: "Update", class: "inline-block") %>
<% end %>
</td>
<td class="px-6 py-4">
<span class="text-gray-500 body-small"><%= line_item.single_money.to_html %></span>
</td>
<td class="px-6 py-4 text-right">
<%= form_for(line_item, url: solidus_admin.order_line_item_path(@order, line_item), method: :delete) do |f| %>
<%= render component('ui/button').new(
scheme: :ghost,
size: :s,
title: t("spree.delete"),
icon: 'close-line',
"data-controller": "confirm",
"data-confirm-text-value": t("spree.are_you_sure"),
) %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
<% end %>
</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= render component('ui/search_panel/result').new do %>
<%= render component('ui/forms/search/result').new do %>
<%= form_for(@order.line_items.build(variant: @variant), url: solidus_admin.order_line_items_path(@order), method: :post, html: {
"data-controller": "readonly-when-submitting",
class: "flex items-center",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<div class="<%= 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">
<h2 class="text-sm mb-4 font-semibold"><%= t(".subtitle.#{@type}") %></h2>
<div class="w-full flex gap-4">
<%= form.fields_for :"#{@type}_address" do |address_form| %>
<%= render component('ui/forms/address').new(form: address_form, disabled: false) %>
<% end %>
</div>

<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: form.object.send("#{@type}_address").new_record? || form.object.bill_address == form.object.ship_address,
value: '1'
) %>

<span class="body-text-sm">
<%= 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)
) %>

<%= render component("ui/button").new(
tag: :button,
text: t(".save"),
form: form_id
) %>
<% end %>
<% end %>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

class SolidusAdmin::Orders::Show::Address::Component < SolidusAdmin::BaseComponent
include SolidusAdmin::Layout::PageHelpers

VALID_TYPES = ['ship', 'bill'].freeze

def initialize(order:, type: 'ship')
@order = order
@type = validate_address_type(type)
end

def form_id
@form_id ||= "#{stimulus_id}--form-#{@type}-#{@order.id}"
end

def use_attribute
case @type
when 'ship'
'use_shipping'
when 'bill'
'use_billing'
end
end

def validate_address_type(type)
VALID_TYPES.include?(type) ? type : raise(ArgumentError, "Invalid address type: #{type}")
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Add your component translations here.
# Use the translation in the example in your template with `t(".hello")`.
en:
save: Save
cancel: Cancel
back: Back
title:
ship: Edit Shipping Address
bill: Edit Billing Address
subtitle:
ship: Shipping Address
bill: Billing Address
use_this_address:
ship: Use this address also for Billing
bill: Use this address also for Shipping
Loading
Loading