-
-
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.
Add a customer controller to allow editing the contact email
- Loading branch information
Showing
9 changed files
with
80 additions
and
3 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
12 changes: 12 additions & 0 deletions
12
admin/app/components/solidus_admin/orders/show/customer/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,12 @@ | ||
<div class="<%= stimulus_id %>"> | ||
<%= render component("orders/show").new(order: @order) %> | ||
<%= render component("ui/modal").new(title: t(".title"), close_path: solidus_admin.order_path(@order)) do |modal| %> | ||
<%= form_for @order, html: { id: form_id} do |f| %> | ||
<%= render component("ui/forms/field").text_field(f, :email) %> | ||
<% end %> | ||
<% modal.with_actions do %> | ||
<%= render component("ui/button").new(form: form_id, type: :submit, text: "Update") %> | ||
<% end %> | ||
<% end %> | ||
</div> |
11 changes: 11 additions & 0 deletions
11
admin/app/components/solidus_admin/orders/show/customer/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,11 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::Orders::Show::Customer::Component < SolidusAdmin::BaseComponent | ||
def initialize(order:) | ||
@order = order | ||
end | ||
|
||
def form_id | ||
dom_id(@order, "#{stimulus_id}_email_form") | ||
end | ||
end |
2 changes: 2 additions & 0 deletions
2
admin/app/components/solidus_admin/orders/show/customer/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,2 @@ | ||
en: | ||
title: "Edit customer" |
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/customer').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
9 changes: 9 additions & 0 deletions
9
admin/spec/components/solidus_admin/orders/show/customer/component_spec.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,9 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
RSpec.describe SolidusAdmin::Orders::Show::Customer::Component, type: :component do | ||
it "renders the overview preview" do | ||
render_preview(:overview) | ||
end | ||
end |