Skip to content

Commit

Permalink
Merge pull request solidusio#489 from bonobos/admin_shipment_delete
Browse files Browse the repository at this point in the history
Admin shipment delete line item hits api/line_items instead of api/shipments
  • Loading branch information
cbrunsdon committed Nov 19, 2015
2 parents 3172ab3 + c6fa622 commit 39d688d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 17 additions & 3 deletions backend/app/assets/javascripts/spree/backend/shipments.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ $(document).ready(function () {
$('a.delete-item').click(function(event){
if (confirm(Spree.translations.are_you_sure_delete)) {
var del = $(this);
var shipment_number = del.data('shipment-number');
var variant_id = del.data('variant-id');
var line_item_id = del.data('line-item-id');

toggleItemEdit();
adjustShipmentItems(shipment_number, variant_id, 0);
deleteLineItem(line_item_id);
}
return false;
});
Expand Down Expand Up @@ -171,6 +170,21 @@ adjustShipmentItems = function(shipment_number, variant_id, quantity){
}
}

deleteLineItem = function(line_item_id){
var url = Spree.routes.line_items_api(order_number) + "/" + line_item_id + ".json";

Spree.ajax({
type: "DELETE",
url: Spree.url(url),
success: function(response) {
window.location.reload();
},
error: function(response) {
show_flash('error', response.responseJSON.message);
}
});
}

toggleMethodEdit = function(){
var link = $(this);
link.parents('tbody').find('tr.edit-method').toggle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<%= link_to '', '#', :class => 'save-item fa fa-check no-text with-tip', :data => {'shipment-number' => shipment_number, 'variant-id' => item.variant.id, :action => 'save'}, :title => Spree.t('actions.save'), :style => 'display: none' %>
<%= link_to '', '#', :class => 'cancel-item fa fa-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => Spree.t('actions.cancel'), :style => 'display: none' %>
<%= link_to '', '#', :class => 'split-item icon_link fa fa-arrows-h no-text with-tip', :data => {:action => 'split', 'variant-id' => item.variant.id}, :title => Spree.t('split') %>
<%= link_to '', '#', :class => 'delete-item fa fa-trash no-text with-tip', :data => { 'shipment-number' => shipment_number, 'variant-id' => item.variant.id, :action => 'remove'}, :title => Spree.t('delete') %>
<%= link_to '', '#', :class => 'delete-item fa fa-trash no-text with-tip', :data => { 'line-item-id' => item.line_item.id}, :title => Spree.t('delete') %>
<% end %>
</td>
</tr>
Expand Down

0 comments on commit 39d688d

Please sign in to comment.