1
0
Fork 0

Moved&Restyled Toolbars, Added Sorting

This commit is contained in:
Joe Wroten 2017-05-16 06:11:49 -05:00
parent b49a04869a
commit c9da3b2033
2 changed files with 78 additions and 23 deletions

View file

@ -1,6 +1,6 @@
<template> <template>
<q-layout> <q-layout>
<div slot="header" class="toolbar"> <div slot="header" class="toolbar dark">
<q-toolbar-title :padding="0"> <q-toolbar-title :padding="0">
My Spells v2.0 My Spells v2.0
</q-toolbar-title> </q-toolbar-title>
@ -26,25 +26,18 @@
</button> </button>
</div> </div>
<div slot="header" class="toolbar primary"> <div slot="header" class="toolbar dark">
<q-search <q-select
class="primary" type="list"
v-model="search" v-model="sortBy"
></q-search> :options="sortByOptions"
</div> ></q-select>
<div slot="header" class="toolbar primary"> <q-search
<q-tabs class="dark"
:refs="$refs" v-model="search"
default-tab="tab-all" @input="searchChanged"
> ></q-search>
<q-tab name="tab-all" icon="local_library">
All Spells
</q-tab>
<q-tab name="tab-my" icon="bookmark">
My Spells
</q-tab>
</q-tabs>
</div> </div>
<div class="layout-view"> <div class="layout-view">
@ -52,6 +45,7 @@
<spell-list <spell-list
:spells="state.spells.data" :spells="state.spells.data"
:search="search" :search="search"
:sortBy="sortBy"
></spell-list> ></spell-list>
</section> </section>
@ -60,11 +54,30 @@
v-if="mySpells.length" v-if="mySpells.length"
:spells="mySpells" :spells="mySpells"
:search="search" :search="search"
:sortBy="sortBy"
></spell-list> ></spell-list>
<div v-else>None :D</div> <div v-else>None :D</div>
</section> </section>
</div> </div>
<footer slot="footer" class="toolbar pink">
<q-tabs
class="pink justified"
:refs="$refs"
default-tab="tab-all"
>
<q-tab name="tab-all" icon="local_library">
All Spells
</q-tab>
<q-tab name="tab-my" icon="bookmark">
My Spells
<span
class="label pointing-left bg-yellow text-dark"
v-show="mySpells.length"
>{{mySpells.length}}</span>
</q-tab>
</q-tabs>
</footer>
</q-layout> </q-layout>
</template> </template>
@ -101,7 +114,27 @@ export default {
data () { data () {
return { return {
state, 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: { computed: {
@ -134,7 +167,21 @@ export default {
}, },
paste () { paste () {
console.log('Load Chosen!') console.log('Load Chosen!')
},
searchChanged (newSearch) {
if (newSearch.length >= 3) {
this.previousSortBy = this.sortBy
this.sortBy = 'sortScore'
}
else {
this.sortBy = this.previousSortBy
}
} }
} }
} }
</script> </script>
<style scoped lang="stylus">
footer .q-tabs
width: 100%
</style>

View file

@ -24,12 +24,12 @@ Vue.component('spell-item', SpellItem)
export default { export default {
props: [ props: [
'spells', 'spells',
'search' 'search',
'sortBy'
], ],
data () { data () {
return { return {
loadedPage: 1, loadedPage: 1
sortBy: 'name'
} }
}, },
computed: { computed: {
@ -48,9 +48,17 @@ export default {
} }
}, },
watch: { watch: {
sortBy (newSort) {
console.log(newSort)
},
search () { search () {
this.loadedPage = 1 this.loadedPage = 1
} }
} }
} }
</script> </script>
<style lang="stylus">
.toolbar > .q-picker-textfield
margin: 0 .75em
</style>