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

[Admin] Automatically check edited return items in RMA form #3904

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ 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