mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-30 06:31:16 +00:00
Prevent page being orphaned when changing page size in BPE
This commit is contained in:
@@ -149,6 +149,9 @@ productsApp.controller "AdminBulkProductsCtrl", [
|
||||
$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))
|
||||
|
||||
$scope.$watch 'perPage', (newVal, oldVal) ->
|
||||
$scope.currentPage = $scope.totalPages() if newVal != oldVal && $scope.totalPages() < $scope.currentPage
|
||||
|
||||
$scope.initialise = (spree_api_key) ->
|
||||
authorise_api_reponse = ""
|
||||
dataFetcher("/api/users/authorise_api?token=" + spree_api_key).then (data) ->
|
||||
|
||||
@@ -564,6 +564,19 @@ feature %q{
|
||||
click_link "2"
|
||||
page.all("input[name='product_name']").select{ |e| e.visible? }.all?{ |e| e.value == "page2product" }.should == true
|
||||
end
|
||||
|
||||
it "moves the user to the last available page when changing perPage value causes user to become orphaned" do
|
||||
51.times { FactoryGirl.create(:product) }
|
||||
login_to_admin_section
|
||||
|
||||
visit '/admin/products/bulk_edit'
|
||||
|
||||
select '25', :from => 'perPage'
|
||||
click_link "3"
|
||||
select '50', :from => 'perPage'
|
||||
page.first("div.pagenav span.page.current").should have_text "2"
|
||||
page.all("input[name='product_name']").select{ |e| e.visible? }.length.should == 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user