fix: show frequent tags by default when filling tags without typing, fix #452

This commit is contained in:
lesion 2024-09-18 15:45:08 +02:00
parent ee12eaf410
commit ad014db451
No known key found for this signature in database
GPG key ID: 352918250B012177
2 changed files with 9 additions and 4 deletions

View file

@ -177,6 +177,9 @@ export default {
disableAddress: false disableAddress: false
} }
}, },
mounted () {
this.$nextTick( async () => this.tags = await this.$axios.$get('/tag') )
},
head() { head() {
return { return {
title: `${this.settings.title} - ${this.$t('common.add_event')}` title: `${this.settings.title} - ${this.$t('common.add_event')}`

View file

@ -72,13 +72,15 @@ module.exports = {
* sorted by usage * sorted by usage
*/ */
async search (req, res) { async search (req, res) {
const search = req.query.search const search = req?.query?.search
let where = { }
if (search) {
where = { tag: { [Op.like]: `%${search}%` } }
}
const tags = await Tag.findAll({ const tags = await Tag.findAll({
order: [[fn('COUNT', col('tag.tag')), 'DESC']], order: [[fn('COUNT', col('tag.tag')), 'DESC']],
attributes: ['tag'], attributes: ['tag'],
where: { where,
tag: { [Op.like]: `%${search}%` }
},
include: [{ model: Event, where: { is_visible: true }, attributes: [], through: { attributes: [] }, required: true }], include: [{ model: Event, where: { is_visible: true }, attributes: [], through: { attributes: [] }, required: true }],
group: ['tag.tag'], group: ['tag.tag'],
limit: 10, limit: 10,