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

VEN-275 As a Admin user on the Admin Order screen I can see Order special instructions left by the customer #105

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 3 additions & 1 deletion app/controllers/spree/admin/orders_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class OrdersController < Spree::Admin::BaseController
before_action :initialize_order_events
before_action :load_order, only: %i[
edit update cancel resume approve resend open_adjustments
close_adjustments cart channel set_channel
close_adjustments cart channel set_channel special_instructions
]

respond_to :html
Expand Down Expand Up @@ -153,6 +153,8 @@ def set_channel
redirect_to channel_admin_order_url(@order)
end

def special_instructions; end

private

def scope
Expand Down
16 changes: 16 additions & 0 deletions app/views/spree/admin/orders/special_instructions.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<%= render 'spree/admin/shared/order_tabs', current: :special_instructions %>

<% if @order.special_instructions.present? %>
<div class="card bg-light mb-3">
<div class="card-header">
<%= spree_icon 'info-circle-fill.svg' %> <%= Spree.t('admin.order.special_instructions_provided') %>
</div>
<div class="card-body">
<p class="card-text"><%= @order.special_instructions %></p>
</div>
</div>
<% else %>
<p><%= Spree.t('admin.order.no_special_instructions') %></p>
<% end %>

<%= render 'spree/admin/shared/order_summary' %>
9 changes: 9 additions & 0 deletions app/views/spree/admin/shared/_order_tabs.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,14 @@
class: "#{'active' if current == :state_changes} nav-link" %>
</li>
<% end %>

<% if @order.special_instructions.present? %>
<li data-hook='admin_order_tabs_state_changes'>
<%= link_to_with_icon 'info-circle.svg',
Spree.t(:special_instructions),
spree.special_instructions_admin_order_url(@order),
class: "#{'active' if current == :special_instructions} nav-link" %>
</li>
<% end %>
</ul>
<% end %>
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ en:
cancel: cancel
resume: resume
resend: Resend
special_instructions_provided: 'Special instructions provided by the customer'
no_special_instructions: 'There are no special instructions provided by the customer.'
orders:
cart: Cart
oauth_applications:
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
get :channel
put :set_channel
get :reset_digitals
get :special_instructions
end

resources :state_changes, only: [:index]
Expand Down
40 changes: 40 additions & 0 deletions spec/features/admin/orders/special_instructions_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require 'spec_helper'

describe 'Order - Special Instructions', type: :feature do
stub_authorization!

let(:store) { Spree::Store.default }
let!(:order) { create(:order, store: store, special_instructions: 'Some special instructions') }

context 'when there are special instructions' do
before do
visit spree.edit_admin_order_path(order)
end

it 'shows the Special Instructions tab' do
expect(page).to have_link(Spree.t(:special_instructions))
end

it 'shows the special instructions' do
click_link 'Special Instructions'
expect(page).to have_content(order.special_instructions)
end
end

context 'when there are no special instructions' do
before do
order.update(special_instructions: nil)
end

it 'does not show the special instructions tab' do
visit spree.edit_admin_order_path(order)
expect(page).not_to have_link(Spree.t(:special_instructions))
end

it 'shows a notification that there are no special instructions' do
visit spree.special_instructions_admin_order_path(order)
expect(page).to have_content(Spree.t('admin.order.no_special_instructions'))
end
end
end