2022-05-31 15:22:42 +02:00
|
|
|
<template lang="pug">
|
2022-06-21 22:45:20 +02:00
|
|
|
v-row
|
|
|
|
v-col(cols=12)
|
|
|
|
v-switch(
|
|
|
|
v-if='settings.allow_recurrent_event'
|
|
|
|
v-model='show_recurrent'
|
|
|
|
@change='change'
|
|
|
|
inset color='primary'
|
|
|
|
hide-details
|
|
|
|
:label="$t('event.show_recurrent')")
|
|
|
|
v-col.mb-4(cols=12)
|
|
|
|
v-autocomplete.p-0(
|
|
|
|
v-model='meta'
|
|
|
|
:label='$t("common.search")'
|
|
|
|
:filter='filter'
|
|
|
|
cache-items
|
|
|
|
hide-details
|
|
|
|
color='primary'
|
|
|
|
hide-selected
|
|
|
|
small-chips
|
|
|
|
@focus='search'
|
|
|
|
:menu-props="{ maxWidth: '400' }"
|
|
|
|
:items='items'
|
|
|
|
@change='change'
|
|
|
|
hide-no-data
|
|
|
|
@input.native='search'
|
|
|
|
item-text='label'
|
|
|
|
return-object
|
|
|
|
chips
|
|
|
|
multiple)
|
|
|
|
template(v-slot:selection="{ attrs, item }")
|
|
|
|
v-chip(v-bind="attrs"
|
|
|
|
small
|
|
|
|
close
|
|
|
|
@click:close='remove(item)'
|
|
|
|
:close-icon='mdiCloseCircle')
|
|
|
|
v-avatar(left)
|
|
|
|
v-icon(small v-text="item.type === 'place' ? mdiMapMarker : mdiTag")
|
|
|
|
span {{ item.label }}
|
|
|
|
template(v-slot:item='{ item }')
|
|
|
|
v-list-item-avatar
|
|
|
|
v-icon(v-text="item.type === 'place' ? mdiMapMarker : mdiTag")
|
|
|
|
v-list-item-content
|
|
|
|
v-list-item-title(v-text='item.label')
|
|
|
|
v-list-item-subtitle(v-if='item.type ==="place"' v-text='item.address')
|
2019-04-03 00:25:12 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-11-13 00:13:44 +01:00
|
|
|
import { mapState } from 'vuex'
|
2022-02-21 11:34:27 +01:00
|
|
|
import { mdiMapMarker, mdiTag, mdiCloseCircle } from '@mdi/js'
|
2022-05-31 15:22:42 +02:00
|
|
|
import debounce from 'lodash/debounce'
|
|
|
|
|
2019-04-03 00:25:12 +02:00
|
|
|
export default {
|
2019-09-11 19:12:24 +02:00
|
|
|
name: 'Search',
|
2019-06-10 01:25:05 +02:00
|
|
|
props: {
|
2022-06-21 22:45:20 +02:00
|
|
|
filters: { type: Object, default: () => ({ }) }
|
2019-06-10 01:25:05 +02:00
|
|
|
},
|
2019-09-11 19:12:24 +02:00
|
|
|
data () {
|
|
|
|
return {
|
2022-02-21 11:34:27 +01:00
|
|
|
mdiTag, mdiMapMarker, mdiCloseCircle,
|
2022-05-31 15:22:42 +02:00
|
|
|
meta: [],
|
2022-05-25 10:56:21 +02:00
|
|
|
items: [],
|
2022-06-21 22:45:20 +02:00
|
|
|
show_recurrent: this.filters.show_recurrent || false
|
2020-11-13 00:13:44 +01:00
|
|
|
}
|
2020-01-15 23:33:56 +01:00
|
|
|
},
|
2022-06-21 22:45:20 +02:00
|
|
|
computed: mapState(['settings']),
|
2020-01-15 23:33:56 +01:00
|
|
|
methods: {
|
2022-05-31 15:22:42 +02:00
|
|
|
filter (item, queryText, itemText) {
|
|
|
|
return itemText.toLocaleLowerCase().indexOf(queryText.toLocaleLowerCase()) > -1 ||
|
|
|
|
item.address && item.address.toLocaleLowerCase().indexOf(queryText.toLocaleLowerCase()) > -1
|
|
|
|
},
|
|
|
|
search: debounce(async function(search) {
|
|
|
|
this.items = await this.$axios.$get(`/event/meta?search=${search.target.value}`)
|
|
|
|
}, 100),
|
|
|
|
remove (item) {
|
2022-06-18 01:10:43 +02:00
|
|
|
this.meta = this.meta.filter(m => m.type !== item.type || m.type === 'place' ? m.id !== item.id : m.label !== item.label)
|
2022-05-31 15:22:42 +02:00
|
|
|
this.change()
|
2021-01-11 00:17:56 +01:00
|
|
|
},
|
2022-06-21 22:45:20 +02:00
|
|
|
change () {
|
2022-05-31 15:22:42 +02:00
|
|
|
const filters = {
|
|
|
|
tags: this.meta.filter(t => t.type === 'tag').map(t => t.label),
|
|
|
|
places: this.meta.filter(p => p.type === 'place').map(p => p.id),
|
2022-06-21 22:45:20 +02:00
|
|
|
show_recurrent: this.show_recurrent
|
2022-05-31 15:22:42 +02:00
|
|
|
}
|
|
|
|
this.$emit('update', filters)
|
|
|
|
}
|
2019-04-03 00:25:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|