1
0
Fork 0

Moved pagination functionality to query.js

This commit is contained in:
Joe Wroten 2017-05-10 16:27:27 -05:00
parent b7ba325a60
commit 513af3a56b
2 changed files with 9 additions and 4 deletions

View file

@ -50,7 +50,7 @@
<script>
import Vue from 'vue'
// import Query from '../query'
import Query from '../query'
import SpellItem from './Spellitem'
Vue.component('spell-item', SpellItem)
@ -62,9 +62,8 @@ export default {
return trueMax < 1 ? 1 : trueMax
},
pagedSpells () {
let min = this.page * this.perPage - this.perPage
let max = min + this.perPage
return this.sortedSpells.slice(min, max)
return new Query(this.sortedSpells)
.paginate(this.page, this.perPage)
},
sortedSpells () {
return this.spells

View file

@ -30,4 +30,10 @@ export default class Query {
})
return this
}
paginate (page = 1, perPage = 10) {
let min = page * perPage - perPage
let max = min + perPage
return this.data.slice(min, max)
}
}