mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-19 04:49:15 +00:00
BPE page nav using page numbers
This commit is contained in:
@@ -145,6 +145,7 @@ productsApp.controller "AdminBulkProductsCtrl", [
|
||||
$scope.totalPages = -> Math.ceil($scope.totalCount()/$scope.perPage)
|
||||
$scope.firstVisibleProduct = -> ($scope.currentPage-1)*$scope.perPage+1
|
||||
$scope.lastVisibleProduct = -> Math.min($scope.totalCount(),$scope.currentPage*$scope.perPage)
|
||||
$scope.setPage = (page) -> $scope.currentPage = page
|
||||
$scope.minPage = -> Math.max(1,Math.min($scope.totalPages()-4,$scope.currentPage-2))
|
||||
$scope.maxPage = -> Math.min($scope.totalPages(),Math.max(5,$scope.currentPage+2))
|
||||
|
||||
|
||||
@@ -520,9 +520,22 @@ feature %q{
|
||||
visit '/admin/products/bulk_edit'
|
||||
|
||||
select '25', :from => 'perPage'
|
||||
page.all("input[name='product_name']").select{|e| e.visible?}.length.should == 25
|
||||
page.all("input[name='product_name']").select{ |e| e.visible? }.length.should == 25
|
||||
select '50', :from => 'perPage'
|
||||
page.all("input[name='product_name']").select{|e| e.visible?}.length.should == 27
|
||||
page.all("input[name='product_name']").select{ |e| e.visible? }.length.should == 27
|
||||
end
|
||||
|
||||
it "displays the correct products when changing pages" do
|
||||
25.times { FactoryGirl.create(:product, :name => "page1product") }
|
||||
5.times { FactoryGirl.create(:product, :name => "page2product") }
|
||||
login_to_admin_section
|
||||
|
||||
visit '/admin/products/bulk_edit'
|
||||
|
||||
select '25', :from => 'perPage'
|
||||
page.all("input[name='product_name']").select{ |e| e.visible? }.all?{ |e| e.value == "page1product" }.should == true
|
||||
click_link "2"
|
||||
page.all("input[name='product_name']").select{ |e| e.visible? }.all?{ |e| e.value == "page2product" }.should == true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user