1
0
Fork 0

Basic sorting

This commit is contained in:
Joe Wroten 2017-05-12 16:30:07 -05:00
parent 5a9ae69368
commit 16ca3af64b

View file

@ -77,13 +77,13 @@ export default {
} }
}, },
computed: { computed: {
dynamicSortBy () {
return this.search.length >= 3 ? 'sortScore' : this.sortBy
},
pageMax () { pageMax () {
let trueMax = this.filteredSpells.length / this.perPage let trueMax = this.filteredSpells.length / this.perPage
return trueMax < 1 ? 1 : trueMax return trueMax < 1 ? 1 : trueMax
}, },
dynamicSortBy () {
return this.search.length >= 3 ? 'sortScore' : 'name'
},
pagedSpells () { pagedSpells () {
return new Query(this.filteredSpells) return new Query(this.filteredSpells)
.paginate(this.page, this.perPage) .paginate(this.page, this.perPage)
@ -92,7 +92,7 @@ export default {
filteredSpells () { filteredSpells () {
return new Query(this.spells) return new Query(this.spells)
.search('name', this.search, 5) .search('name', this.search, 5)
.sort(this.dynamicSortBy) .sort(this.sortBy)
.results .results
} }
} }