This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
frontend/src/components/list/partials/filter-popup.vue

75 lines
1.2 KiB
Vue
Raw Normal View History

<template>
<transition name="fade">
<filters
v-if="visibleInternal"
2021-10-01 18:14:21 +00:00
v-model="value"
ref="filters"
/>
</transition>
</template>
<script>
import {closeWhenClickedOutside} from '@/helpers/closeWhenClickedOutside'
import Filters from '../../../components/list/partials/filters'
export default {
name: 'filter-popup',
2021-10-01 18:14:21 +00:00
components: {
Filters,
},
props: {
modelValue: {
required: true,
},
visible: {
type: Boolean,
default: false,
},
},
emits: ['update:modelValue'],
data() {
return {
visibleInternal: false,
}
},
2021-10-01 18:14:21 +00:00
computed: {
value: {
get() {
return this.modelValue
},
set(value) {
this.$emit('update:modelValue', value)
},
},
},
mounted() {
document.addEventListener('click', this.hidePopup)
},
2021-08-19 19:36:09 +00:00
beforeUnmount() {
document.removeEventListener('click', this.hidePopup)
},
watch: {
modelValue: {
handler(value) {
this.params = value
},
immediate: true,
},
visible() {
this.visibleInternal = !this.visibleInternal
},
},
methods: {
hidePopup(e) {
2021-10-01 18:14:21 +00:00
if (!this.visibleInternal) {
return
}
2021-10-01 18:14:21 +00:00
closeWhenClickedOutside(e, this.$refs.filters.$el, () => {
this.visibleInternal = false
})
},
},
}
</script>