BOM: applying ofnLineItemUpdAttr directive to quantity field, tracks changes with update-pending class

This commit is contained in:
Rob H
2014-01-31 11:17:27 +08:00
parent a5ffdbb1ba
commit 7dbb7a5c2c
3 changed files with 23 additions and 2 deletions

View File

@@ -29,7 +29,7 @@ orderManagementModule.directive "ofnLineItemUpdAttr", [
element: element
attrName: attrName
url: "/api/orders/#{scope.line_item.order.number}/line_items/#{scope.line_item.id}?line_item[#{attrName}]=#{value}"
pendingChanges.addItem(scope.line_item.id, attrName, changeObj)
pendingChanges.add(scope.line_item.id, attrName, changeObj)
switchClass( element, "update-pending", ["update-error", "update-success"], false )
]

View File

@@ -36,7 +36,7 @@
%td.producer {{ line_item.supplier.name }}
%td.variant {{ line_item.variant_unit_text }}
%td.quantity
%input{ :type => 'number', :name => 'quantity', 'ng-model' => "line_item.quantity" }
%input{ :type => 'number', :name => 'quantity', 'ng-model' => "line_item.quantity", 'ofn-line-item-upd-attr' => "quantity" }
%td.max {{ line_item.max }}
%td.actions
%a{ 'ng-click' => "deleteLineItem(line_item)", :class => "delete-line-item icon-trash no-text" }

View File

@@ -83,6 +83,27 @@ feature %q{
end
end
context "altering line item properties" do
before :each do
login_to_admin_section
end
context "tracking changes" do
let!(:o1) { FactoryGirl.create(:order, state: 'complete', completed_at: Time.now ) }
let!(:li1) { FactoryGirl.create(:line_item, order: o1, :quantity => 5 ) }
before :each do
visit '/admin/orders/bulk_management'
end
it "adds the class 'update-pending' to input elements when value is altered" do
page.should_not have_css "input[name='quantity'].update-pending"
fill_in "quantity", :with => 2
page.should have_css "input[name='quantity'].update-pending"
end
end
end
context "using page page controls" do
before :each do
login_to_admin_section