X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fsearch%2Fadvanced-search.model.ts;h=ce22c3f84e290f39bab31bf43fa8868a796a4862;hb=cddf45035389cc7d9003ea2b64fff3c28cd368d9;hp=aad4367881f8c0f37771114e270cf666822978a5;hpb=7afea880e561196671f186045c94f09511189405;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/search/advanced-search.model.ts b/client/src/app/search/advanced-search.model.ts index aad436788..ce22c3f84 100644 --- a/client/src/app/search/advanced-search.model.ts +++ b/client/src/app/search/advanced-search.model.ts @@ -18,6 +18,8 @@ export class AdvancedSearch { durationMin: number // seconds durationMax: number // seconds + sort: string + constructor (options?: { startDate?: string endDate?: string @@ -29,6 +31,7 @@ export class AdvancedSearch { tagsAllOf?: string durationMin?: string durationMax?: string + sort?: string }) { if (!options) return @@ -45,11 +48,15 @@ export class AdvancedSearch { if (isNaN(this.durationMin)) this.durationMin = undefined if (isNaN(this.durationMax)) this.durationMax = undefined + + this.sort = options.sort || '-match' } containsValues () { const obj = this.toUrlObject() for (const k of Object.keys(obj)) { + if (k === 'sort') continue // Exception + if (obj[k] !== undefined) return true } @@ -67,6 +74,8 @@ export class AdvancedSearch { this.tagsAllOf = undefined this.durationMin = undefined this.durationMax = undefined + + this.sort = '-match' } toUrlObject () { @@ -80,7 +89,8 @@ export class AdvancedSearch { tagsOneOf: this.tagsOneOf, tagsAllOf: this.tagsAllOf, durationMin: this.durationMin, - durationMax: this.durationMax + durationMax: this.durationMax, + sort: this.sort } } @@ -95,7 +105,8 @@ export class AdvancedSearch { tagsOneOf: this.tagsOneOf ? this.tagsOneOf.split(',') : undefined, tagsAllOf: this.tagsAllOf ? this.tagsAllOf.split(',') : undefined, durationMin: this.durationMin, - durationMax: this.durationMax + durationMax: this.durationMax, + sort: this.sort } } }