diff options
author | Chocobozzz <me@florianbigard.com> | 2020-08-11 16:07:53 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-08-11 16:18:42 +0200 |
commit | 52c4976fcf4ee255a3af68ff9778e4f5c4f84bd4 (patch) | |
tree | 887d2b6106548ad23cf016d82baf1977198027d9 /client/src/app/+admin/config/edit-custom-config | |
parent | 3d25d5de33d8aa0ba00d7514522b25d22bf0e0a1 (diff) | |
download | PeerTube-52c4976fcf4ee255a3af68ff9778e4f5c4f84bd4.tar.gz PeerTube-52c4976fcf4ee255a3af68ff9778e4f5c4f84bd4.tar.zst PeerTube-52c4976fcf4ee255a3af68ff9778e4f5c4f84bd4.zip |
Use ng select for multiselect
Diffstat (limited to 'client/src/app/+admin/config/edit-custom-config')
3 files changed, 27 insertions, 32 deletions
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html index 8fdced1c7..b82281c6c 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html | |||
@@ -48,11 +48,12 @@ | |||
48 | <label i18n for="instanceCategories">Main instance categories</label> | 48 | <label i18n for="instanceCategories">Main instance categories</label> |
49 | 49 | ||
50 | <div> | 50 | <div> |
51 | <p-multiSelect | 51 | <my-select-checkbox |
52 | inputId="instanceCategories" [options]="categoryItems" formControlName="categories" [showToggleAll]="false" | 52 | id="instanceCategories" |
53 | [defaultLabel]="getDefaultCategoryLabel()" [selectedItemsLabel]="getSelectedCategoryLabel()" | 53 | formControlName="categories" [availableItems]="categoryItems" |
54 | emptyFilterMessage="No results found" i18n-emptyFilterMessage | 54 | [selectableGroup]="false" |
55 | ></p-multiSelect> | 55 | > |
56 | </my-select-checkbox> | ||
56 | </div> | 57 | </div> |
57 | </div> | 58 | </div> |
58 | 59 | ||
@@ -60,11 +61,12 @@ | |||
60 | <label i18n for="instanceLanguages">Main languages you/your moderators speak</label> | 61 | <label i18n for="instanceLanguages">Main languages you/your moderators speak</label> |
61 | 62 | ||
62 | <div> | 63 | <div> |
63 | <p-multiSelect | 64 | <my-select-checkbox |
64 | inputId="instanceLanguages" [options]="languageItems" formControlName="languages" [showToggleAll]="false" | 65 | id="instanceLanguages" |
65 | [defaultLabel]="getDefaultLanguageLabel()" [selectedItemsLabel]="getSelectedLanguageLabel()" | 66 | formControlName="languages" [availableItems]="languageItems" |
66 | emptyFilterMessage="No results found" i18n-emptyFilterMessage | 67 | [selectableGroup]="false" |
67 | ></p-multiSelect> | 68 | > |
69 | </my-select-checkbox> | ||
68 | </div> | 70 | </div> |
69 | </div> | 71 | </div> |
70 | 72 | ||
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.scss b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.scss index 9618100b5..f8f2d5fdc 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.scss +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.scss | |||
@@ -30,6 +30,10 @@ input[type=checkbox] { | |||
30 | @include peertube-select-container($form-base-input-width); | 30 | @include peertube-select-container($form-base-input-width); |
31 | } | 31 | } |
32 | 32 | ||
33 | my-select-checkbox { | ||
34 | @include ng-select($form-base-input-width); | ||
35 | } | ||
36 | |||
33 | input[type=submit] { | 37 | input[type=submit] { |
34 | @include peertube-button; | 38 | @include peertube-button; |
35 | @include orange-button; | 39 | @include orange-button; |
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts index 69629770f..00a0bfad2 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts | |||
@@ -1,11 +1,16 @@ | |||
1 | import { SelectItem } from 'primeng/api' | ||
2 | import { forkJoin } from 'rxjs' | 1 | import { forkJoin } from 'rxjs' |
3 | import { ViewportScroller } from '@angular/common' | 2 | import { ViewportScroller } from '@angular/common' |
4 | import { AfterViewChecked, Component, OnInit, ViewChild } from '@angular/core' | 3 | import { AfterViewChecked, Component, OnInit, ViewChild } from '@angular/core' |
5 | import { ConfigService } from '@app/+admin/config/shared/config.service' | 4 | import { ConfigService } from '@app/+admin/config/shared/config.service' |
6 | import { Notifier } from '@app/core' | 5 | import { Notifier } from '@app/core' |
7 | import { ServerService } from '@app/core/server/server.service' | 6 | import { ServerService } from '@app/core/server/server.service' |
8 | import { CustomConfigValidatorsService, FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' | 7 | import { |
8 | CustomConfigValidatorsService, | ||
9 | FormReactive, | ||
10 | FormValidatorService, | ||
11 | SelectOptionsItem, | ||
12 | UserValidatorsService | ||
13 | } from '@app/shared/shared-forms' | ||
9 | import { NgbNav } from '@ng-bootstrap/ng-bootstrap' | 14 | import { NgbNav } from '@ng-bootstrap/ng-bootstrap' |
10 | import { I18n } from '@ngx-translate/i18n-polyfill' | 15 | import { I18n } from '@ngx-translate/i18n-polyfill' |
11 | import { CustomConfig, ServerConfig } from '@shared/models' | 16 | import { CustomConfig, ServerConfig } from '@shared/models' |
@@ -25,8 +30,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A | |||
25 | resolutions: { id: string, label: string, description?: string }[] = [] | 30 | resolutions: { id: string, label: string, description?: string }[] = [] |
26 | transcodingThreadOptions: { label: string, value: number }[] = [] | 31 | transcodingThreadOptions: { label: string, value: number }[] = [] |
27 | 32 | ||
28 | languageItems: SelectItem[] = [] | 33 | languageItems: SelectOptionsItem[] = [] |
29 | categoryItems: SelectItem[] = [] | 34 | categoryItems: SelectOptionsItem[] = [] |
30 | 35 | ||
31 | private serverConfig: ServerConfig | 36 | private serverConfig: ServerConfig |
32 | 37 | ||
@@ -290,22 +295,6 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A | |||
290 | ) | 295 | ) |
291 | } | 296 | } |
292 | 297 | ||
293 | getSelectedLanguageLabel () { | ||
294 | return this.i18n('{{\'{0} languages selected') | ||
295 | } | ||
296 | |||
297 | getDefaultLanguageLabel () { | ||
298 | return this.i18n('No language') | ||
299 | } | ||
300 | |||
301 | getSelectedCategoryLabel () { | ||
302 | return this.i18n('{{\'{0} categories selected') | ||
303 | } | ||
304 | |||
305 | getDefaultCategoryLabel () { | ||
306 | return this.i18n('No category') | ||
307 | } | ||
308 | |||
309 | gotoAnchor () { | 298 | gotoAnchor () { |
310 | const hashToNav = { | 299 | const hashToNav = { |
311 | 'customizations': 'advanced-configuration' | 300 | 'customizations': 'advanced-configuration' |
@@ -331,8 +320,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A | |||
331 | ([ config, languages, categories ]) => { | 320 | ([ config, languages, categories ]) => { |
332 | this.customConfig = config | 321 | this.customConfig = config |
333 | 322 | ||
334 | this.languageItems = languages.map(l => ({ label: l.label, value: l.id })) | 323 | this.languageItems = languages.map(l => ({ label: l.label, id: l.id })) |
335 | this.categoryItems = categories.map(l => ({ label: l.label, value: l.id })) | 324 | this.categoryItems = categories.map(l => ({ label: l.label, id: l.id + '' })) |
336 | 325 | ||
337 | this.updateForm() | 326 | this.updateForm() |
338 | // Force form validation | 327 | // Force form validation |