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

Remove "Add product" in admin order shipments page #3214

Merged
merged 5 commits into from
Sep 12, 2019
Merged
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
62 changes: 0 additions & 62 deletions backend/app/assets/javascripts/spree/backend/shipments.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,6 @@
// Shipments AJAX API
/* eslint no-extra-semi: "off", no-unused-vars: "off" */

var ShipmentAddVariantView = Backbone.View.extend({
events: {
"change #add_variant_id": "onSelect",
"click .add_variant": "onAdd",
"submit form": "onAdd"
},
onSelect: function(e) {
var variant_id = this.$("#add_variant_id").val();
var template = HandlebarsTemplates["variants/autocomplete_stock"];
var $stock_details = this.$('#stock_details');
Spree.ajax({
url: Spree.routes.variants_api + "/" + variant_id,
success: function(variant){
$stock_details.html(template({variant: variant})).show()
}
});
},
onAdd: function(e){
e.preventDefault();

this.$('#stock_details').hide();

var variant_id = this.$('input.variant_autocomplete').val();
var stock_location_id = $(e.target).data('stock-location-id');
var quantity = this.$("input.quantity[data-stock-location-id='" + stock_location_id + "']").val();

addVariantFromStockLocation(stock_location_id, variant_id, quantity)
}
});

Spree.ready(function(){
$(".js-shipment-add-variant").each(function(){
new ShipmentAddVariantView({el: this});
});
});

var ShipShipmentView = Backbone.View.extend({
initialize: function(options){
this.shipment_number = options.shipment_number;
@@ -97,32 +61,6 @@ adjustShipmentItems = function(shipment_number, variant_id, quantity){
}
};

addVariantFromStockLocation = function(stock_location_id, variant_id, quantity) {
var shipment = _.find(shipments, function(shipment){
return shipment.stock_location_id == stock_location_id && (shipment.state == 'ready' || shipment.state == 'pending');
});

if(shipment==undefined){
Spree.ajax({
type: "POST",
url: Spree.routes.shipments_api,
data: {
shipment: {
order_id: window.order_number
},
variant_id: variant_id,
quantity: quantity,
stock_location_id: stock_location_id,
}
}).done(function(){
window.location.reload();
});
}else{
//add to existing shipment
adjustShipmentItems(shipment.number, variant_id, quantity);
}
};

var ShipmentSplitItemView = Backbone.View.extend({
tagName: 'tr',
className: 'stock-item-split',
Original file line number Diff line number Diff line change
@@ -13,6 +13,5 @@
//= require spree/backend/templates/taxons/_tree
//= require spree/backend/templates/taxons/tree
//= require spree/backend/templates/variants/autocomplete
//= require spree/backend/templates/variants/autocomplete_stock
//= require spree/backend/templates/variants/line_items_autocomplete_stock
//= require spree/backend/templates/variants/split

This file was deleted.

12 changes: 0 additions & 12 deletions backend/app/views/spree/admin/orders/_add_product.html.erb

This file was deleted.

7 changes: 3 additions & 4 deletions backend/app/views/spree/admin/orders/edit.html.erb
Original file line number Diff line number Diff line change
@@ -18,13 +18,12 @@
<%= render 'spree/admin/orders/risk_analysis', latest_payment: @order.payments.reorder("created_at DESC").first %>
<% end %>

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

<% if @order.line_items.empty? %>
<div class="no-objects-found">
<%= t('spree.your_order_is_empty_add_product')%>
<p><%= t('spree.your_order_is_empty_add_product') %></p>
<%= link_to t('spree.cart'), spree.cart_admin_order_url(@order), class: 'btn btn-primary' %>
</div>
<% end %>

Original file line number Diff line number Diff line change
@@ -157,7 +157,6 @@
end

it "sets default country when displaying form" do
click_link "Cart"
click_link "Customer"
expect(page).to have_field("order_bill_address_attributes_country_id", with: brazil.id, visible: false)
end
10 changes: 5 additions & 5 deletions backend/spec/features/admin/orders/new_order_spec.rb
Original file line number Diff line number Diff line change
@@ -154,14 +154,14 @@
click_on "Update"

# Automatically redirected to Shipments page
select2_search product.name, from: I18n.t('spree.name_or_sku')

click_icon :plus
within '.no-objects-found' do
click_on "Cart"
end

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

click_on "Payments"
click_on "Continue"
click_on "Update"

within(".additional-info") do
expect(page).to have_content("Confirm")
5 changes: 1 addition & 4 deletions backend/spec/features/admin/orders/order_details_spec.rb
Original file line number Diff line number Diff line change
@@ -278,8 +278,7 @@

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

visit spree.cart_admin_order_path(order)

@@ -525,8 +524,6 @@
expect(page).not_to have_css('.delete-item')
expect(page).not_to have_css('.split-item')
expect(page).not_to have_css('.edit-tracking')

expect(page).not_to have_css('#add-line-item')
end
end

4 changes: 1 addition & 3 deletions core/config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1944,7 +1944,6 @@ en:
select: Select
select_a_reason: Select a reason
select_a_stock_location: Select a stock location
select_stock: Select stock
selected_quantity_not_available: selected of %{item} is not available.
send_copy_of_all_mails_to: Send Copy of All Mails To
send_mailer: Send Mailer
@@ -2223,8 +2222,7 @@ en:
you_cannot_undo_action: You will not be able to undo this action
you_have_no_orders_yet: You have no orders yet
your_cart_is_empty: Your cart is empty
your_order_is_empty_add_product: Your order is empty, please search for and add
a product above
your_order_is_empty_add_product: Your order is empty. Please add products first.
zip: Zip
zipcode: Zip Code
zone: Zone