BOM: can update quantities of line_items

This commit is contained in:
Rob H
2014-01-31 11:57:57 +08:00
parent 0ac1816eb8
commit 58d1bf0092
3 changed files with 24 additions and 3 deletions

View File

@@ -64,11 +64,12 @@ orderManagementModule.factory "pendingChanges",[
orderManagementModule.controller "AdminOrderMgmtCtrl", [
"$scope", "$http", "dataFetcher", "blankEnterprise"
($scope, $http, dataFetcher, blankEnterprise) ->
"$scope", "$http", "dataFetcher", "blankEnterprise", "pendingChanges"
($scope, $http, dataFetcher, blankEnterprise, pendingChanges) ->
$scope.lineItems = []
$scope.confirmDelete = true
$scope.pendingChanges = pendingChanges
$scope.initialise = (spree_api_key) ->
authorise_api_reponse = ""

View File

@@ -39,4 +39,5 @@
%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" }
%a{ 'ng-click' => "deleteLineItem(line_item)", :class => "delete-line-item icon-trash no-text" }
%input{ :type => "button", 'value' => 'Update', 'ng-click' => 'pendingChanges.submitAll()' }

View File

@@ -110,6 +110,25 @@ feature %q{
page.should_not have_css "input[name='quantity'].update-pending"
end
end
context "submitting data to the server" 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 "displays an update button which submits pending changes" do
fill_in "quantity", :with => 2
page.should have_selector "input[name='quantity'].update-pending"
page.should_not have_selector "input[name='quantity'].update-success"
page.should have_button "Update"
click_button "Update"
page.should_not have_selector "input[name='quantity'].update-pending"
page.should have_selector "input[name='quantity'].update-success"
end
end
end
context "using page page controls" do