Fixed #1602 - Paginator's Inputnumber displays index instead of current page

pull/1613/head
Yiğit FINDIKLI 2021-09-23 12:31:47 +03:00
parent 6648de2769
commit c17b67e2f5
3 changed files with 12 additions and 5 deletions

View File

@ -10,6 +10,10 @@
type: Number, type: Number,
default: 0 default: 0
}, },
currentPage: {
type: Number,
default: 0
},
page: { page: {
type: Number, type: Number,
default: 0 default: 0
@ -34,7 +38,7 @@
computed: { computed: {
text() { text() {
let text = this.template let text = this.template
.replace("{currentPage}", this.pageCount > 0 ? this.page + 1 : 0) .replace("{currentPage}", this.currentPage)
.replace("{totalPages}", this.pageCount) .replace("{totalPages}", this.pageCount)
.replace("{first}", this.pageCount > 0 ? this.first + 1 : 0) .replace("{first}", this.pageCount > 0 ? this.first + 1 : 0)
.replace("{last}", Math.min(this.first + this.rows, this.totalRecords)) .replace("{last}", Math.min(this.first + this.rows, this.totalRecords))

View File

@ -16,7 +16,7 @@ export default {
}, },
methods: { methods: {
onChange(value) { onChange(value) {
this.$emit('page-change', value); this.$emit('page-change', value - 1);
} }
}, },
components: { components: {

View File

@ -9,13 +9,13 @@
<NextPageLink v-else-if="item === 'NextPageLink'" @click="changePageToNext($event)" :disabled="isLastPage || empty" /> <NextPageLink v-else-if="item === 'NextPageLink'" @click="changePageToNext($event)" :disabled="isLastPage || empty" />
<LastPageLink v-else-if="item === 'LastPageLink'" @click="changePageToLast($event)" :disabled="isLastPage || empty" /> <LastPageLink v-else-if="item === 'LastPageLink'" @click="changePageToLast($event)" :disabled="isLastPage || empty" />
<PageLinks v-else-if="item === 'PageLinks'" :value="pageLinks" :page="page" @click="changePageLink($event)" /> <PageLinks v-else-if="item === 'PageLinks'" :value="pageLinks" :page="page" @click="changePageLink($event)" />
<CurrentPageReport v-else-if="item === 'CurrentPageReport'" :template="currentPageReportTemplate" <CurrentPageReport v-else-if="item === 'CurrentPageReport'" :template="currentPageReportTemplate" :currentPage="currentPage"
:page="page" :pageCount="pageCount" :first="d_first" :rows="d_rows" :totalRecords="totalRecords" /> :page="page" :pageCount="pageCount" :first="d_first" :rows="d_rows" :totalRecords="totalRecords" />
<RowsPerPageDropdown v-else-if="item === 'RowsPerPageDropdown' && rowsPerPageOptions" :rows="d_rows" <RowsPerPageDropdown v-else-if="item === 'RowsPerPageDropdown' && rowsPerPageOptions" :rows="d_rows"
:options="rowsPerPageOptions" @rows-change="onRowChange($event)" :disabled="empty"/> :options="rowsPerPageOptions" @rows-change="onRowChange($event)" :disabled="empty"/>
<JumpToPageDropdown v-else-if="item === 'JumpToPageDropdown'" :page="page" :pageCount="pageCount" <JumpToPageDropdown v-else-if="item === 'JumpToPageDropdown'" :page="page" :pageCount="pageCount"
@page-change="changePage($event)" :disabled="empty"/> @page-change="changePage($event)" :disabled="empty"/>
<JumpToPageInput v-else-if="item === 'JumpToPageInput'" :page="page" @page-change="changePage($event)" :disabled="empty"/> <JumpToPageInput v-else-if="item === 'JumpToPageInput'" :page="currentPage" @page-change="changePage($event)" :disabled="empty"/>
</template> </template>
<div class="p-paginator-right-content" v-if="$slots.right"> <div class="p-paginator-right-content" v-if="$slots.right">
<slot name="right" :state="currentState"></slot> <slot name="right" :state="currentState"></slot>
@ -194,6 +194,9 @@ export default {
}, },
empty() { empty() {
return this.pageCount === 0; return this.pageCount === 0;
},
currentPage() {
return this.pageCount > 0 ? this.page + 1 : 0;
} }
}, },
components: { components: {