aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+search
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-08-05 00:50:07 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-08-11 09:03:39 +0200
commit02c01341f4dae30ec6b81fcb644952393d73c4a8 (patch)
treeaca3f2b118bb123457fd38724be68fe877504c75 /client/src/app/+search
parent766d13b4470de02d3d7bec94188260b89a356399 (diff)
downloadPeerTube-02c01341f4dae30ec6b81fcb644952393d73c4a8.tar.gz
PeerTube-02c01341f4dae30ec6b81fcb644952393d73c4a8.tar.zst
PeerTube-02c01341f4dae30ec6b81fcb644952393d73c4a8.zip
add ng-select for templatable select options
- create select-tags component to replace ngx-chips - create select-options to factorize option selection in forms - create select-channel to simplify channel selection - refactor tags validation
Diffstat (limited to 'client/src/app/+search')
-rw-r--r--client/src/app/+search/search-filters.component.html14
-rw-r--r--client/src/app/+search/search-filters.component.scss2
-rw-r--r--client/src/app/+search/search-filters.component.ts6
-rw-r--r--client/src/app/+search/search.module.ts4
4 files changed, 2 insertions, 24 deletions
diff --git a/client/src/app/+search/search-filters.component.html b/client/src/app/+search/search-filters.component.html
index e20aef8fb..b36b1d2ae 100644
--- a/client/src/app/+search/search-filters.component.html
+++ b/client/src/app/+search/search-filters.component.html
@@ -144,12 +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 <tag-input 147 <my-select-tags labelForId="tagsAllOf" id="tagsAllOf" [(ngModel)]="advancedSearch.tagsAllOf"></my-select-tags>
148 [(ngModel)]="advancedSearch.tagsAllOf" name="tagsAllOf" id="tagsAllOf"
149 [validators]="tagValidators" [errorMessages]="tagValidatorsMessages"
150 i18n-placeholder placeholder="+ Tag" i18n-secondaryPlaceholder secondaryPlaceholder="Enter a tag"
151 [maxItems]="5" [modelAsStrings]="true"
152 ></tag-input>
153 </div> 148 </div>
154 149
155 <div class="form-group"> 150 <div class="form-group">
@@ -157,12 +152,7 @@
157 <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">
158 Reset 153 Reset
159 </button> 154 </button>
160 <tag-input 155 <my-select-tags labelForId="tagsOneOf" id="tagsOneOf" [(ngModel)]="advancedSearch.tagsOneOf"></my-select-tags>
161 [(ngModel)]="advancedSearch.tagsOneOf" name="tagsOneOf" id="tagsOneOf"
162 [validators]="tagValidators" [errorMessages]="tagValidatorsMessages"
163 i18n-placeholder placeholder="+ Tag" i18n-secondaryPlaceholder secondaryPlaceholder="Enter a tag"
164 [maxItems]="5" [modelAsStrings]="true"
165 ></tag-input>
166 </div> 156 </div>
167 157
168 <div class="form-group" *ngIf="isSearchTargetEnabled()"> 158 <div class="form-group" *ngIf="isSearchTargetEnabled()">
diff --git a/client/src/app/+search/search-filters.component.scss b/client/src/app/+search/search-filters.component.scss
index a88a1c0b0..68ac6d021 100644
--- a/client/src/app/+search/search-filters.component.scss
+++ b/client/src/app/+search/search-filters.component.scss
@@ -65,5 +65,3 @@ input[type=submit] {
65 display: flex; 65 display: flex;
66 white-space: nowrap; 66 white-space: nowrap;
67} 67}
68
69@include ng2-tags;
diff --git a/client/src/app/+search/search-filters.component.ts b/client/src/app/+search/search-filters.component.ts
index fc1db3258..13ad61647 100644
--- a/client/src/app/+search/search-filters.component.ts
+++ b/client/src/app/+search/search-filters.component.ts
@@ -1,5 +1,4 @@
1import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' 1import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
2import { ValidatorFn } from '@angular/forms'
3import { ServerService } from '@app/core' 2import { ServerService } from '@app/core'
4import { VideoValidatorsService } from '@app/shared/shared-forms' 3import { VideoValidatorsService } from '@app/shared/shared-forms'
5import { AdvancedSearch } from '@app/shared/shared-search' 4import { AdvancedSearch } from '@app/shared/shared-search'
@@ -20,9 +19,6 @@ export class SearchFiltersComponent implements OnInit {
20 videoLicences: VideoConstant<number>[] = [] 19 videoLicences: VideoConstant<number>[] = []
21 videoLanguages: VideoConstant<string>[] = [] 20 videoLanguages: VideoConstant<string>[] = []
22 21
23 tagValidators: ValidatorFn[]
24 tagValidatorsMessages: { [ name: string ]: string }
25
26 publishedDateRanges: { id: string, label: string }[] = [] 22 publishedDateRanges: { id: string, label: string }[] = []
27 sorts: { id: string, label: string }[] = [] 23 sorts: { id: string, label: string }[] = []
28 durationRanges: { id: string, label: string }[] = [] 24 durationRanges: { id: string, label: string }[] = []
@@ -40,8 +36,6 @@ export class SearchFiltersComponent implements OnInit {
40 private videoValidatorsService: VideoValidatorsService, 36 private videoValidatorsService: VideoValidatorsService,
41 private serverService: ServerService 37 private serverService: ServerService
42 ) { 38 ) {
43 this.tagValidators = this.videoValidatorsService.VIDEO_TAGS.VALIDATORS
44 this.tagValidatorsMessages = this.videoValidatorsService.VIDEO_TAGS.MESSAGES
45 this.publishedDateRanges = [ 39 this.publishedDateRanges = [
46 { 40 {
47 id: 'any_published_date', 41 id: 'any_published_date',
diff --git a/client/src/app/+search/search.module.ts b/client/src/app/+search/search.module.ts
index ee4f07ad1..e85ae07d0 100644
--- a/client/src/app/+search/search.module.ts
+++ b/client/src/app/+search/search.module.ts
@@ -1,4 +1,3 @@
1import { TagInputModule } from 'ngx-chips'
2import { NgModule } from '@angular/core' 1import { NgModule } from '@angular/core'
3import { SharedFormModule } from '@app/shared/shared-forms' 2import { SharedFormModule } from '@app/shared/shared-forms'
4import { SharedMainModule } from '@app/shared/shared-main' 3import { SharedMainModule } from '@app/shared/shared-main'
@@ -14,8 +13,6 @@ import { VideoLazyLoadResolver } from './video-lazy-load.resolver'
14 13
15@NgModule({ 14@NgModule({
16 imports: [ 15 imports: [
17 TagInputModule,
18
19 SearchRoutingModule, 16 SearchRoutingModule,
20 17
21 SharedMainModule, 18 SharedMainModule,
@@ -31,7 +28,6 @@ import { VideoLazyLoadResolver } from './video-lazy-load.resolver'
31 ], 28 ],
32 29
33 exports: [ 30 exports: [
34 TagInputModule,
35 SearchComponent 31 SearchComponent
36 ], 32 ],
37 33