Skip to content

Commit f08036a

Browse files
committed
Fire change event in pf-paginate-control on input's @change
1 parent bd805a2 commit f08036a

File tree

2 files changed

+50
-12
lines changed

2 files changed

+50
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file.
1212

1313
### Fixed
1414
- Unwatched scrollable property on `pf-table` destruction.
15+
- The `pf-paginate-control` component correctly fires change of page event every time the input value changes.
1516

1617
## [0.0.23] - 2019-03-15
1718
### Fixed

src/components/PaginateControl.vue

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,45 @@
44
<pf-select ref="perpage" button close-on-select class="pagination-pf-pagesize">
55
<pf-option :value="itemsPerPage" @input="$emit('update:itemsPerPage', $event)" :checked-value="item" v-for="(item, i) in itemsPerPageOptions" :key="i">{{item}}</pf-option>
66
</pf-select>
7-
<span @click.stop="openPerPageSelect">per page</span>
7+
<span @click.stop="openPerPageSelect">{{labelPerPage}}</span>
88
</div>
99

1010
<div class="form-group">
11-
{{firstItem}}-{{lastItem}} of {{totalItems}}
11+
{{firstItem}}-{{lastItem}} {{labelOf}} {{totalItems}}
1212
<ul class="pagination pagination-pf-back">
1313
<li :class="{disabled: page == 1}">
14-
<a href="javascript:void(0)" title="First Page" @click="setPage(1)">
14+
<a href="javascript:void(0)" :title="labelFirstPage" @click="setPage(1)">
1515
<pf-icon name="fa-angle-double-left" class="i"/>
1616
</a>
1717
</li>
1818
<li :class="{disabled: page <= 1}">
19-
<a href="javascript:void(0)" title="Previous Page" @click="setPage(page - 1)">
19+
<a href="javascript:void(0)" :title="labelPreviousPage" @click="setPage(page - 1)">
2020
<pf-icon name="fa-angle-left" class="i"/>
2121
</a>
2222
</li>
2323
</ul>
2424

25-
<label for="`pf-paginate-control-input-${_uid}`" class="sr-only">Current Page</label>
26-
<input :id="`pf-paginate-control-input-${_uid}`" type="text" class="pagination-pf-page" v-model="page" :style="{
27-
width: (pages.toString().length * .8 + 1.5) + 'em'
28-
}">
29-
of {{pages}}
25+
<label for="`pf-paginate-control-input-${_uid}`" class="sr-only">{{labelCurrentPage}}</label>
26+
<input
27+
:id="`pf-paginate-control-input-${_uid}`"
28+
type="text"
29+
class="pagination-pf-page"
30+
:style="{
31+
width: (pages.toString().length * .8 + 1.5) + 'em'
32+
}"
33+
:value="page"
34+
@change="setPage($event.target.value)"
35+
>
36+
{{labelOf}} {{pages}}
3037

3138
<ul class="pagination pagination-pf-forward">
3239
<li :class="{disabled: page >= pages}">
33-
<a href="javascript:void(0)" title="Next Page" @click="setPage(page + 1)">
40+
<a href="javascript:void(0)" :title="labelNextPage" @click="setPage(page + 1)">
3441
<pf-icon name="fa-angle-right" class="i"/>
3542
</a>
3643
</li>
3744
<li :class="{disabled: page >= pages}">
38-
<a href="javascript:void(0)" title="Last Page" @click="setPage(pages)">
45+
<a href="javascript:void(0)" :title="labelLastPage" @click="setPage(pages)">
3946
<pf-icon name="fa-angle-double-right" class="i"/>
4047
</a>
4148
</li>
@@ -82,6 +89,34 @@ export default {
8289
return [10, 25, 50, 100, 500];
8390
},
8491
},
92+
labelFirstPage: {
93+
type: String,
94+
default: 'First Page',
95+
},
96+
labelLastPage: {
97+
type: String,
98+
default: 'Last Page',
99+
},
100+
labelPreviousPage: {
101+
type: String,
102+
default: 'Previous Page',
103+
},
104+
labelNextPage: {
105+
type: String,
106+
default: 'Next Page',
107+
},
108+
labelCurrentPage: {
109+
type: String,
110+
default: 'Current Page',
111+
},
112+
labelOf: {
113+
type: String,
114+
default: 'of',
115+
},
116+
labelPerPage: {
117+
type: String,
118+
default: 'per page',
119+
},
85120
},
86121
87122
computed: {
@@ -101,7 +136,9 @@ export default {
101136
methods: {
102137
setPage(page) {
103138
page = Math.max(Math.min(page, this.pages), 1);
104-
this.$emit('change', page);
139+
if (!isNaN(page) && page !== this.page) {
140+
this.$emit('change', page);
141+
}
105142
},
106143
107144
openPerPageSelect() {

0 commit comments

Comments
 (0)