From 58d1bf009245413d2b165e7ac3a0451950c8f107 Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 31 Jan 2014 11:57:57 +0800 Subject: [PATCH] BOM: can update quantities of line_items --- .../admin/bulk_order_management.js.coffee | 5 +++-- .../admin/orders/bulk_management.html.haml | 3 ++- .../admin/bulk_order_management_spec.rb | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/admin/bulk_order_management.js.coffee b/app/assets/javascripts/admin/bulk_order_management.js.coffee index b03ae1dc4f..e88697ff7f 100644 --- a/app/assets/javascripts/admin/bulk_order_management.js.coffee +++ b/app/assets/javascripts/admin/bulk_order_management.js.coffee @@ -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 = "" diff --git a/app/views/spree/admin/orders/bulk_management.html.haml b/app/views/spree/admin/orders/bulk_management.html.haml index 96bc32b0cf..a2cc517420 100644 --- a/app/views/spree/admin/orders/bulk_management.html.haml +++ b/app/views/spree/admin/orders/bulk_management.html.haml @@ -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" } \ No newline at end of file + %a{ 'ng-click' => "deleteLineItem(line_item)", :class => "delete-line-item icon-trash no-text" } + %input{ :type => "button", 'value' => 'Update', 'ng-click' => 'pendingChanges.submitAll()' } \ No newline at end of file diff --git a/spec/features/admin/bulk_order_management_spec.rb b/spec/features/admin/bulk_order_management_spec.rb index 0dfe2a779f..2b6c5d3542 100644 --- a/spec/features/admin/bulk_order_management_spec.rb +++ b/spec/features/admin/bulk_order_management_spec.rb @@ -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