avoid tag duplication

This commit is contained in:
lesion 2022-05-05 11:10:35 +02:00
parent 3c96e9d25e
commit 65b676b5f1
No known key found for this signature in database
GPG key ID: 352918250B012177
2 changed files with 13 additions and 3 deletions

View file

@ -51,8 +51,10 @@
v-combobox(v-model='event.tags' v-combobox(v-model='event.tags'
:prepend-icon="mdiTagMultiple" :prepend-icon="mdiTagMultiple"
chips small-chips multiple deletable-chips hide-no-data hide-selected persistent-hint chips small-chips multiple deletable-chips hide-no-data hide-selected persistent-hint
no-filter
:search-input.sync="tagName"
:delimiters="[',', ';']" :delimiters="[',', ';']"
:items="tags.map(t => t.tag)" :items="filteredTags"
:label="$t('common.tags')") :label="$t('common.tags')")
template(v-slot:selection="{ item, on, attrs, selected, parent}") template(v-slot:selection="{ item, on, attrs, selected, parent}")
v-chip(v-bind="attrs" close :close-icon='mdiCloseCircle' @click:close='parent.selectItem(item)' v-chip(v-bind="attrs" close :close-icon='mdiCloseCircle' @click:close='parent.selectItem(item)'
@ -131,6 +133,7 @@ export default {
tags: [], tags: [],
media: [] media: []
}, },
tagName: '',
page: { month, year }, page: { month, year },
fileList: [], fileList: [],
id: null, id: null,
@ -145,7 +148,14 @@ export default {
title: `${this.settings.title} - ${this.$t('common.add_event')}` title: `${this.settings.title} - ${this.$t('common.add_event')}`
} }
}, },
computed: mapState(['tags', 'places', 'settings']), computed: {
...mapState(['tags', 'settings']),
filteredTags () {
if (!this.tagName) { return this.tags.slice(0, 10).map(t => t.tag) }
const tagName = this.tagName.trim().toLowerCase()
return this.tags.filter(t => t.tag.toLowerCase().includes(tagName)).map(t => t.tag)
}
},
methods: { methods: {
...mapActions(['updateMeta']), ...mapActions(['updateMeta']),
eventImported (event) { eventImported (event) {

View file

@ -10,7 +10,7 @@ v-container#home(fluid)
#calh.col-xl-5.col-lg-5.col-md-7.col-sm-12.col-xs-12.pa-4.pa-sm-3 #calh.col-xl-5.col-lg-5.col-md-7.col-sm-12.col-xs-12.pa-4.pa-sm-3
//- this is needed as v-calendar does not support SSR //- this is needed as v-calendar does not support SSR
//- https://github.com/nathanreyes/v-calendar/issues/336 //- https://github.com/nathanreyes/v-calendar/issues/336
client-only(placeholder='Calendar unavailable without js') client-only(placeholder='Loading...')
Calendar(@dayclick='dayChange' @monthchange='monthChange' :events='filteredEvents') Calendar(@dayclick='dayChange' @monthchange='monthChange' :events='filteredEvents')
.col.pt-0.pt-md-2 .col.pt-0.pt-md-2