pull/1613/head
Cagatay Civici 2021-09-24 13:31:28 +03:00
commit bb82b6aae1
4 changed files with 18 additions and 8 deletions

View File

@ -1,8 +1,8 @@
<template> <template>
<div :class="containerClass" @click="onClick($event)" :style="style"> <div :class="containerClass" @click="onClick($event)" :style="style">
<div class="p-hidden-accessible"> <div class="p-hidden-accessible">
<input ref="input" type="checkbox" :checked="modelValue" v-bind="$attrs" @focus="onFocus($event)" @blur="onBlur($event)" @keydown.enter.prevent="onClick($event)" <input ref="input" type="checkbox" :checked="checked" v-bind="$attrs" @focus="onFocus($event)" @blur="onBlur($event)" @keydown.enter.prevent="onClick($event)"
role="switch" :aria-checked="modelValue"> role="switch" :aria-checked="checked">
</div> </div>
<span class="p-inputswitch-slider"></span> <span class="p-inputswitch-slider"></span>
</div> </div>
@ -14,7 +14,10 @@ export default {
inheritAttrs: false, inheritAttrs: false,
emits: ['click', 'update:modelValue', 'change', 'input'], emits: ['click', 'update:modelValue', 'change', 'input'],
props: { props: {
modelValue: Boolean, modelValue: {
type: null,
default: false
},
class: null, class: null,
style: null, style: null,
trueValue: { trueValue: {

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: {