Skip to content

feat (pagination) added slots for first, prev, next, last, and ellipsis #1980

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from Oct 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/components/pagination/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ values for `total-rows` and `per-page`.
| `hide-ellipsis` | never show ellipsis indicators
| `hide-goto-end-buttons` | never display goto first/last buttons

| Slot | Description
|----- | -----------
| `first-text` | The "goto first page" button text (html supported)
| `prev-text` | The "goto previous page" button text (html supported)
| `next-text` | The "goto next page" button text (html supported)
| `last-text` | The "goto last page" button text (html supported)
| `ellipsis-text` | the `...` indicator text (html supported)


Ellipsis inidcator(s) will only be ever shown at the front and/or end of
the page number buttons. For `limit` values less than or equal to `3`, the ellipsis
indicator(s) will never be shown for practical display reasons.
Expand Down
10 changes: 10 additions & 0 deletions src/components/pagination/fixtures/pagination.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ <h6>Default</h6>
<b-pagination hide-goto-end-buttons :total-rows="100" v-model="currentPage" :limit="4" :per-page="10">
</b-pagination>

<br><br>

<b-pagination :total-rows="100" v-model="currentPage" :limit="4" :per-page="10">
<template slot="first-text">First</template>
<template slot="prev-text">Prev</template>
<template slot="next-text">Next</template>
<template slot="last-text">Last</template>
<template slot="ellipsis-text">...</template>
</b-pagination>

<br><br>
<div>currentPage: {{currentPage}}</div>
</div>
Expand Down
9 changes: 5 additions & 4 deletions src/mixins/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export default {
attrs: { role: 'separator' }
},
[
this.$slots['ellipsis-text'] ||
h('span', {
class: ['page-link'],
domProps: { innerHTML: this.ellipsisText }
Expand All @@ -190,11 +191,11 @@ export default {
buttons.push(
this.hideGotoEndButtons
? h(false)
: makeEndBtns(1, this.labelFirstPage, this.firstText)
: makeEndBtns(1, this.labelFirstPage, this.$slots['first-text'] || this.firstText)
)

// Goto Previous page button
buttons.push(makeEndBtns(this.currentPage - 1, this.labelPrevPage, this.prevText, 1))
buttons.push(makeEndBtns(this.currentPage - 1, this.labelPrevPage, this.$slots['prev-text'] || this.prevText, 1))

// First Ellipsis Bookend
buttons.push(this.showFirstDots ? makeEllipsis() : h(false))
Expand Down Expand Up @@ -257,7 +258,7 @@ export default {
makeEndBtns(
this.currentPage + 1,
this.labelNextPage,
this.nextText,
this.$slots['next-text'] || this.nextText,
this.numberOfPages
)
)
Expand All @@ -266,7 +267,7 @@ export default {
buttons.push(
this.hideGotoEndButtons
? h(false)
: makeEndBtns(this.numberOfPages, this.labelLastPage, this.lastText)
: makeEndBtns(this.numberOfPages, this.labelLastPage, this.$slots['last-text'] || this.lastText)
)

// Assemble the paginatiom buttons
Expand Down