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.ts21
1 files changed, 17 insertions, 4 deletions
diff --git a/client/src/app/search/advanced-search.model.ts b/client/src/app/search/advanced-search.model.ts
index 50f00bc27..643cc9a29 100644
--- a/client/src/app/search/advanced-search.model.ts
+++ b/client/src/app/search/advanced-search.model.ts
@@ -1,3 +1,4 @@
1import { SearchTargetType } from '@shared/models/search/search-target-query.model'
1import { NSFWQuery } from '../../../../shared/models/search' 2import { NSFWQuery } from '../../../../shared/models/search'
2 3
3export class AdvancedSearch { 4export class AdvancedSearch {
@@ -23,6 +24,11 @@ export class AdvancedSearch {
23 24
24 sort: string 25 sort: string
25 26
27 searchTarget: SearchTargetType
28
29 // Filters we don't want to count, because they are mandatory
30 private silentFilters = new Set([ 'sort', 'searchTarget' ])
31
26 constructor (options?: { 32 constructor (options?: {
27 startDate?: string 33 startDate?: string
28 endDate?: string 34 endDate?: string
@@ -37,6 +43,7 @@ export class AdvancedSearch {
37 durationMin?: string 43 durationMin?: string
38 durationMax?: string 44 durationMax?: string
39 sort?: string 45 sort?: string
46 searchTarget?: SearchTargetType
40 }) { 47 }) {
41 if (!options) return 48 if (!options) return
42 49
@@ -54,6 +61,8 @@ export class AdvancedSearch {
54 this.durationMin = parseInt(options.durationMin, 10) 61 this.durationMin = parseInt(options.durationMin, 10)
55 this.durationMax = parseInt(options.durationMax, 10) 62 this.durationMax = parseInt(options.durationMax, 10)
56 63
64 this.searchTarget = options.searchTarget || undefined
65
57 if (isNaN(this.durationMin)) this.durationMin = undefined 66 if (isNaN(this.durationMin)) this.durationMin = undefined
58 if (isNaN(this.durationMax)) this.durationMax = undefined 67 if (isNaN(this.durationMax)) this.durationMax = undefined
59 68
@@ -61,9 +70,11 @@ export class AdvancedSearch {
61 } 70 }
62 71
63 containsValues () { 72 containsValues () {
73 const exceptions = new Set([ 'sort', 'searchTarget' ])
74
64 const obj = this.toUrlObject() 75 const obj = this.toUrlObject()
65 for (const k of Object.keys(obj)) { 76 for (const k of Object.keys(obj)) {
66 if (k === 'sort') continue // Exception 77 if (this.silentFilters.has(k)) continue
67 78
68 if (obj[k] !== undefined && obj[k] !== '') return true 79 if (obj[k] !== undefined && obj[k] !== '') return true
69 } 80 }
@@ -102,7 +113,8 @@ export class AdvancedSearch {
102 tagsAllOf: this.tagsAllOf, 113 tagsAllOf: this.tagsAllOf,
103 durationMin: this.durationMin, 114 durationMin: this.durationMin,
104 durationMax: this.durationMax, 115 durationMax: this.durationMax,
105 sort: this.sort 116 sort: this.sort,
117 searchTarget: this.searchTarget
106 } 118 }
107 } 119 }
108 120
@@ -120,7 +132,8 @@ export class AdvancedSearch {
120 tagsAllOf: this.intoArray(this.tagsAllOf), 132 tagsAllOf: this.intoArray(this.tagsAllOf),
121 durationMin: this.durationMin, 133 durationMin: this.durationMin,
122 durationMax: this.durationMax, 134 durationMax: this.durationMax,
123 sort: this.sort 135 sort: this.sort,
136 searchTarget: this.searchTarget
124 } 137 }
125 } 138 }
126 139
@@ -129,7 +142,7 @@ export class AdvancedSearch {
129 142
130 const obj = this.toUrlObject() 143 const obj = this.toUrlObject()
131 for (const k of Object.keys(obj)) { 144 for (const k of Object.keys(obj)) {
132 if (k === 'sort') continue // Exception 145 if (this.silentFilters.has(k)) continue
133 146
134 if (obj[k] !== undefined && obj[k] !== '') acc++ 147 if (obj[k] !== undefined && obj[k] !== '') acc++
135 } 148 }