Skip to content
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
15 changes: 13 additions & 2 deletions src/components/Pagination/SPagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default class SPagination extends Mixins(BorderRadiusMixin) {
/**
* Text for 'Rows per page' text
*
* `Per page text` by default
* `Rows per page` by default
*/
@Prop({ default: 'Rows per page', type: String }) readonly perPageText!: string
/**
Expand All @@ -117,6 +117,12 @@ export default class SPagination extends Mixins(BorderRadiusMixin) {
* `Total` by default
*/
@Prop({ default: 'Total', type: String }) readonly totalText!: string
/**
* Text for 'of' text
*
* `of` by default
*/
@Prop({ default: 'of', type: String }) readonly ofText!: string

@Ref('pagination') pagination!: any

Expand Down Expand Up @@ -147,7 +153,7 @@ export default class SPagination extends Mixins(BorderRadiusMixin) {
if (this.totalItem) {
if (this.total) {
const upperNumber = this.pageSizeModel * this.currentPageModel
this.totalItem.textContent = `${upperNumber - this.pageSizeModel + 1}—${upperNumber > this.total ? this.total : upperNumber} of ${this.total}`
this.totalItem.textContent = `${upperNumber - this.pageSizeModel + 1}—${upperNumber > this.total ? this.total : upperNumber} ${this.ofText} ${this.total}`
} else {
this.totalItem.textContent = `${this.totalText} ${this.total}`
}
Expand All @@ -172,6 +178,11 @@ export default class SPagination extends Mixins(BorderRadiusMixin) {
this.renderPaginationItems()
}

@Watch('ofText')
private handleOfTextChange () {
this.renderPaginationItems()
}

@Watch('pageSize')
private handlePageSizePropChange (value: number): void {
this.pageSizeModel = value
Expand Down
8 changes: 6 additions & 2 deletions src/stories/SPagination.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const configurable = () => ({
:next-text="nextText"
:per-page-text="perPageText"
:total-text="totalText"
:of-text="ofText"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
@prev-click="handlePrevClick"
Expand Down Expand Up @@ -57,10 +58,13 @@ export const configurable = () => ({
default: text('Next text', '')
},
perPageText: {
default: text('Per page text', '')
default: text('Per page text', 'Rows per page')
},
totalText: {
default: text('Total text', '')
default: text('Total text', 'Total')
},
ofText: {
default: text('Of text', 'of')
}
},
methods: {
Expand Down