-
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(index): add pagination controls to the bottom of the page
- Loading branch information
Showing
15 changed files
with
1,286 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module PactBroker | ||
module Index | ||
class Page < Array | ||
attr_reader :pagination_record_count | ||
|
||
def initialize(array, pagination_record_count) | ||
super(array) | ||
@pagination_record_count = pagination_record_count | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
%script{type: 'text/javascript', src:'/javascripts/pagination.js'} | ||
|
||
:javascript | ||
const PAGE_NUMBER = #{page_number}; | ||
const PAGE_SIZE = #{page_size}; | ||
const TOTAL_NUMBER = #{pagination_record_count} | ||
const CURRENT_PAGE_SIZE = #{current_page_size} | ||
|
||
$(document).ready(function(){ | ||
function createPageLink(pageNumber, pageSize) { | ||
const url = new URL(window.location) | ||
url.searchParams.set('page', pageNumber) | ||
url.searchParams.set('pageSize', pageSize) | ||
return url.toString() | ||
} | ||
|
||
function createFooter(currentPage, totalPage, totalNumber) { | ||
return `<div class='nav-footer'>${CURRENT_PAGE_SIZE} of ${totalNumber} pacts</div>` | ||
} | ||
|
||
$('div.pagination').pagination({ | ||
dataSource: [], | ||
totalNumber: TOTAL_NUMBER, | ||
pageNumber: PAGE_NUMBER, | ||
pageSize: PAGE_SIZE, | ||
pageRange: 2, | ||
pageLink: createPageLink, | ||
ulClassName: 'pagination', | ||
footer: createFooter | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.