mirror of
https://github.com/koel/koel
synced 2024-11-24 21:23:06 +00:00
Allow searching specifically in title, album, and artist
This commit is contained in:
parent
f2db3bac89
commit
221579c6e7
1 changed files with 19 additions and 1 deletions
|
@ -103,10 +103,28 @@ export default {
|
|||
|
||||
computed: {
|
||||
filteredItems () {
|
||||
// Allow searching specifically in title, album, and artist
|
||||
const re = /in:(title|album|artist)/ig
|
||||
const fields = []
|
||||
const matches = this.q.match(re)
|
||||
if (matches) {
|
||||
this.q = this.q.replace(re, '').trim()
|
||||
if (!this.q) {
|
||||
return this.songRows
|
||||
}
|
||||
matches.forEach(match => {
|
||||
let field = match.split(':')[1].toLowerCase()
|
||||
if (field !== 'title') {
|
||||
field = `${field}.name`
|
||||
}
|
||||
fields.push(`song.${field}`)
|
||||
})
|
||||
}
|
||||
|
||||
return filterBy(
|
||||
this.songRows,
|
||||
this.q,
|
||||
'song.title', 'song.album.name', 'song.artist.name'
|
||||
...(fields.length ? fields : ['song.title', 'song.album.name', 'song.artist.name'])
|
||||
)
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue