aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-search
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/shared-search')
-rw-r--r--client/src/app/shared/shared-search/advanced-search.model.ts32
1 files changed, 20 insertions, 12 deletions
diff --git a/client/src/app/shared/shared-search/advanced-search.model.ts b/client/src/app/shared/shared-search/advanced-search.model.ts
index 516854a8c..30badc8fa 100644
--- a/client/src/app/shared/shared-search/advanced-search.model.ts
+++ b/client/src/app/shared/shared-search/advanced-search.model.ts
@@ -15,8 +15,8 @@ export class AdvancedSearch {
15 15
16 languageOneOf: string 16 languageOneOf: string
17 17
18 tagsOneOf: string 18 tagsOneOf: string[]
19 tagsAllOf: string 19 tagsAllOf: string[]
20 20
21 durationMin: number // seconds 21 durationMin: number // seconds
22 durationMax: number // seconds 22 durationMax: number // seconds
@@ -37,8 +37,10 @@ export class AdvancedSearch {
37 categoryOneOf?: string 37 categoryOneOf?: string
38 licenceOneOf?: string 38 licenceOneOf?: string
39 languageOneOf?: string 39 languageOneOf?: string
40 tagsOneOf?: string 40
41 tagsAllOf?: string 41 tagsOneOf?: any
42 tagsAllOf?: any
43
42 durationMin?: string 44 durationMin?: string
43 durationMax?: string 45 durationMax?: string
44 sort?: string 46 sort?: string
@@ -55,8 +57,8 @@ export class AdvancedSearch {
55 this.categoryOneOf = options.categoryOneOf || undefined 57 this.categoryOneOf = options.categoryOneOf || undefined
56 this.licenceOneOf = options.licenceOneOf || undefined 58 this.licenceOneOf = options.licenceOneOf || undefined
57 this.languageOneOf = options.languageOneOf || undefined 59 this.languageOneOf = options.languageOneOf || undefined
58 this.tagsOneOf = options.tagsOneOf || undefined 60 this.tagsOneOf = this.intoArray(options.tagsOneOf)
59 this.tagsAllOf = options.tagsAllOf || undefined 61 this.tagsAllOf = this.intoArray(options.tagsAllOf)
60 this.durationMin = parseInt(options.durationMin, 10) 62 this.durationMin = parseInt(options.durationMin, 10)
61 this.durationMax = parseInt(options.durationMax, 10) 63 this.durationMax = parseInt(options.durationMax, 10)
62 64
@@ -69,13 +71,11 @@ export class AdvancedSearch {
69 } 71 }
70 72
71 containsValues () { 73 containsValues () {
72 const exceptions = new Set([ 'sort', 'searchTarget' ])
73
74 const obj = this.toUrlObject() 74 const obj = this.toUrlObject()
75 for (const k of Object.keys(obj)) { 75 for (const k of Object.keys(obj)) {
76 if (this.silentFilters.has(k)) continue 76 if (this.silentFilters.has(k)) continue
77 77
78 if (obj[k] !== undefined && obj[k] !== '') return true 78 if (this.isValidValue(obj[k])) return true
79 } 79 }
80 80
81 return false 81 return false
@@ -127,8 +127,8 @@ export class AdvancedSearch {
127 categoryOneOf: this.intoArray(this.categoryOneOf), 127 categoryOneOf: this.intoArray(this.categoryOneOf),
128 licenceOneOf: this.intoArray(this.licenceOneOf), 128 licenceOneOf: this.intoArray(this.licenceOneOf),
129 languageOneOf: this.intoArray(this.languageOneOf), 129 languageOneOf: this.intoArray(this.languageOneOf),
130 tagsOneOf: this.intoArray(this.tagsOneOf), 130 tagsOneOf: this.tagsOneOf,
131 tagsAllOf: this.intoArray(this.tagsAllOf), 131 tagsAllOf: this.tagsAllOf,
132 durationMin: this.durationMin, 132 durationMin: this.durationMin,
133 durationMax: this.durationMax, 133 durationMax: this.durationMax,
134 sort: this.sort, 134 sort: this.sort,
@@ -143,12 +143,20 @@ export class AdvancedSearch {
143 for (const k of Object.keys(obj)) { 143 for (const k of Object.keys(obj)) {
144 if (this.silentFilters.has(k)) continue 144 if (this.silentFilters.has(k)) continue
145 145
146 if (obj[k] !== undefined && obj[k] !== '') acc++ 146 if (this.isValidValue(obj[k])) acc++
147 } 147 }
148 148
149 return acc 149 return acc
150 } 150 }
151 151
152 private isValidValue (val: any) {
153 if (val === undefined) return false
154 if (val === '') return false
155 if (Array.isArray(val) && val.length === 0) return false
156
157 return true
158 }
159
152 private intoArray (value: any) { 160 private intoArray (value: any) {
153 if (!value) return undefined 161 if (!value) return undefined
154 if (Array.isArray(value)) return value 162 if (Array.isArray(value)) return value