diff --git a/src/components/dropdown/Dropdown.vue b/src/components/dropdown/Dropdown.vue
index 1c19e2675..679a58524 100644
--- a/src/components/dropdown/Dropdown.vue
+++ b/src/components/dropdown/Dropdown.vue
@@ -365,7 +365,7 @@ export default {
'p-dropdown-label p-inputtext',
{
'p-placeholder': this.label === null && this.placeholder,
- 'p-dropdown-label-empty': !this.placeholder
+ 'p-dropdown-label-empty': (this.label == null || this.label.length === 0)
}
];
},
diff --git a/src/components/paginator/FirstPageLink.vue b/src/components/paginator/FirstPageLink.vue
index fa69fd569..60b43a4bf 100644
--- a/src/components/paginator/FirstPageLink.vue
+++ b/src/components/paginator/FirstPageLink.vue
@@ -1,21 +1,14 @@
-
\ No newline at end of file
diff --git a/src/components/paginator/Paginator.css b/src/components/paginator/Paginator.css
index 5b4ed5ae3..081a6407a 100644
--- a/src/components/paginator/Paginator.css
+++ b/src/components/paginator/Paginator.css
@@ -37,7 +37,8 @@
text-decoration: none;
vertical-align: middle;
text-align: center;
- position: relative;
+ position: relative;
+ cursor: pointer;
}
.p-paginator .p-paginator-pages {
@@ -80,7 +81,7 @@
-webkit-box-shadow: none;
}
-.p-paginator a.p-disabled {
+.p-paginator .p-disabled {
outline: 0 none;
}
diff --git a/src/components/paginator/Paginator.vue b/src/components/paginator/Paginator.vue
index 5566a1e20..e5149563b 100644
--- a/src/components/paginator/Paginator.vue
+++ b/src/components/paginator/Paginator.vue
@@ -3,14 +3,14 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -58,14 +58,68 @@ export default {
default: '({currentPage} of {totalPages})'
}
},
- components: {
- 'CurrentPageReport': CurrrentPageReport,
- 'FirstPageLink': FirstPageLink,
- 'LastPageLink': LastPageLink,
- 'NextPageLink': NextPageLink,
- 'PageLinks': PageLinks,
- 'PrevPageLink': PrevPageLink,
- 'RowsPerPageDropdown': RowsPerPageDropdown,
+ data() {
+ return {
+ d_first: this.first,
+ d_rows: this.rows
+ }
+ },
+ watch: {
+ first(newValue) {
+ this.d_first = newValue;
+ },
+ rows(newValue) {
+ this.d_rows = newValue;
+ }
+ },
+ methods: {
+ changePage(p) {
+ const pc = this.pageCount;
+
+ if (p >= 0 && p < pc) {
+ this.d_first = this.d_rows * p;
+ const state = {
+ page: p,
+ first: this.d_first,
+ rows: this.d_rows,
+ pageCount: pc
+ };
+
+ this.$emit('update:first', this.d_first);
+ this.$emit('update:rows', this.d_rows);
+ this.$emit('page-change', state);
+ }
+ },
+ changePageToFirst(event) {
+ if(!this.isFirstPage) {
+ this.changePage(0);
+ }
+
+ event.preventDefault();
+ },
+ changePageToPrev(event) {
+ this.changePage(this.page - 1);
+ event.preventDefault();
+ },
+ changePageLink(event) {
+ this.changePage(event.value - 1);
+ event.originalEvent.preventDefault();
+ },
+ changePageToNext(event) {
+ this.changePage(this.page + 1);
+ event.preventDefault();
+ },
+ changePageToLast(event) {
+ if(!this.isLastPage) {
+ this.changePage(this.pageCount - 1);
+ }
+
+ event.preventDefault();
+ },
+ onRowChange(value) {
+ this.d_rows = value;
+ this.changePage(this.page);
+ }
},
computed: {
templateItems() {
@@ -76,10 +130,10 @@ export default {
return keys;
},
page() {
- return Math.floor(this.first / this.rows);
+ return Math.floor(this.d_first / this.d_rows);
},
pageCount() {
- return Math.ceil(this.totalRecords / this.rows) || 1;
+ return Math.ceil(this.totalRecords / this.d_rows) || 1;
},
isFirstPage() {
return this.page === 0;
@@ -88,24 +142,24 @@ export default {
return this.page === this.pageCount - 1;
},
calculatePageLinkBoundaries() {
- var numberOfPages = this.pageCount;
- var visiblePages = Math.min(this.pageLinkSize, numberOfPages);
+ const numberOfPages = this.pageCount;
+ const visiblePages = Math.min(this.pageLinkSize, numberOfPages);
//calculate range, keep current in middle if necessary
- var start = Math.max(0, Math.ceil(this.page - ((visiblePages) / 2)));
- var end = Math.min(numberOfPages - 1, start + visiblePages - 1);
+ let start = Math.max(0, Math.ceil(this.page - ((visiblePages) / 2)));
+ let end = Math.min(numberOfPages - 1, start + visiblePages - 1);
//check when approaching to last page
- var delta = this.pageLinkSize - (end - start + 1);
+ const delta = this.pageLinkSize - (end - start + 1);
start = Math.max(0, start - delta);
return [start, end];
},
- updatePageLinks() {
- var pageLinks = [];
- var boundaries = this.calculatePageLinkBoundaries;
- var start = boundaries[0];
- var end = boundaries[1];
+ pageLinks() {
+ let pageLinks = [];
+ let boundaries = this.calculatePageLinkBoundaries;
+ let start = boundaries[0];
+ let end = boundaries[1];
for(var i = start; i <= end; i++) {
pageLinks.push(i + 1);
@@ -116,51 +170,19 @@ export default {
currentState() {
return {
page: this.page,
- first: this.first,
- rows: this.rows
+ first: this.d_first,
+ rows: this.d_rows
}
}
},
- methods: {
- changePage(first, rows) {
- const pc = this.pageCount;
- const p = Math.floor(first / rows);
-
- if (p >= 0 && p < pc) {
- let newPageState = {
- first: first,
- rows: rows,
- page: p,
- pageCount: pc
- };
-
- this.$emit('page-change', newPageState);
- this.$emit('update:first', first);
- this.$emit('update:rows', rows);
- }
- },
- changePageToFirst(event) {
- this.changePage(0, this.rows);
- event.preventDefault();
- },
- changePageToPrev(event) {
- this.changePage(this.first - this.rows, this.rows);
- event.preventDefault();
- },
- pageLinkClick(event) {
- this.changePage((event.value - 1) * this.rows, this.rows);
- },
- changePageToNext(event) {
- this.changePage(this.first + this.rows, this.rows);
- event.preventDefault();
- },
- changePageToLast(event) {
- this.changePage((this.pageCount - 1) * this.rows, this.rows);
- event.preventDefault();
- },
- rowsChange(event) {
- this.changePage(0, event.value.code);
- }
- }
+ components: {
+ 'CurrentPageReport': CurrrentPageReport,
+ 'FirstPageLink': FirstPageLink,
+ 'LastPageLink': LastPageLink,
+ 'NextPageLink': NextPageLink,
+ 'PageLinks': PageLinks,
+ 'PrevPageLink': PrevPageLink,
+ 'RowsPerPageDropdown': RowsPerPageDropdown,
+ },
}
\ No newline at end of file
diff --git a/src/components/paginator/PrevPageLink.vue b/src/components/paginator/PrevPageLink.vue
index d0965fa54..044e58531 100644
--- a/src/components/paginator/PrevPageLink.vue
+++ b/src/components/paginator/PrevPageLink.vue
@@ -1,21 +1,14 @@
-
+
\ No newline at end of file
diff --git a/src/views/paginator/PaginatorDoc.vue b/src/views/paginator/PaginatorDoc.vue
index 36f51e8b3..13ed5816c 100644
--- a/src/views/paginator/PaginatorDoc.vue
+++ b/src/views/paginator/PaginatorDoc.vue
@@ -229,11 +229,12 @@ onPage(event) {
</div>
<div class="content-section implementation">
- <h3 class="first">Default</h3>
- <Paginator :first.sync="first" :rows.sync="rows" :totalRecords="totalRecords" :rowsPerPageOptions="[10,20,30]"></Paginator>
+ <h3>Basic</h3>
+ <Paginator :rows="10" :totalRecords="totalRecords" :rowsPerPageOptions="[10,20,30]"></Paginator>
- <h3>Custom Template</h3>
- <Paginator :first.sync="first2" :rows="1" :totalRecords="totalRecords2" @page-change="onPageChangeCustom($event)" template="FirstPageLink PrevPageLink CurrentPageReport NextPageLink LastPageLink">
+ <h3>Custom</h3>
+ <Paginator :first.sync="first" :rows="1" :totalRecords="totalRecords2"
+ template="FirstPageLink PrevPageLink CurrentPageReport NextPageLink LastPageLink">
<template #left>
<Button type="button" icon="pi pi-refresh" @click="reset()"/>
</template>
@@ -243,7 +244,7 @@ onPage(event) {
</Paginator>
<div class="image-gallery">
- <img :src="'demo/images/nature/' + image + '.jpg'" />
+ <img :src="'demo/images/nature/' + image + '.jpg'" />
</div>
</div>
@@ -253,30 +254,23 @@ onPage(event) {
-import PaginatorDoc from './PaginatorDoc';
-
export default {
data() {
return {
first: 0,
- rows: 10,
- totalRecords: 50,
- first2: 0,
- totalRecords2: 12,
- image: 'nature1'
+ totalRecords: 120,
+ totalRecords2: 12
}
},
methods: {
- onPageChangeCustom(event) {
- this.image = 'nature' + (event.page + 1);
- },
reset() {
- this.first2 = 0;
- this.image = 'nature1';
+ this.first = 0;
}
},
- components: {
- 'PaginatorDoc': PaginatorDoc
+ computed: {
+ image() {
+ return 'nature' + (this.first + 1);
+ }
}
}