Fixed #1475 - CurrentPageReport displays wrong value

pull/1533/head
Cagatay Civici 2021-08-27 17:26:57 +03:00
parent 3f5d6a2bf1
commit 2b00a72b7a
4 changed files with 18 additions and 13 deletions

View File

@ -34,9 +34,9 @@
computed: { computed: {
text() { text() {
let text = this.template let text = this.template
.replace("{currentPage}", this.page + 1) .replace("{currentPage}", this.pageCount > 0 ? this.page + 1 : 0)
.replace("{totalPages}", this.pageCount) .replace("{totalPages}", this.pageCount)
.replace("{first}", this.first + 1) .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))
.replace("{rows}", this.rows) .replace("{rows}", this.rows)
.replace("{totalRecords}", this.totalRecords); .replace("{totalRecords}", this.totalRecords);

View File

@ -1,6 +1,6 @@
<template> <template>
<JTPDropdown :modelValue="page" :options="pageOptions" optionLabel="label" optionValue="value" <JTPDropdown :modelValue="page" :options="pageOptions" optionLabel="label" optionValue="value"
@update:modelValue="onChange($event)" class="p-paginator-page-options"></JTPDropdown> @update:modelValue="onChange($event)" class="p-paginator-page-options" :disabled="disabled"></JTPDropdown>
</template> </template>
<script> <script>
@ -12,7 +12,8 @@ export default {
emits: ['page-change'], emits: ['page-change'],
props: { props: {
page: Number, page: Number,
pageCount: Number pageCount: Number,
disabled: Boolean
}, },
methods: { methods: {
onChange(value) { onChange(value) {

View File

@ -4,17 +4,17 @@
<slot name="left" :state="currentState"></slot> <slot name="left" :state="currentState"></slot>
</div> </div>
<template v-for="item of templateItems" :key="item"> <template v-for="item of templateItems" :key="item">
<FirstPageLink v-if="item === 'FirstPageLink'" @click="changePageToFirst($event)" :disabled="isFirstPage" /> <FirstPageLink v-if="item === 'FirstPageLink'" @click="changePageToFirst($event)" :disabled="isFirstPage || empty" />
<PrevPageLink v-else-if="item === 'PrevPageLink'" @click="changePageToPrev($event)" :disabled="isFirstPage" /> <PrevPageLink v-else-if="item === 'PrevPageLink'" @click="changePageToPrev($event)" :disabled="isFirstPage || empty" />
<NextPageLink v-else-if="item === 'NextPageLink'" @click="changePageToNext($event)" :disabled="isLastPage" /> <NextPageLink v-else-if="item === 'NextPageLink'" @click="changePageToNext($event)" :disabled="isLastPage || empty" />
<LastPageLink v-else-if="item === 'LastPageLink'" @click="changePageToLast($event)" :disabled="isLastPage" /> <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"
: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)" /> :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)" /> @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>
@ -149,7 +149,7 @@ export default {
return Math.floor(this.d_first / this.d_rows); return Math.floor(this.d_first / this.d_rows);
}, },
pageCount() { pageCount() {
return Math.ceil(this.totalRecords / this.d_rows) || 1; return Math.ceil(this.totalRecords / this.d_rows);
}, },
isFirstPage() { isFirstPage() {
return this.page === 0; return this.page === 0;
@ -189,6 +189,9 @@ export default {
first: this.d_first, first: this.d_first,
rows: this.d_rows rows: this.d_rows
} }
},
empty() {
return this.pageCount === 0;
} }
}, },
components: { components: {

View File

@ -1,6 +1,6 @@
<template> <template>
<RPPDropdown :modelValue="rows" :options="rowsOptions" optionLabel="label" optionValue="value" <RPPDropdown :modelValue="rows" :options="rowsOptions" optionLabel="label" optionValue="value"
@update:modelValue="onChange($event)" class="p-paginator-rpp-options"></RPPDropdown> @update:modelValue="onChange($event)" class="p-paginator-rpp-options" :disabled="disabled"></RPPDropdown>
</template> </template>
<script> <script>
@ -12,7 +12,8 @@ export default {
emits: ['rows-change'], emits: ['rows-change'],
props: { props: {
options: Array, options: Array,
rows: Number rows: Number,
disabled: Boolean
}, },
methods: { methods: {
onChange(value) { onChange(value) {