mirror of
https://framagit.org/les/gancio.git
synced 2025-01-31 16:42:22 +01:00
fix: show frequent tags by default when filling tags without typing, fix #452
This commit is contained in:
parent
ee12eaf410
commit
ad014db451
2 changed files with 9 additions and 4 deletions
|
@ -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')}`
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Reference in a new issue