mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
WIP: Add basic page nav controls to BPE
This commit is contained in:
@@ -142,8 +142,11 @@ productsApp.controller "AdminBulkProductsCtrl", [
|
||||
$scope.currentPage = 1
|
||||
$scope.products = []
|
||||
$scope.totalCount = -> $scope.products.length
|
||||
$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.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.initialise = (spree_api_key) ->
|
||||
authorise_api_reponse = ""
|
||||
@@ -375,6 +378,10 @@ productsApp.factory "dataFetcher", [
|
||||
deferred.promise
|
||||
]
|
||||
|
||||
productsApp.filter "rangeArray", ->
|
||||
return (input,start,end) ->
|
||||
input.push(i) for i in [start..end]
|
||||
input
|
||||
|
||||
filterSubmitProducts = (productsToFilter) ->
|
||||
filteredProducts = []
|
||||
|
||||
@@ -2,6 +2,16 @@
|
||||
display: block;
|
||||
}
|
||||
|
||||
div.pagination {
|
||||
div.pagenav {
|
||||
margin: 0px;
|
||||
span.first, span.prev, span.next, span.last {
|
||||
padding: 5px 0px;
|
||||
display:inline-block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tbody.odd {
|
||||
tr.product { td { background-color: white; } }
|
||||
tr.variant.odd { td { background-color: lighten(#eff5fc, 3); } }
|
||||
|
||||
@@ -33,6 +33,26 @@
|
||||
per page
|
||||
%br
|
||||
%span Displaying {{firstVisibleProduct()}}-{{lastVisibleProduct()}} of {{totalCount()}} products
|
||||
%div.pagination{ :class => "seven columns" }
|
||||
%div.pagenav{ :class => "two columns alpha" }
|
||||
%span.first
|
||||
%a{ 'ng-click' => "currentPage = 1", 'ng-show' => "currentPage > 1" }
|
||||
« First
|
||||
%span.prev
|
||||
%a{ 'ng-click' => "currentPage = currentPage - 1", 'ng-show' => "currentPage > 1" }
|
||||
‹ Prev
|
||||
%div.pagenav{ :class => "columns omega" }
|
||||
%span.page{ 'ng-repeat' => "page in [] | rangeArray:minPage():maxPage()", 'ng-class' => "{current: currentPage==page}" }
|
||||
%a{ 'ng-click' => "setPage(page)" }
|
||||
{{page}}
|
||||
%span{ 'ng-show' => "maxPage() < totalPages()" } ...
|
||||
%div.pagenav{ :class => "two columns omega" }
|
||||
%span.next
|
||||
%a{ 'ng-click' => "currentPage = currentPage + 1", 'ng-show' => "currentPage < totalPages()" }
|
||||
Next ›
|
||||
%span.last
|
||||
%a{ 'ng-click' => "currentPage = totalPages()", 'ng-show' => "currentPage < totalPages()" }
|
||||
Last »
|
||||
%table.index#listing_products.bulk
|
||||
%colgroup
|
||||
%col
|
||||
|
||||
@@ -500,11 +500,17 @@ feature %q{
|
||||
|
||||
describe "using pagination controls" do
|
||||
it "shows pagination controls" do
|
||||
27.times { FactoryGirl.create(:product) }
|
||||
login_to_admin_section
|
||||
|
||||
visit '/admin/products/bulk_edit'
|
||||
|
||||
page.should have_select 'perPage', :selected => '25'
|
||||
within '.pagination' do
|
||||
page.should have_text "1 2"
|
||||
page.should have_text "Next"
|
||||
page.should have_text "Last"
|
||||
end
|
||||
end
|
||||
|
||||
it "allows the number of visible products to be altered" do
|
||||
|
||||
Reference in New Issue
Block a user