aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/search/advanced-search.model.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/search/advanced-search.model.ts')
-rw-r--r--client/src/app/search/advanced-search.model.ts15
1 files changed, 13 insertions, 2 deletions
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 {
18 durationMin: number // seconds 18 durationMin: number // seconds
19 durationMax: number // seconds 19 durationMax: number // seconds
20 20
21 sort: string
22
21 constructor (options?: { 23 constructor (options?: {
22 startDate?: string 24 startDate?: string
23 endDate?: string 25 endDate?: string
@@ -29,6 +31,7 @@ export class AdvancedSearch {
29 tagsAllOf?: string 31 tagsAllOf?: string
30 durationMin?: string 32 durationMin?: string
31 durationMax?: string 33 durationMax?: string
34 sort?: string
32 }) { 35 }) {
33 if (!options) return 36 if (!options) return
34 37
@@ -45,11 +48,15 @@ export class AdvancedSearch {
45 48
46 if (isNaN(this.durationMin)) this.durationMin = undefined 49 if (isNaN(this.durationMin)) this.durationMin = undefined
47 if (isNaN(this.durationMax)) this.durationMax = undefined 50 if (isNaN(this.durationMax)) this.durationMax = undefined
51
52 this.sort = options.sort || '-match'
48 } 53 }
49 54
50 containsValues () { 55 containsValues () {
51 const obj = this.toUrlObject() 56 const obj = this.toUrlObject()
52 for (const k of Object.keys(obj)) { 57 for (const k of Object.keys(obj)) {
58 if (k === 'sort') continue // Exception
59
53 if (obj[k] !== undefined) return true 60 if (obj[k] !== undefined) return true
54 } 61 }
55 62
@@ -67,6 +74,8 @@ export class AdvancedSearch {
67 this.tagsAllOf = undefined 74 this.tagsAllOf = undefined
68 this.durationMin = undefined 75 this.durationMin = undefined
69 this.durationMax = undefined 76 this.durationMax = undefined
77
78 this.sort = '-match'
70 } 79 }
71 80
72 toUrlObject () { 81 toUrlObject () {
@@ -80,7 +89,8 @@ export class AdvancedSearch {
80 tagsOneOf: this.tagsOneOf, 89 tagsOneOf: this.tagsOneOf,
81 tagsAllOf: this.tagsAllOf, 90 tagsAllOf: this.tagsAllOf,
82 durationMin: this.durationMin, 91 durationMin: this.durationMin,
83 durationMax: this.durationMax 92 durationMax: this.durationMax,
93 sort: this.sort
84 } 94 }
85 } 95 }
86 96
@@ -95,7 +105,8 @@ export class AdvancedSearch {
95 tagsOneOf: this.tagsOneOf ? this.tagsOneOf.split(',') : undefined, 105 tagsOneOf: this.tagsOneOf ? this.tagsOneOf.split(',') : undefined,
96 tagsAllOf: this.tagsAllOf ? this.tagsAllOf.split(',') : undefined, 106 tagsAllOf: this.tagsAllOf ? this.tagsAllOf.split(',') : undefined,
97 durationMin: this.durationMin, 107 durationMin: this.durationMin,
98 durationMax: this.durationMax 108 durationMax: this.durationMax,
109 sort: this.sort
99 } 110 }
100 } 111 }
101} 112}