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
}
},
mounted () {
this.$nextTick( async () => this.tags = await this.$axios.$get('/tag') )
},
head() {
return {
title: `${this.settings.title} - ${this.$t('common.add_event')}`

View file

@ -72,13 +72,15 @@ module.exports = {
* sorted by usage
*/
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({
order: [[fn('COUNT', col('tag.tag')), 'DESC']],
attributes: ['tag'],
where: {
tag: { [Op.like]: `%${search}%` }
},
where,
include: [{ model: Event, where: { is_visible: true }, attributes: [], through: { attributes: [] }, required: true }],
group: ['tag.tag'],
limit: 10,