@@ -43,41 +43,40 @@ import PrettyPrint from './PrettyPrint'
4343export default {
4444 name: ' DetailsTable' ,
4545 components: { DetailsTableFilterToggle, PrettyPrint },
46- props: [ ' columns' , ' filter' , ' filterExample' , ' items' , ' noHeader' ] ,
46+ props: { columns: {}, filter: {}, filterExample: {}, items: {}, noHeader: {}, perPage : { default : 30 } } ,
4747 data : () => ({
48- showItemsCount: 30 ,
49- showItemsFirst: 0
48+ firstShown: 0
5049 }),
5150 computed: {
5251 filteredItems () {
5352 return this .filter .filter (this .items )
5453 },
5554 shownItems () {
56- if (this .showItemsFirst > this .filteredItems .length ) {
57- this .showItemsFirst = Math .max (this .filteredItems .length - this .showItemsCount , 0 )
55+ if (this .firstShown > this .filteredItems .length ) {
56+ this .firstShown = Math .max (this .filteredItems .length - this .perPage , 0 )
5857 }
5958
60- return this .filteredItems .slice (this .showItemsFirst , this .showItemsFirst + this .showItemsCount )
59+ return this .filteredItems .slice (this .firstShown , this .firstShown + this .perPage )
6160 },
6261 hasPreviousItems () {
63- return this .showItemsFirst > 0
62+ return this .firstShown > 0
6463 },
6564 previousItemsCount () {
66- return this .showItemsFirst
65+ return this .firstShown
6766 },
6867 hasNextItems () {
69- return this .showItemsFirst + this .showItemsCount < this .filteredItems .length
68+ return this .firstShown + this .perPage < this .filteredItems .length
7069 },
7170 nextItemsCount () {
72- return this .filteredItems .length - this .showItemsCount - this .showItemsFirst
71+ return this .filteredItems .length - this .perPage - this .firstShown
7372 },
7473 },
7574 methods: {
7675 showPreviousItems () {
77- this .showItemsFirst -= this .showItemsCount
76+ this .firstShown -= this .perPage
7877 },
7978 showNextItems () {
80- this .showItemsFirst += this .showItemsCount
79+ this .firstShown += this .perPage
8180
8281 // scroll the first scrollable parent to top of the table
8382 let firstScrollableParent = this .$el .parentElement
@@ -92,7 +91,7 @@ export default {
9291 }
9392 },
9493 watch: {
95- filteredItems () { this .showItemsFirst = 0 }
94+ filteredItems () { this .firstShown = 0 }
9695 }
9796}
9897 </script >
0 commit comments