Skip to content

Commit

Permalink
Automatically check edited line items
Browse files Browse the repository at this point in the history
This feature got lost with #3565. It automatically checks rows
where the admin changes something, under the assumption that,
if a value is changed, then the user means to include the row
into the RMA/return.

An integration spec is added to properly track this feature.
  • Loading branch information
spaghetticode committed Jan 20, 2021
1 parent d51518a commit 05851c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Spree.Views.Tables.ReturnItems = Backbone.View.extend({
var tfoot = document.createElement('tfoot')
new Spree.Views.Tables.SelectableTable.SumReturnItemAmount({el: tfoot, model: this.model});
this.$el.append(tfoot);

this.$el.find('input, select').not('.add-item').on('change', function(e) {
$(this).closest('tr').find('input.add-item').prop('checked', true).change();
});
}
},
})
12 changes: 9 additions & 3 deletions backend/spec/features/admin/orders/return_authorizations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
end

context "when the user can manage return authorizations" do
describe "create" do
describe "create", :js do
def create_return_authorization
find("#select-all").click
select "NY Warehouse", from: "Stock Location"
Expand All @@ -38,13 +38,19 @@ def create_return_authorization
visit spree.new_admin_order_return_authorization_path(order)
end

it "creates a return authorization", :js do
it "creates a return authorization" do
create_return_authorization

expect(page).to have_content "Return Authorization has been successfully created!"
end

it "disables the button at submit", :js do
it "automatically checks edited rows" do
expect do
find(".refund-amount-input").native.send_keys [1, :tab]
end.to change { find(".add-item").checked? }.from(false).to(true)
end

it "disables the button at submit" do
page.execute_script "$('form').submit(function(e) { e.preventDefault()})"

create_return_authorization
Expand Down

0 comments on commit 05851c8

Please sign in to comment.