feat: simplify filter-popup
continuous-integration/drone/pr Build is failing Details

This commit is contained in:
Dominik Pschenitschni 2021-10-01 20:14:21 +02:00
parent 8d88b3792d
commit 15640e98ec
Signed by: dpschen
GPG Key ID: B257AC0149F43A77
5 changed files with 33 additions and 27 deletions

View File

@ -1,9 +1,8 @@
<template>
<transition name="fade">
<filters
@change="change"
v-if="visibleInternal"
v-model="params"
v-model="value"
ref="filters"
/>
</transition>
@ -15,15 +14,33 @@ import Filters from '../../../components/list/partials/filters'
export default {
name: 'filter-popup',
emits: ['update:modelValue', 'change'],
components: {
Filters,
},
props: {
modelValue: {
required: true,
},
visible: {
type: Boolean,
default: false,
},
},
emits: ['update:modelValue'],
data() {
return {
params: null,
visibleInternal: false,
}
},
components: {
Filters,
computed: {
value: {
get() {
return this.modelValue
},
set(value) {
this.$emit('update:modelValue', value)
},
},
},
mounted() {
document.addEventListener('click', this.hidePopup)
@ -42,26 +59,15 @@ export default {
this.visibleInternal = !this.visibleInternal
},
},
props: {
modelValue: {
required: true,
},
visible: {
type: Boolean,
default: false,
},
},
methods: {
change() {
this.$emit('change', this.params)
this.$emit('update:modelValue', this.params)
},
hidePopup(e) {
if (this.visibleInternal) {
closeWhenClickedOutside(e, this.$refs.filters.$el, () => {
this.visibleInternal = false
})
if (!this.visibleInternal) {
return
}
closeWhenClickedOutside(e, this.$refs.filters.$el, () => {
this.visibleInternal = false
})
},
},
}

View File

@ -11,9 +11,9 @@
</x-button>
</div>
<filter-popup
@change="loadTasks()"
:visible="showTaskFilter"
v-model="params"
@update:modelValue="loadTasks()"
/>
</div>
<div class="dates">

View File

@ -11,7 +11,7 @@
</x-button>
</div>
<filter-popup
@change="() => {filtersChanged = true; loadBuckets()}"
@update:modelValue="() => {filtersChanged = true; loadBuckets()}"
:visible="showFilters"
v-model="params"
/>

View File

@ -50,9 +50,9 @@
</x-button>
</div>
<filter-popup
@change="loadTasks(1)"
:visible="showTaskFilter"
v-model="params"
@update:modelValue="loadTasks(1)"
/>
</div>

View File

@ -59,9 +59,9 @@
</card>
</transition>
<filter-popup
@change="loadTasks(1)"
:visible="showTaskFilter"
v-model="params"
@update:modelValue="loadTasks(1)"
/>
</div>