2019-04-03 00:25:12 +02:00
|
|
|
<template lang="pug">
|
2020-07-25 21:41:22 +02:00
|
|
|
v-container
|
|
|
|
v-switch.mt-0(
|
2019-07-23 01:31:43 +02:00
|
|
|
v-if='recurrentFilter && settings.allow_recurrent_event'
|
2020-07-25 21:41:22 +02:00
|
|
|
inset color='primary'
|
|
|
|
:label="$t('event.show_recurrent')"
|
2020-10-17 00:41:21 +02:00
|
|
|
@change="v => $emit('showrecurrent', v)")
|
2020-01-21 15:09:23 +01:00
|
|
|
|
2020-07-25 21:41:22 +02:00
|
|
|
v-switch.mt-0(
|
|
|
|
v-if='pastFilter' inset color='primary'
|
|
|
|
:label="$t('event.show_past')"
|
2020-10-17 00:41:21 +02:00
|
|
|
@change="v => $emit('showpast', v)")
|
2019-05-30 12:04:14 +02:00
|
|
|
|
2020-07-31 01:03:19 +02:00
|
|
|
v-autocomplete.mt-0(
|
2020-10-16 14:47:32 +02:00
|
|
|
:label='$t("common.search")'
|
2020-07-31 01:03:19 +02:00
|
|
|
:items='keywords'
|
2020-10-17 00:41:21 +02:00
|
|
|
@change='change'
|
|
|
|
:value='selectedFilters'
|
|
|
|
clearable
|
2020-07-31 01:03:19 +02:00
|
|
|
:search-input.sync='search'
|
|
|
|
item-text='label'
|
2020-10-17 00:41:21 +02:00
|
|
|
return-object
|
|
|
|
chips single-line
|
2020-10-10 00:40:16 +02:00
|
|
|
multiple)
|
2020-07-31 01:03:19 +02:00
|
|
|
template(v-slot:selection="data")
|
|
|
|
v-chip(v-bind="data.attrs"
|
2020-10-17 00:41:21 +02:00
|
|
|
:input-value="data.selected")
|
2020-07-31 01:03:19 +02:00
|
|
|
v-avatar(left)
|
2020-10-10 00:40:16 +02:00
|
|
|
v-icon {{data.item.type === 'place' ? 'mdi-map-marker' : 'mdi-tag' }}
|
|
|
|
span {{ data.item.label }}
|
2020-07-31 01:03:19 +02:00
|
|
|
template(v-slot:item='{ item }')
|
2020-10-10 00:40:16 +02:00
|
|
|
v-list-item-avatar
|
|
|
|
v-icon {{item.type === 'place' ? 'mdi-map-marker' : 'mdi-tag' }}
|
|
|
|
v-list-item-content
|
|
|
|
v-list-item-title(v-text='item.label')
|
2019-04-03 00:25:12 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-09-11 19:12:24 +02:00
|
|
|
import { mapState, mapActions } from 'vuex'
|
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
|
|
|
pastFilter: { type: Boolean, default: true },
|
|
|
|
recurrentFilter: { type: Boolean, default: true },
|
|
|
|
filters: { type: Object, default: () => {} }
|
2019-06-10 01:25:05 +02:00
|
|
|
},
|
2019-09-11 19:12:24 +02:00
|
|
|
data () {
|
|
|
|
return {
|
2020-10-10 00:40:16 +02:00
|
|
|
tmpfilter: null,
|
2020-01-15 23:33:56 +01:00
|
|
|
search: ''
|
2019-09-11 19:12:24 +02:00
|
|
|
}
|
|
|
|
},
|
2019-04-03 00:25:12 +02:00
|
|
|
computed: {
|
2020-10-17 00:41:21 +02:00
|
|
|
...mapState(['tags', 'places', , 'settings']),
|
|
|
|
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
|
2020-10-10 00:40:16 +02:00
|
|
|
},
|
2019-05-30 12:04:14 +02:00
|
|
|
keywords () {
|
2020-10-17 00:41:21 +02:00
|
|
|
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 }))
|
2020-01-21 01:17:45 +01:00
|
|
|
const keywords = tags.concat(places).sort((a, b) => b.weigth - a.weigth)
|
|
|
|
return keywords
|
2019-05-30 12:04:14 +02:00
|
|
|
},
|
2020-01-15 23:33:56 +01:00
|
|
|
},
|
|
|
|
methods: {
|
2020-10-17 00:41:21 +02:00
|
|
|
change (filters) {
|
|
|
|
filters = {
|
|
|
|
tags: filters.filter(t => t.type === 'tag').map(t => t.id),
|
|
|
|
places: filters.filter(p => p.type === 'place').map(p => p.id)
|
2020-10-16 14:47:32 +02:00
|
|
|
}
|
2020-10-17 00:41:21 +02:00
|
|
|
this.$emit('update', filters)
|
2020-10-16 14:47:32 +02:00
|
|
|
},
|
2019-04-03 00:25:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|