Bulk Actions only apply to visible line items

This commit is contained in:
Rob H
2014-03-20 16:54:24 +11:00
parent 43863069e9
commit 048b8b43cc
2 changed files with 26 additions and 5 deletions

View File

@@ -202,18 +202,18 @@ orderManagementModule.controller "AdminOrderMgmtCtrl", [
$scope.deleteSelected = ->
existingState = $scope.confirmDelete
$scope.confirmDelete = false
$scope.deleteLineItem lineItem for lineItem in $scope.lineItems when lineItem.checked
$scope.deleteLineItem lineItem for lineItem in $scope.filteredLineItems when lineItem.checked
$scope.confirmDelete = existingState
$scope.allBoxesChecked = ->
checkedCount = $scope.lineItems.reduce (count,lineItem) ->
checkedCount = $scope.filteredLineItems.reduce (count,lineItem) ->
count + (if lineItem.checked then 1 else 0 )
, 0
checkedCount == $scope.lineItems.length
checkedCount == $scope.filteredLineItems.length
$scope.toggleAllCheckboxes = ->
changeTo = !$scope.allBoxesChecked()
lineItem.checked = changeTo for lineItem in $scope.lineItems
lineItem.checked = changeTo for lineItem in $scope.filteredLineItems
$scope.setSelectedUnitsVariant = (unitsVariant) ->
$scope.selectedUnitsVariant = unitsVariant

View File

@@ -392,6 +392,27 @@ feature %q{
page.should_not have_selector "tr#li_#{li2.id}", visible: true
end
end
context "when a filter has been applied" do
it "only toggles checkboxes which are in filteredLineItems" do
fill_in "quick_search", with: o1.number
check "toggle_bulk"
fill_in "quick_search", with: ''
find("tr#li_#{li1.id} input[type='checkbox'][name='bulk']").checked?.should == true
find("tr#li_#{li2.id} input[type='checkbox'][name='bulk']").checked?.should == false
find("input[type='checkbox'][name='toggle_bulk']").checked?.should == false
end
it "only applies the delete action to filteredLineItems" do
check "toggle_bulk"
fill_in "quick_search", with: o1.number
select "Delete", :from => "bulk_actions"
click_button "bulk_execute"
fill_in "quick_search", with: ''
page.should_not have_selector "tr#li_#{li1.id}", visible: true
page.should have_selector "tr#li_#{li2.id}", visible: true
end
end
end
context "using action buttons" do
@@ -409,7 +430,7 @@ feature %q{
page.should have_selector "a.delete-line-item", :count => 2
end
it "removes a line item when the relavent delete button is clicked" do
it "removes a line item when the relevant delete button is clicked" do
first("a.delete-line-item").click
page.should_not have_selector "a.delete-line-item", :count => 2
page.should have_selector "a.delete-line-item", :count => 1