-
-
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.
Allow editing the contact email in orders admin section
- Loading branch information
Showing
9 changed files
with
105 additions
and
5 deletions.
There are no files selected for viewing
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
18 changes: 18 additions & 0 deletions
18
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<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="body-small mt-4 block"> | ||
<%= t('.guest_checkout') %>: | ||
<output class="body-small-bold"><%= @order.user ? t('.yes') : t('.no') %></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')) %> | ||
<% end %> | ||
<% end %> | ||
</div> |
15 changes: 15 additions & 0 deletions
15
admin/app/components/solidus_admin/orders/show/email/component.rb
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::Orders::Show::Email::Component < SolidusAdmin::BaseComponent | ||
def initialize(order:) | ||
@order = order | ||
end | ||
|
||
def form_id | ||
dom_id(@order, "#{stimulus_id}_email_form") | ||
end | ||
|
||
def close_path | ||
@close_path ||= solidus_admin.order_path(@order) | ||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
admin/app/components/solidus_admin/orders/show/email/component.yml
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
en: | ||
title: "Edit order email" | ||
submit: "Save" | ||
cancel: "Cancel" | ||
guest_checkout: "Guest checkout" | ||
guest_checkout_tip: "An order without an associated user account is considered a guest checkout." | ||
"yes": "Yes" | ||
"no": "No" |
19 changes: 19 additions & 0 deletions
19
admin/app/controllers/solidus_admin/customers_controller.rb
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::CustomersController < SolidusAdmin::BaseController | ||
before_action :load_order, only: :show | ||
|
||
def show | ||
render component('orders/show/email').new(order: @order) | ||
end | ||
|
||
private | ||
|
||
def load_order | ||
@order = Spree::Order.find_by!(number: params[:order_id]) | ||
end | ||
|
||
def authorization_subject | ||
@order || Spree::Order | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ en: | |
solidus_admin: | ||
orders: | ||
title: "Orders" | ||
update: | ||
success: "Order was updated successfully" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,27 @@ | |
|
||
require 'spec_helper' | ||
|
||
describe "Order", type: :feature do | ||
describe "Order", :js, type: :feature do | ||
before { sign_in create(:admin_user, email: '[email protected]') } | ||
|
||
it "allows changing the order email" do | ||
create(:order, number: "R123456789", total: 19.99) | ||
|
||
visit "/admin/orders/R123456789/edit" | ||
|
||
expect(page).to have_content("Order R123456789") | ||
find("summary", text: "Customer").click | ||
click_on "Edit order email" | ||
within("dialog") do | ||
fill_in "Customer Email", with: "[email protected]" | ||
click_on "Save" | ||
end | ||
expect(page).to have_content("Order was updated successfully") | ||
expect(page).to have_content("Order contact email [email protected]", normalize_ws: true) | ||
end | ||
|
||
context "in cart state" do | ||
it "allows managing the cart", :js do | ||
it "allows managing the cart" do | ||
create(:product, name: "Just a product", slug: 'just-a-prod', price: 19.99) | ||
create(:product, name: "Just another product", slug: 'just-another-prod', price: 29.99) | ||
create(:order, number: "R123456789", total: 19.99, state: "cart") | ||
|