mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
BOM: applying ofnLineItemUpdAttr directive to quantity field, tracks changes with update-pending class
This commit is contained in:
@@ -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 )
|
||||
]
|
||||
|
||||
|
||||
@@ -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" }
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user