File tree 5 files changed +42
-5
lines changed
5 files changed +42
-5
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div id =" app" >
3
3
<h1 >Vue-Paginate v3.0</h1 >
4
- <paginate name =" items" :list =" items" class =" paginate-list" >
4
+ <paginate name =" items" :list =" items" ref = " paginator " class =" paginate-list" >
5
5
<li v-for =" item in paginated('items')" >
6
6
{{ item }}
7
7
</li >
21
21
next: 'Next »',
22
22
prev: '« Back'
23
23
}" ></paginate-links >
24
+ <span v-if =" $refs.paginator" >
25
+ Viewing {{$refs.paginator.pageItemsCount}} results
26
+ </span >
24
27
</div >
25
28
</template >
26
29
Original file line number Diff line number Diff line change 73
73
"uglify-js" : " ^2.6.2" ,
74
74
"vue-loader" : " ^10.0.2" ,
75
75
"vue-style-loader" : " ^1.0.0" ,
76
- "vue-template-compiler" : " ^2.1.8 " ,
76
+ "vue-template-compiler" : " 2.3.3 " ,
77
77
"watchify" : " ^3.7.0" ,
78
78
"webpack" : " ^1.14.0" ,
79
79
"webpack-dev-server" : " ^1.16.2"
Original file line number Diff line number Diff line change @@ -36,6 +36,12 @@ export default {
36
36
set ( page ) {
37
37
this . $parent . paginate [ this . name ] . page = page
38
38
}
39
+ } ,
40
+ pageItemsCount ( ) {
41
+ const numOfItems = this . list . length
42
+ const first = this . currentPage * this . per + 1
43
+ const last = Math . min ( ( this . currentPage * this . per ) + this . per , numOfItems )
44
+ return `${ first } -${ last } of ${ numOfItems } `
39
45
}
40
46
} ,
41
47
mounted ( ) {
Original file line number Diff line number Diff line change @@ -160,4 +160,32 @@ describe('Paginate.vue', () => {
160
160
done ( )
161
161
} )
162
162
} )
163
+
164
+ it ( 'has page items count descripiton' , ( done ) => {
165
+ vm = new Vue ( {
166
+ template : `
167
+ <div>
168
+ <paginate ref="paginate"
169
+ name="langs"
170
+ :list="langs"
171
+ :per="2"
172
+ class="test-paginate"
173
+ ></paginate>
174
+ </div>` ,
175
+ data : {
176
+ langs : LANGS ,
177
+ paginate : { langs : { list : [ ] , page : 0 } }
178
+ } ,
179
+ components : { Paginate }
180
+ } ) . $mount ( )
181
+ const paginator = vm . $refs . paginate
182
+ Vue . nextTick ( ( ) => {
183
+ expect ( paginator . pageItemsCount ) . to . equal ( '1-2 of 8' )
184
+ vm . paginate . langs . page = 1
185
+ Vue . nextTick ( ( ) => {
186
+ expect ( paginator . pageItemsCount ) . to . equal ( '3-4 of 8' )
187
+ done ( )
188
+ } )
189
+ } )
190
+ } )
163
191
} )
Original file line number Diff line number Diff line change @@ -5045,9 +5045,9 @@ vue-style-loader@^1.0.0:
5045
5045
dependencies :
5046
5046
loader-utils "^0.2.7"
5047
5047
5048
- vue-template-compiler@^2.1.8 :
5049
- version "2.1.8 "
5050
- resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.1.8 .tgz#12dd1cc63793f59be580c694a61610cb9369d629 "
5048
+ vue-template-compiler@2.3.3 :
5049
+ version "2.3.3 "
5050
+ resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.3.3 .tgz#b5bab9ec57309c906b82a78c81a02179dbc2f470 "
5051
5051
dependencies :
5052
5052
de-indent "^1.0.2"
5053
5053
he "^1.1.0"
You can’t perform that action at this time.
0 commit comments