aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/search/advanced-search.model.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-07-24 10:13:54 +0200
committerChocobozzz <me@florianbigard.com>2018-07-24 14:04:05 +0200
commitcddf45035389cc7d9003ea2b64fff3c28cd368d9 (patch)
tree89e1485a34264b6a2d8052c4cc0c179cbfbd8381 /client/src/app/search/advanced-search.model.ts
parent8cd72bd37724054f8942f2fefc7aa2e60eca74cf (diff)
downloadPeerTube-cddf45035389cc7d9003ea2b64fff3c28cd368d9.tar.gz
PeerTube-cddf45035389cc7d9003ea2b64fff3c28cd368d9.tar.zst
PeerTube-cddf45035389cc7d9003ea2b64fff3c28cd368d9.zip
Add ability to sort the search
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}