From ac0410b4e90e1de3cd8a6c04238d904446501537 Mon Sep 17 00:00:00 2001 From: todd Date: Fri, 3 Aug 2018 22:03:22 +0900 Subject: [PATCH] pagination (feat) added slots for first, prev, next, last, and ellipsis. Fixed #1870. --- src/components/pagination/README.md | 9 +++++++++ src/components/pagination/fixtures/pagination.html | 10 ++++++++++ src/mixins/pagination.js | 9 +++++---- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/components/pagination/README.md b/src/components/pagination/README.md index 521bbde9fa7..22dff87a0a1 100755 --- a/src/components/pagination/README.md +++ b/src/components/pagination/README.md @@ -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. diff --git a/src/components/pagination/fixtures/pagination.html b/src/components/pagination/fixtures/pagination.html index 837c62c2b79..486a4fb96ee 100755 --- a/src/components/pagination/fixtures/pagination.html +++ b/src/components/pagination/fixtures/pagination.html @@ -29,6 +29,16 @@
Default
+

+ + + + + + + + +

currentPage: {{currentPage}}
diff --git a/src/mixins/pagination.js b/src/mixins/pagination.js index 6d330185f74..f04a1491bf6 100644 --- a/src/mixins/pagination.js +++ b/src/mixins/pagination.js @@ -178,6 +178,7 @@ export default { attrs: { role: 'separator' } }, [ + this.$slots['ellipsis-text'] || h('span', { class: ['page-link'], domProps: { innerHTML: this.ellipsisText } @@ -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)) @@ -257,7 +258,7 @@ export default { makeEndBtns( this.currentPage + 1, this.labelNextPage, - this.nextText, + this.$slots['next-text'] || this.nextText, this.numberOfPages ) ) @@ -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