gancio-upstream/components/Search.vue

116 lines
3.9 KiB
Vue
Raw Normal View History

<template>
<v-container class='pt-0.pt-md-2'>
<!-- <v-switch class='mt-0'
2019-07-23 01:31:43 +02:00
v-if='recurrentFilter && settings.allow_recurrent_event'
2021-04-30 00:27:41 +02:00
v-model='showRecurrent'
2020-07-25 21:41:22 +02:00
inset color='primary'
2021-02-09 12:10:33 +01:00
hide-details
:label="$t('event.show_recurrent')"/> -->
<v-combobox
2020-10-16 14:47:32 +02:00
:label='$t("common.search")'
:items='items'
no-filter
@input='input'
2021-02-09 12:10:33 +01:00
hide-details
:menu-props="{ maxWidth: '400' }"
:search-input.sync='search'>
<!-- <template v-slot:selection="{ item, on, attrs, selected, parent}">
<span>{{selected}}</span>
</template> -->
<!-- template(v-slot:selection="data")
2020-07-31 01:03:19 +02:00
v-chip(v-bind="data.attrs"
2020-12-04 17:25:31 +01:00
close
2022-02-21 11:34:27 +01:00
:close-icon='mdiCloseCircle'
2020-12-04 17:25:31 +01:00
@click:close='remove(data.item)'
2020-10-17 00:41:21 +02:00
:input-value="data.selected")
2020-07-31 01:03:19 +02:00
v-avatar(left)
v-icon(v-text="data.item.type === 'place' ? mdiMapMarker : mdiTag")
span {{ data.item.label }} -->
<template v-slot:item='{ item }' >
<v-list-item-avatar v-if="['place','tag'].includes(item.type)">
<v-icon small v-text="item.type === 'place' ? mdiMapMarker : mdiTag" />
</v-list-item-avatar>
<v-list-item-content v-if="item.type === 'event'">
<v-list-item-title v-text='item.title'/>
<v-list-item-subtitle>{{item.start_datetime | from}} @{{item.place.name}}</v-list-item-subtitle>
</v-list-item-content>
<v-list-item-title v-else-if='item.type==="tag"' v-text='item.tag' />
<v-list-item-title v-else-if='item.type==="place"' v-text='item.name' />
</template>
</v-combobox>
</v-container>
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'
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: {
2020-10-17 00:41:21 +02:00
recurrentFilter: { type: Boolean, default: true },
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,
item: '',
items: [],
2020-01-15 23:33:56 +01:00
search: ''
2019-09-11 19:12:24 +02:00
}
},
watch: {
async search (search) {
if (!search) return
this.items = await this.$axios.$get('/event/search', { params: { search } })
2020-11-13 00:13:44 +01:00
}
2020-01-15 23:33:56 +01:00
},
computed: {
...mapState(['settings']),
// showRecurrent: {
// get () {
// return this.filters.show_recurrent
// },
// set (v) {
// const filters = {
// tags: this.filters.tags,
// places: this.filters.places,
// show_recurrent: v
// }
// this.$emit('update', filters)
// }
// },
// selectedFilters () {
// const tags = this.tags.filter(t => this.filters.tags.includes(t.tag)).map(t => ({ type: 'tag', label: t.tag, weigth: t.weigth, id: t.tag }))
// const places = this.places.filter(p => this.filters.places.includes(p.id))
// .map(p => ({ type: 'place', label: p.name, weigth: p.weigth, id: p.id }))
// const keywords = tags.concat(places).sort((a, b) => b.weigth - a.weigth)
// return keywords
// },
// keywords () {
// const tags = this.tags.map(t => ({ type: 'tag', label: t.tag, weigth: t.weigth, id: t.tag }))
// const places = this.places.map(p => ({ type: 'place', label: p.name, weigth: p.weigth, id: p.id }))
// const keywords = tags.concat(places).sort((a, b) => b.weigth - a.weigth)
// return keywords
// }
},
2020-01-15 23:33:56 +01:00
methods: {
// remove (item) {
// const filters = {
// tags: item.type === 'tag' ? this.filters.tags.filter(f => f !== item.id) : this.filters.tags,
// places: item.type === 'place' ? this.filters.places.filter(f => f !== item.id) : this.filters.places,
// show_recurrent: this.filters.show_recurrent
// }
// this.$emit('update', filters)
// },
input (item) {
if (typeof item ==='object') {
this.$emit(`${item.type}:selected`, item)
} else {
this.$emit('update', item)
2021-01-11 00:17:56 +01:00
}
},
2019-04-03 00:25:12 +02:00
}
}
</script>