UI: add support for year specification in search

This commit is contained in:
ducklet 2021-08-07 14:32:32 +02:00
parent 181719c6d9
commit f964c0ceb9

View file

@ -170,6 +170,14 @@ type User = {
groups: Array<{ id: ULID }>
}
function parse_query(query) {
const match = /^(.*?)(?:\s+([<=>])?(\d+|\(\d+\)))?$/.exec(query)
const title = match[1].replaceAll('"', "")
const comp = match[2] || ""
const year = match[3] ? /\d+/.exec(match[3])[0] : ""
return { title, year: year ? `${comp}${year}` : null }
}
export default defineComponent({
data: () => ({
query: "",
@ -213,10 +221,12 @@ export default defineComponent({
const media_type = this.media_type === "" ? null : this.media_type
const user_id = (this.filter_group === "" && this.credentials.user_id) || null
const group_id = user_id === null && this.filter_group ? this.filter_group : null
const { title, year } = parse_query(this.query)
const more = await debounced_get(
"movies",
{
title: this.query,
title,
year,
per_page,
include_unrated: true,
page: this.page,