minor on export search

This commit is contained in:
lesion
2022-06-21 22:45:20 +02:00
parent 20524e92c0
commit 5dc183a5b2

View File

@@ -1,43 +1,48 @@
<template lang="pug"> <template lang="pug">
v-container.pt-0.pt-md-2 v-row
v-switch.mt-0( v-col(cols=12)
v-if='settings.allow_recurrent_event' v-switch(
v-model='showRecurrent' v-if='settings.allow_recurrent_event'
inset color='primary' v-model='show_recurrent'
hide-details @change='change'
:label="$t('event.show_recurrent')") inset color='primary'
v-autocomplete( hide-details
v-model='meta' :label="$t('event.show_recurrent')")
:label='$t("common.search")' v-col.mb-4(cols=12)
:filter='filter' v-autocomplete.p-0(
cache-items v-model='meta'
hide-details :label='$t("common.search")'
color='primary' :filter='filter'
hide-selected cache-items
small-chips hide-details
:items='items' color='primary'
@change='change' hide-selected
hide-no-data small-chips
@input.native='search' @focus='search'
item-text='label' :menu-props="{ maxWidth: '400' }"
return-object :items='items'
chips @change='change'
multiple) hide-no-data
template(v-slot:selection="{ attrs, item }") @input.native='search'
v-chip(v-bind="attrs" item-text='label'
small return-object
close chips
@click:close='remove(item)' multiple)
:close-icon='mdiCloseCircle') template(v-slot:selection="{ attrs, item }")
v-avatar(left) v-chip(v-bind="attrs"
v-icon(small v-text="item.type === 'place' ? mdiMapMarker : mdiTag") small
span {{ item.label }} close
template(v-slot:item='{ item }') @click:close='remove(item)'
v-list-item-avatar :close-icon='mdiCloseCircle')
v-icon(v-text="item.type === 'place' ? mdiMapMarker : mdiTag") v-avatar(left)
v-list-item-content v-icon(small v-text="item.type === 'place' ? mdiMapMarker : mdiTag")
v-list-item-title(v-text='item.label') span {{ item.label }}
v-list-item-subtitle(v-if='item.type ==="place"' v-text='item.address') 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')
</template> </template>
<script> <script>
@@ -48,26 +53,17 @@ import debounce from 'lodash/debounce'
export default { export default {
name: 'Search', name: 'Search',
props: { props: {
filters: { type: Object, default: () => ({}) } filters: { type: Object, default: () => ({ }) }
}, },
data () { data () {
return { return {
mdiTag, mdiMapMarker, mdiCloseCircle, mdiTag, mdiMapMarker, mdiCloseCircle,
meta: [], meta: [],
items: [], items: [],
show_recurrent: this.filters.show_recurrent || false
} }
}, },
computed: { computed: mapState(['settings']),
...mapState(['settings']),
showRecurrent: {
get () {
return this.filters.show_recurrent
},
set (v) {
this.change(v)
}
},
},
methods: { methods: {
filter (item, queryText, itemText) { filter (item, queryText, itemText) {
return itemText.toLocaleLowerCase().indexOf(queryText.toLocaleLowerCase()) > -1 || return itemText.toLocaleLowerCase().indexOf(queryText.toLocaleLowerCase()) > -1 ||
@@ -80,11 +76,11 @@ export default {
this.meta = this.meta.filter(m => m.type !== item.type || m.type === 'place' ? m.id !== item.id : m.label !== item.label) this.meta = this.meta.filter(m => m.type !== item.type || m.type === 'place' ? m.id !== item.id : m.label !== item.label)
this.change() this.change()
}, },
change (show_recurrent) { change () {
const filters = { const filters = {
tags: this.meta.filter(t => t.type === 'tag').map(t => t.label), tags: this.meta.filter(t => t.type === 'tag').map(t => t.label),
places: this.meta.filter(p => p.type === 'place').map(p => p.id), places: this.meta.filter(p => p.type === 'place').map(p => p.id),
show_recurrent: typeof show_recurrent !== 'undefined' ? show_recurrent : this.filters.show_recurrent show_recurrent: this.show_recurrent
} }
this.$emit('update', filters) this.$emit('update', filters)
} }