diff options
author | Chocobozzz <me@florianbigard.com> | 2020-08-11 09:22:42 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-08-11 09:41:55 +0200 |
commit | 9abd170dec9a0b929da1f0947e3c7019e38631da (patch) | |
tree | d43418b375d306dcf96af1e9c2f8b6a6775e6e22 | |
parent | 02c01341f4dae30ec6b81fcb644952393d73c4a8 (diff) | |
download | PeerTube-9abd170dec9a0b929da1f0947e3c7019e38631da.tar.gz PeerTube-9abd170dec9a0b929da1f0947e3c7019e38631da.tar.zst PeerTube-9abd170dec9a0b929da1f0947e3c7019e38631da.zip |
Fix tags in search filters
12 files changed, 59 insertions, 40 deletions
diff --git a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-edit.component.html b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-edit.component.html index e61509efd..56060359a 100644 --- a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-edit.component.html +++ b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-edit.component.html | |||
@@ -68,13 +68,10 @@ | |||
68 | 68 | ||
69 | <div class="form-group"> | 69 | <div class="form-group"> |
70 | <label i18n>Channel</label> | 70 | <label i18n>Channel</label> |
71 | <div class="peertube-select-container"> | 71 | |
72 | <select formControlName="videoChannelId" class="form-control"> | 72 | <my-select-channel |
73 | <option i18n value="undefined" disabled>Channel to bind the playlist to</option> | 73 | labelForId="videoChannelIdl" [items]="userVideoChannels" formControlName="videoChannelId" |
74 | <option></option> | 74 | ></my-select-channel> |
75 | <option *ngFor="let channel of userVideoChannels" [value]="channel.id">{{ channel.label }}</option> | ||
76 | </select> | ||
77 | </div> | ||
78 | 75 | ||
79 | <div *ngIf="formErrors['videoChannelId']" class="form-error"> | 76 | <div *ngIf="formErrors['videoChannelId']" class="form-error"> |
80 | {{ formErrors['videoChannelId'] }} | 77 | {{ formErrors['videoChannelId'] }} |
diff --git a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-edit.ts b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-edit.ts index 7ae8de75e..94a0f6168 100644 --- a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-edit.ts +++ b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-edit.ts | |||
@@ -1,11 +1,12 @@ | |||
1 | import { FormReactive } from '@app/shared/shared-forms' | 1 | import { FormReactive } from '@app/shared/shared-forms' |
2 | import { SelectChannelItem } from '@app/shared/shared-forms/select-channel.component' | ||
2 | import { VideoConstant, VideoPlaylistPrivacy } from '@shared/models' | 3 | import { VideoConstant, VideoPlaylistPrivacy } from '@shared/models' |
3 | import { VideoPlaylist } from '@shared/models/videos/playlist/video-playlist.model' | 4 | import { VideoPlaylist } from '@shared/models/videos/playlist/video-playlist.model' |
4 | 5 | ||
5 | export abstract class MyAccountVideoPlaylistEdit extends FormReactive { | 6 | export abstract class MyAccountVideoPlaylistEdit extends FormReactive { |
6 | // Declare it here to avoid errors in create template | 7 | // Declare it here to avoid errors in create template |
7 | videoPlaylistToUpdate: VideoPlaylist | 8 | videoPlaylistToUpdate: VideoPlaylist |
8 | userVideoChannels: { id: number, label: string }[] = [] | 9 | userVideoChannels: SelectChannelItem[] = [] |
9 | videoPlaylistPrivacies: VideoConstant<VideoPlaylistPrivacy>[] = [] | 10 | videoPlaylistPrivacies: VideoConstant<VideoPlaylistPrivacy>[] = [] |
10 | 11 | ||
11 | abstract isCreation (): boolean | 12 | abstract isCreation (): boolean |
diff --git a/client/src/app/+search/search-filters.component.html b/client/src/app/+search/search-filters.component.html index b36b1d2ae..1d1e7b868 100644 --- a/client/src/app/+search/search-filters.component.html +++ b/client/src/app/+search/search-filters.component.html | |||
@@ -144,7 +144,7 @@ | |||
144 | <button i18n class="reset-button reset-button-small" (click)="resetField('tagsAllOf')" *ngIf="advancedSearch.tagsAllOf"> | 144 | <button i18n class="reset-button reset-button-small" (click)="resetField('tagsAllOf')" *ngIf="advancedSearch.tagsAllOf"> |
145 | Reset | 145 | Reset |
146 | </button> | 146 | </button> |
147 | <my-select-tags labelForId="tagsAllOf" id="tagsAllOf" [(ngModel)]="advancedSearch.tagsAllOf"></my-select-tags> | 147 | <my-select-tags name="tagsAllOf" labelForId="tagsAllOf" id="tagsAllOf" [(ngModel)]="advancedSearch.tagsAllOf"></my-select-tags> |
148 | </div> | 148 | </div> |
149 | 149 | ||
150 | <div class="form-group"> | 150 | <div class="form-group"> |
@@ -152,7 +152,7 @@ | |||
152 | <button i18n class="reset-button reset-button-small" (click)="resetField('tagsOneOf')" *ngIf="advancedSearch.tagsOneOf"> | 152 | <button i18n class="reset-button reset-button-small" (click)="resetField('tagsOneOf')" *ngIf="advancedSearch.tagsOneOf"> |
153 | Reset | 153 | Reset |
154 | </button> | 154 | </button> |
155 | <my-select-tags labelForId="tagsOneOf" id="tagsOneOf" [(ngModel)]="advancedSearch.tagsOneOf"></my-select-tags> | 155 | <my-select-tags name="tagsOneOf" labelForId="tagsOneOf" id="tagsOneOf" [(ngModel)]="advancedSearch.tagsOneOf"></my-select-tags> |
156 | </div> | 156 | </div> |
157 | 157 | ||
158 | <div class="form-group" *ngIf="isSearchTargetEnabled()"> | 158 | <div class="form-group" *ngIf="isSearchTargetEnabled()"> |
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts index 4cd3838de..48c5508f4 100644 --- a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts +++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts | |||
@@ -1,16 +1,17 @@ | |||
1 | import { forkJoin } from 'rxjs' | ||
1 | import { map } from 'rxjs/operators' | 2 | import { map } from 'rxjs/operators' |
2 | import { Component, Input, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core' | 3 | import { Component, Input, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core' |
3 | import { FormArray, FormControl, FormGroup, ValidatorFn, Validators } from '@angular/forms' | 4 | import { FormArray, FormControl, FormGroup, ValidatorFn, Validators } from '@angular/forms' |
4 | import { ServerService } from '@app/core' | 5 | import { ServerService } from '@app/core' |
5 | import { removeElementFromArray } from '@app/helpers' | 6 | import { removeElementFromArray } from '@app/helpers' |
6 | import { FormReactiveValidationMessages, FormValidatorService, VideoValidatorsService } from '@app/shared/shared-forms' | 7 | import { FormReactiveValidationMessages, FormValidatorService, VideoValidatorsService } from '@app/shared/shared-forms' |
8 | import { SelectChannelItem } from '@app/shared/shared-forms/select-channel.component' | ||
9 | import { InstanceService } from '@app/shared/shared-instance' | ||
7 | import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main' | 10 | import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main' |
11 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
8 | import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models' | 12 | import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models' |
9 | import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service' | 13 | import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service' |
10 | import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component' | 14 | import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component' |
11 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
12 | import { forkJoin } from 'rxjs' | ||
13 | import { InstanceService } from '@app/shared/shared-instance' | ||
14 | 15 | ||
15 | type VideoLanguages = VideoConstant<string> & { group?: string } | 16 | type VideoLanguages = VideoConstant<string> & { group?: string } |
16 | 17 | ||
@@ -23,7 +24,7 @@ export class VideoEditComponent implements OnInit, OnDestroy { | |||
23 | @Input() form: FormGroup | 24 | @Input() form: FormGroup |
24 | @Input() formErrors: { [ id: string ]: string } = {} | 25 | @Input() formErrors: { [ id: string ]: string } = {} |
25 | @Input() validationMessages: FormReactiveValidationMessages = {} | 26 | @Input() validationMessages: FormReactiveValidationMessages = {} |
26 | @Input() userVideoChannels: { id: number, label: string, support: string }[] = [] | 27 | @Input() userVideoChannels: SelectChannelItem[] = [] |
27 | @Input() schedulePublicationPossible = true | 28 | @Input() schedulePublicationPossible = true |
28 | @Input() videoCaptions: (VideoCaptionEdit & { captionPath?: string })[] = [] | 29 | @Input() videoCaptions: (VideoCaptionEdit & { captionPath?: string })[] = [] |
29 | @Input() waitTranscodingEnabled = true | 30 | @Input() waitTranscodingEnabled = true |
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-send.ts b/client/src/app/+videos/+video-edit/video-add-components/video-send.ts index 86f2b376f..c55e5f923 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-send.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-send.ts | |||
@@ -3,6 +3,7 @@ import { Directive, EventEmitter, OnInit } from '@angular/core' | |||
3 | import { AuthService, CanComponentDeactivateResult, Notifier, ServerService } from '@app/core' | 3 | import { AuthService, CanComponentDeactivateResult, Notifier, ServerService } from '@app/core' |
4 | import { populateAsyncUserVideoChannels } from '@app/helpers' | 4 | import { populateAsyncUserVideoChannels } from '@app/helpers' |
5 | import { FormReactive } from '@app/shared/shared-forms' | 5 | import { FormReactive } from '@app/shared/shared-forms' |
6 | import { SelectChannelItem } from '@app/shared/shared-forms/select-channel.component' | ||
6 | import { VideoCaptionEdit, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' | 7 | import { VideoCaptionEdit, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' |
7 | import { LoadingBarService } from '@ngx-loading-bar/core' | 8 | import { LoadingBarService } from '@ngx-loading-bar/core' |
8 | import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models' | 9 | import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models' |
@@ -10,7 +11,7 @@ import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models' | |||
10 | @Directive() | 11 | @Directive() |
11 | // tslint:disable-next-line: directive-class-suffix | 12 | // tslint:disable-next-line: directive-class-suffix |
12 | export abstract class VideoSend extends FormReactive implements OnInit { | 13 | export abstract class VideoSend extends FormReactive implements OnInit { |
13 | userVideoChannels: { id: number, label: string, support: string, avatarPath?: string }[] = [] | 14 | userVideoChannels: SelectChannelItem[] = [] |
14 | videoPrivacies: VideoConstant<VideoPrivacy>[] = [] | 15 | videoPrivacies: VideoConstant<VideoPrivacy>[] = [] |
15 | videoCaptions: VideoCaptionEdit[] = [] | 16 | videoCaptions: VideoCaptionEdit[] = [] |
16 | 17 | ||
diff --git a/client/src/app/+videos/+video-edit/video-update.component.ts b/client/src/app/+videos/+video-edit/video-update.component.ts index de4f65df3..263c71f3b 100644 --- a/client/src/app/+videos/+video-edit/video-update.component.ts +++ b/client/src/app/+videos/+video-edit/video-update.component.ts | |||
@@ -3,6 +3,7 @@ import { Component, HostListener, OnInit } from '@angular/core' | |||
3 | import { ActivatedRoute, Router } from '@angular/router' | 3 | import { ActivatedRoute, Router } from '@angular/router' |
4 | import { Notifier } from '@app/core' | 4 | import { Notifier } from '@app/core' |
5 | import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' | 5 | import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' |
6 | import { SelectChannelItem } from '@app/shared/shared-forms/select-channel.component' | ||
6 | import { VideoCaptionEdit, VideoCaptionService, VideoDetails, VideoEdit, VideoService } from '@app/shared/shared-main' | 7 | import { VideoCaptionEdit, VideoCaptionService, VideoDetails, VideoEdit, VideoService } from '@app/shared/shared-main' |
7 | import { LoadingBarService } from '@ngx-loading-bar/core' | 8 | import { LoadingBarService } from '@ngx-loading-bar/core' |
8 | import { I18n } from '@ngx-translate/i18n-polyfill' | 9 | import { I18n } from '@ngx-translate/i18n-polyfill' |
@@ -17,7 +18,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
17 | video: VideoEdit | 18 | video: VideoEdit |
18 | 19 | ||
19 | isUpdatingVideo = false | 20 | isUpdatingVideo = false |
20 | userVideoChannels: { id: number, label: string, support: string, avatar?: string }[] = [] | 21 | userVideoChannels: SelectChannelItem[] = [] |
21 | schedulePublicationPossible = false | 22 | schedulePublicationPossible = false |
22 | videoCaptions: VideoCaptionEdit[] = [] | 23 | videoCaptions: VideoCaptionEdit[] = [] |
23 | waitTranscodingEnabled = true | 24 | waitTranscodingEnabled = true |
diff --git a/client/src/app/core/rest/rest.service.ts b/client/src/app/core/rest/rest.service.ts index 9e32c6d58..4f1fc8848 100644 --- a/client/src/app/core/rest/rest.service.ts +++ b/client/src/app/core/rest/rest.service.ts | |||
@@ -49,7 +49,7 @@ export class RestService { | |||
49 | const value = object[name] | 49 | const value = object[name] |
50 | if (value === undefined || value === null) continue | 50 | if (value === undefined || value === null) continue |
51 | 51 | ||
52 | if (Array.isArray(value) && value.length !== 0) { | 52 | if (Array.isArray(value)) { |
53 | for (const v of value) params = params.append(name, v) | 53 | for (const v of value) params = params.append(name, v) |
54 | } else { | 54 | } else { |
55 | params = params.append(name, value) | 55 | params = params.append(name, value) |
diff --git a/client/src/app/helpers/utils.ts b/client/src/app/helpers/utils.ts index aa37fdd46..b925e6d98 100644 --- a/client/src/app/helpers/utils.ts +++ b/client/src/app/helpers/utils.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import { DatePipe } from '@angular/common' | 1 | import { DatePipe } from '@angular/common' |
2 | import { environment } from '../../environments/environment' | 2 | import { environment } from '../../environments/environment' |
3 | import { AuthService } from '../core/auth' | 3 | import { AuthService } from '../core/auth' |
4 | import { SelectChannelItem } from '@app/shared/shared-forms/select-channel.component' | ||
4 | 5 | ||
5 | // Thanks: https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript | 6 | // Thanks: https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript |
6 | function getParameterByName (name: string, url: string) { | 7 | function getParameterByName (name: string, url: string) { |
@@ -18,7 +19,7 @@ function getParameterByName (name: string, url: string) { | |||
18 | 19 | ||
19 | function populateAsyncUserVideoChannels ( | 20 | function populateAsyncUserVideoChannels ( |
20 | authService: AuthService, | 21 | authService: AuthService, |
21 | channel: { id: number, label: string, support?: string, avatarPath?: string, recent?: boolean }[] | 22 | channel: SelectChannelItem[] |
22 | ) { | 23 | ) { |
23 | return new Promise(res => { | 24 | return new Promise(res => { |
24 | authService.userInformationLoaded | 25 | authService.userInformationLoaded |
diff --git a/client/src/app/shared/shared-forms/select-channel.component.ts b/client/src/app/shared/shared-forms/select-channel.component.ts index de98c8c0a..ef4192095 100644 --- a/client/src/app/shared/shared-forms/select-channel.component.ts +++ b/client/src/app/shared/shared-forms/select-channel.component.ts | |||
@@ -1,7 +1,14 @@ | |||
1 | import { Component, Input, forwardRef, ViewChild } from '@angular/core' | 1 | import { Component, forwardRef, Input } from '@angular/core' |
2 | import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms' | 2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' |
3 | import { Actor } from '../shared-main' | 3 | import { Actor } from '../shared-main' |
4 | 4 | ||
5 | export type SelectChannelItem = { | ||
6 | id: number | ||
7 | label: string | ||
8 | support: string | ||
9 | avatarPath?: string | ||
10 | } | ||
11 | |||
5 | @Component({ | 12 | @Component({ |
6 | selector: 'my-select-channel', | 13 | selector: 'my-select-channel', |
7 | styleUrls: [ './select-shared.component.scss' ], | 14 | styleUrls: [ './select-shared.component.scss' ], |
@@ -15,7 +22,7 @@ import { Actor } from '../shared-main' | |||
15 | ] | 22 | ] |
16 | }) | 23 | }) |
17 | export class SelectChannelComponent implements ControlValueAccessor { | 24 | export class SelectChannelComponent implements ControlValueAccessor { |
18 | @Input() items: { id: number, label: string, support: string, avatarPath?: string }[] = [] | 25 | @Input() items: SelectChannelItem[] = [] |
19 | 26 | ||
20 | selectedId: number | 27 | selectedId: number |
21 | 28 | ||
diff --git a/client/src/app/shared/shared-forms/select-tags.component.html b/client/src/app/shared/shared-forms/select-tags.component.html index 0609c9d20..e1cd50882 100644 --- a/client/src/app/shared/shared-forms/select-tags.component.html +++ b/client/src/app/shared/shared-forms/select-tags.component.html | |||
@@ -1,6 +1,6 @@ | |||
1 | <ng-select | 1 | <ng-select |
2 | [items]="items" | 2 | [items]="availableItems" |
3 | [(ngModel)]="_items" | 3 | [(ngModel)]="selectedItems" |
4 | (ngModelChange)="onModelChange()" | 4 | (ngModelChange)="onModelChange()" |
5 | i18n-placeholder placeholder="Enter a new tag" | 5 | i18n-placeholder placeholder="Enter a new tag" |
6 | [maxSelectedItems]="5" | 6 | [maxSelectedItems]="5" |
diff --git a/client/src/app/shared/shared-forms/select-tags.component.ts b/client/src/app/shared/shared-forms/select-tags.component.ts index 2e07d7e8f..a8a19d788 100644 --- a/client/src/app/shared/shared-forms/select-tags.component.ts +++ b/client/src/app/shared/shared-forms/select-tags.component.ts | |||
@@ -14,14 +14,14 @@ import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms' | |||
14 | ] | 14 | ] |
15 | }) | 15 | }) |
16 | export class SelectTagsComponent implements ControlValueAccessor { | 16 | export class SelectTagsComponent implements ControlValueAccessor { |
17 | @Input() items: string[] = [] | 17 | @Input() availableItems: string[] = [] |
18 | @Input() _items: string[] = [] | 18 | @Input() selectedItems: string[] = [] |
19 | 19 | ||
20 | propagateChange = (_: any) => { /* empty */ } | 20 | propagateChange = (_: any) => { /* empty */ } |
21 | 21 | ||
22 | writeValue (items: string[]) { | 22 | writeValue (items: string[]) { |
23 | this._items = items | 23 | this.selectedItems = items |
24 | this.propagateChange(this._items) | 24 | this.propagateChange(this.selectedItems) |
25 | } | 25 | } |
26 | 26 | ||
27 | registerOnChange (fn: (_: any) => void) { | 27 | registerOnChange (fn: (_: any) => void) { |
@@ -33,6 +33,8 @@ export class SelectTagsComponent implements ControlValueAccessor { | |||
33 | } | 33 | } |
34 | 34 | ||
35 | onModelChange () { | 35 | onModelChange () { |
36 | this.propagateChange(this._items) | 36 | console.log(this.selectedItems) |
37 | |||
38 | this.propagateChange(this.selectedItems) | ||
37 | } | 39 | } |
38 | } | 40 | } |
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 |