Moved pagination functionality to query.js
This commit is contained in:
parent
b7ba325a60
commit
513af3a56b
2 changed files with 9 additions and 4 deletions
|
@ -50,7 +50,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
// import Query from '../query'
|
import Query from '../query'
|
||||||
import SpellItem from './Spellitem'
|
import SpellItem from './Spellitem'
|
||||||
|
|
||||||
Vue.component('spell-item', SpellItem)
|
Vue.component('spell-item', SpellItem)
|
||||||
|
@ -62,9 +62,8 @@ export default {
|
||||||
return trueMax < 1 ? 1 : trueMax
|
return trueMax < 1 ? 1 : trueMax
|
||||||
},
|
},
|
||||||
pagedSpells () {
|
pagedSpells () {
|
||||||
let min = this.page * this.perPage - this.perPage
|
return new Query(this.sortedSpells)
|
||||||
let max = min + this.perPage
|
.paginate(this.page, this.perPage)
|
||||||
return this.sortedSpells.slice(min, max)
|
|
||||||
},
|
},
|
||||||
sortedSpells () {
|
sortedSpells () {
|
||||||
return this.spells
|
return this.spells
|
||||||
|
|
|
@ -30,4 +30,10 @@ export default class Query {
|
||||||
})
|
})
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
paginate (page = 1, perPage = 10) {
|
||||||
|
let min = page * perPage - perPage
|
||||||
|
let max = min + perPage
|
||||||
|
return this.data.slice(min, max)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue