Skip to content

Commit bb75082

Browse files
authored
Merge pull request #3214 from nebulab/no-product-add-at-shipments
Remove "Add product" in admin order shipments page
2 parents c2eae3a + b06c385 commit bb75082

File tree

9 files changed

+10
-148
lines changed

9 files changed

+10
-148
lines changed

backend/app/assets/javascripts/spree/backend/shipments.js

-62
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,6 @@
11
// Shipments AJAX API
22
/* eslint no-extra-semi: "off", no-unused-vars: "off" */
33

4-
var ShipmentAddVariantView = Backbone.View.extend({
5-
events: {
6-
"change #add_variant_id": "onSelect",
7-
"click .add_variant": "onAdd",
8-
"submit form": "onAdd"
9-
},
10-
onSelect: function(e) {
11-
var variant_id = this.$("#add_variant_id").val();
12-
var template = HandlebarsTemplates["variants/autocomplete_stock"];
13-
var $stock_details = this.$('#stock_details');
14-
Spree.ajax({
15-
url: Spree.routes.variants_api + "/" + variant_id,
16-
success: function(variant){
17-
$stock_details.html(template({variant: variant})).show()
18-
}
19-
});
20-
},
21-
onAdd: function(e){
22-
e.preventDefault();
23-
24-
this.$('#stock_details').hide();
25-
26-
var variant_id = this.$('input.variant_autocomplete').val();
27-
var stock_location_id = $(e.target).data('stock-location-id');
28-
var quantity = this.$("input.quantity[data-stock-location-id='" + stock_location_id + "']").val();
29-
30-
addVariantFromStockLocation(stock_location_id, variant_id, quantity)
31-
}
32-
});
33-
34-
Spree.ready(function(){
35-
$(".js-shipment-add-variant").each(function(){
36-
new ShipmentAddVariantView({el: this});
37-
});
38-
});
39-
404
var ShipShipmentView = Backbone.View.extend({
415
initialize: function(options){
426
this.shipment_number = options.shipment_number;
@@ -97,32 +61,6 @@ adjustShipmentItems = function(shipment_number, variant_id, quantity){
9761
}
9862
};
9963

100-
addVariantFromStockLocation = function(stock_location_id, variant_id, quantity) {
101-
var shipment = _.find(shipments, function(shipment){
102-
return shipment.stock_location_id == stock_location_id && (shipment.state == 'ready' || shipment.state == 'pending');
103-
});
104-
105-
if(shipment==undefined){
106-
Spree.ajax({
107-
type: "POST",
108-
url: Spree.routes.shipments_api,
109-
data: {
110-
shipment: {
111-
order_id: window.order_number
112-
},
113-
variant_id: variant_id,
114-
quantity: quantity,
115-
stock_location_id: stock_location_id,
116-
}
117-
}).done(function(){
118-
window.location.reload();
119-
});
120-
}else{
121-
//add to existing shipment
122-
adjustShipmentItems(shipment.number, variant_id, quantity);
123-
}
124-
};
125-
12664
var ShipmentSplitItemView = Backbone.View.extend({
12765
tagName: 'tr',
12866
className: 'stock-item-split',

backend/app/assets/javascripts/spree/backend/templates/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@
1313
//= require spree/backend/templates/taxons/_tree
1414
//= require spree/backend/templates/taxons/tree
1515
//= require spree/backend/templates/variants/autocomplete
16-
//= require spree/backend/templates/variants/autocomplete_stock
1716
//= require spree/backend/templates/variants/line_items_autocomplete_stock
1817
//= require spree/backend/templates/variants/split

backend/app/assets/javascripts/spree/backend/templates/variants/autocomplete_stock.hbs

-56
This file was deleted.

backend/app/views/spree/admin/orders/_add_product.html.erb

-12
This file was deleted.

backend/app/views/spree/admin/orders/edit.html.erb

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@
1818
<%= render 'spree/admin/orders/risk_analysis', latest_payment: @order.payments.reorder("created_at DESC").first %>
1919
<% end %>
2020

21-
<% if can?(:update, Spree::Shipment) && can?(:update, @order) && @order.shipment_state != "shipped" %>
22-
<%= render partial: 'add_product' %>
23-
<% end %>
21+
<div data-hook="admin_order_edit_sub_header" />
2422

2523
<% if @order.line_items.empty? %>
2624
<div class="no-objects-found">
27-
<%= t('spree.your_order_is_empty_add_product')%>
25+
<p><%= t('spree.your_order_is_empty_add_product') %></p>
26+
<%= link_to t('spree.cart'), spree.cart_admin_order_url(@order), class: 'btn btn-primary' %>
2827
</div>
2928
<% end %>
3029

backend/spec/features/admin/orders/customer_details_spec.rb

-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@
157157
end
158158

159159
it "sets default country when displaying form" do
160-
click_link "Cart"
161160
click_link "Customer"
162161
expect(page).to have_field("order_bill_address_attributes_country_id", with: brazil.id, visible: false)
163162
end

backend/spec/features/admin/orders/new_order_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@
154154
click_on "Update"
155155

156156
# Automatically redirected to Shipments page
157-
select2_search product.name, from: I18n.t('spree.name_or_sku')
158-
159-
click_icon :plus
157+
within '.no-objects-found' do
158+
click_on "Cart"
159+
end
160160

161-
expect(page).to have_css('.stock-item')
161+
add_line_item product.name
162162

163163
click_on "Payments"
164-
click_on "Continue"
164+
click_on "Update"
165165

166166
within(".additional-info") do
167167
expect(page).to have_content("Confirm")

backend/spec/features/admin/orders/order_details_spec.rb

+1-4
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,7 @@
291291

292292
context 'A shipment has shipped' do
293293
it 'should not show or let me back to the cart page, nor show the shipment edit buttons' do
294-
order = create(:order, state: 'payment')
295-
order.shipments.create!(stock_location_id: stock_location.id, state: 'shipped')
294+
order = create(:shipped_order, state: 'payment', stock_location: stock_location)
296295

297296
visit spree.cart_admin_order_path(order)
298297

@@ -538,8 +537,6 @@
538537
expect(page).not_to have_css('.delete-item')
539538
expect(page).not_to have_css('.split-item')
540539
expect(page).not_to have_css('.edit-tracking')
541-
542-
expect(page).not_to have_css('#add-line-item')
543540
end
544541
end
545542

core/config/locales/en.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,6 @@ en:
19441944
select: Select
19451945
select_a_reason: Select a reason
19461946
select_a_stock_location: Select a stock location
1947-
select_stock: Select stock
19481947
selected_quantity_not_available: selected of %{item} is not available.
19491948
send_copy_of_all_mails_to: Send Copy of All Mails To
19501949
send_mailer: Send Mailer
@@ -2223,8 +2222,7 @@ en:
22232222
you_cannot_undo_action: You will not be able to undo this action
22242223
you_have_no_orders_yet: You have no orders yet
22252224
your_cart_is_empty: Your cart is empty
2226-
your_order_is_empty_add_product: Your order is empty, please search for and add
2227-
a product above
2225+
your_order_is_empty_add_product: Your order is empty. Please add products first.
22282226
zip: Zip
22292227
zipcode: Zip Code
22302228
zone: Zone

0 commit comments

Comments
 (0)