From c9da3b2033bcad340cd1803e3d2f45a2c2f0b6ca Mon Sep 17 00:00:00 2001 From: Joe Wroten Date: Tue, 16 May 2017 06:11:49 -0500 Subject: [PATCH] Moved&Restyled Toolbars, Added Sorting --- src/components/Index.vue | 87 +++++++++++++++++++++++++++--------- src/components/Spelllist.vue | 14 ++++-- 2 files changed, 78 insertions(+), 23 deletions(-) diff --git a/src/components/Index.vue b/src/components/Index.vue index 57003c8..cef9f9b 100644 --- a/src/components/Index.vue +++ b/src/components/Index.vue @@ -1,6 +1,6 @@ @@ -101,7 +114,27 @@ export default { data () { return { state, - search: '' + search: '', + sortBy: 'name', + previousSortBy: 'name', + sortByOptions: [ + { + label: 'Relevance', + value: 'sortScore' + }, + { + label: 'Name', + value: 'name' + }, + { + label: 'Level', + value: 'level' + }, + { + label: 'School', + value: 'school' + } + ] } }, computed: { @@ -134,7 +167,21 @@ export default { }, paste () { console.log('Load Chosen!') + }, + searchChanged (newSearch) { + if (newSearch.length >= 3) { + this.previousSortBy = this.sortBy + this.sortBy = 'sortScore' + } + else { + this.sortBy = this.previousSortBy + } } } } + + diff --git a/src/components/Spelllist.vue b/src/components/Spelllist.vue index 4a87373..988714a 100644 --- a/src/components/Spelllist.vue +++ b/src/components/Spelllist.vue @@ -24,12 +24,12 @@ Vue.component('spell-item', SpellItem) export default { props: [ 'spells', - 'search' + 'search', + 'sortBy' ], data () { return { - loadedPage: 1, - sortBy: 'name' + loadedPage: 1 } }, computed: { @@ -48,9 +48,17 @@ export default { } }, watch: { + sortBy (newSort) { + console.log(newSort) + }, search () { this.loadedPage = 1 } } } + +