Skip to content

Instantly share code, notes, and snippets.

@smolinari
Created April 5, 2020 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smolinari/b77cbed244802e1ca409a8602e440724 to your computer and use it in GitHub Desktop.
Save smolinari/b77cbed244802e1ca409a8602e440724 to your computer and use it in GitHub Desktop.
<template>
<div class="q-pa-sm text-center">
<q-btn
color="primary"
v-for="(filter, index) in filters"
:flat="!filter.active"
:key="index"
@click="setFilter(filter.name)"
>
{{ filter.label }}
</q-btn>
<p v-if="error">There has been an error<br>{{error}}</p>
</div>
</template>
<script>
import { queries, mutations } from 'src/graphql/Todos'
export default {
name: 'FilterBar',
data () {
return {
filters: [],
error: ''
}
},
apollo: {
filters: queries.getFilters
},
methods: {
setFilter (filterName) {
this.$apollo.mutate({
mutation: mutations.setActiveFilter,
variables: {
name: filterName
}
}).catch((error) => {
this.error = error
})
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment