forked from vikunja/frontend
78 lines
1.4 KiB
Vue
78 lines
1.4 KiB
Vue
<template>
|
|
<x-button
|
|
v-if="hasFilters"
|
|
type="secondary"
|
|
@click="clearFilters"
|
|
>
|
|
{{ $t('filters.clear') }}
|
|
</x-button>
|
|
<popup>
|
|
<template #trigger="{toggle}">
|
|
<x-button
|
|
@click.prevent.stop="toggle()"
|
|
type="secondary"
|
|
icon="filter"
|
|
>
|
|
{{ $t('filters.title') }}
|
|
</x-button>
|
|
</template>
|
|
<template #default>
|
|
<filters
|
|
v-model="value"
|
|
ref="filters"
|
|
/>
|
|
</template>
|
|
</popup>
|
|
</template>
|
|
|
|
<script>
|
|
import Filters from '../../../components/list/partials/filters'
|
|
import {getDefaultParams} from '../../tasks/mixins/taskList'
|
|
import Popup from '../../misc/popup'
|
|
|
|
export default {
|
|
name: 'filter-popup',
|
|
components: {
|
|
Popup,
|
|
Filters,
|
|
},
|
|
props: {
|
|
modelValue: {
|
|
required: true,
|
|
},
|
|
},
|
|
emits: ['update:modelValue'],
|
|
computed: {
|
|
value: {
|
|
get() {
|
|
return this.modelValue
|
|
},
|
|
set(value) {
|
|
this.$emit('update:modelValue', value)
|
|
},
|
|
},
|
|
hasFilters() {
|
|
// this.value also contains the page parameter which we don't want to include in filters
|
|
// eslint-disable-next-line no-unused-vars
|
|
const {page, ...value} = this.value
|
|
const def = {...getDefaultParams()}
|
|
|
|
return JSON.stringify(value) !== JSON.stringify(def)
|
|
},
|
|
},
|
|
watch: {
|
|
modelValue: {
|
|
handler(value) {
|
|
this.value = value
|
|
},
|
|
immediate: true,
|
|
},
|
|
},
|
|
methods: {
|
|
clearFilters() {
|
|
this.value = {...getDefaultParams()}
|
|
},
|
|
},
|
|
}
|
|
</script>
|