From 52c4976fcf4ee255a3af68ff9778e4f5c4f84bd4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 11 Aug 2020 16:07:53 +0200 Subject: [PATCH] Use ng select for multiselect --- .../edit-custom-config.component.html | 22 +++--- .../edit-custom-config.component.scss | 4 + .../edit-custom-config.component.ts | 33 +++----- .../users/user-list/user-list.component.html | 44 +++++------ .../users/user-list/user-list.component.scss | 1 + .../users/user-list/user-list.component.ts | 34 +++++---- .../my-account-video-playlist-edit.ts | 3 +- .../shared/video-edit.component.ts | 3 +- .../video-add-components/video-send.ts | 3 +- .../+video-edit/video-update.component.ts | 3 +- client/src/app/helpers/utils.ts | 2 +- client/src/app/shared/shared-forms/index.ts | 1 + .../shared-forms/select-shared.component.scss | 20 ----- .../app/shared/shared-forms/select/index.ts | 4 + .../select-channel.component.html | 0 .../{ => select}/select-channel.component.ts | 2 +- .../select/select-checkbox.component.html | 41 ++++++++++ .../select/select-checkbox.component.scss | 18 +++++ .../select/select-checkbox.component.ts | 75 +++++++++++++++++++ .../select-options.component.html | 5 +- .../{ => select}/select-options.component.ts | 12 +-- .../select/select-shared.component.scss | 32 ++++++++ .../{ => select}/select-tags.component.html | 0 .../{ => select}/select-tags.component.scss | 0 .../{ => select}/select-tags.component.ts | 2 - .../shared/shared-forms/shared-form.module.ts | 15 ++-- .../user-video-settings.component.html | 10 +-- .../user-video-settings.component.scss | 4 + .../user-video-settings.component.ts | 45 +++++++---- client/src/sass/include/_mixins.scss | 11 +++ client/src/sass/primeng-custom.scss | 61 --------------- 31 files changed, 314 insertions(+), 196 deletions(-) delete mode 100644 client/src/app/shared/shared-forms/select-shared.component.scss create mode 100644 client/src/app/shared/shared-forms/select/index.ts rename client/src/app/shared/shared-forms/{ => select}/select-channel.component.html (100%) rename client/src/app/shared/shared-forms/{ => select}/select-channel.component.ts (94%) create mode 100644 client/src/app/shared/shared-forms/select/select-checkbox.component.html create mode 100644 client/src/app/shared/shared-forms/select/select-checkbox.component.scss create mode 100644 client/src/app/shared/shared-forms/select/select-checkbox.component.ts rename client/src/app/shared/shared-forms/{ => select}/select-options.component.html (89%) rename client/src/app/shared/shared-forms/{ => select}/select-options.component.ts (85%) create mode 100644 client/src/app/shared/shared-forms/select/select-shared.component.scss rename client/src/app/shared/shared-forms/{ => select}/select-tags.component.html (100%) rename client/src/app/shared/shared-forms/{ => select}/select-tags.component.scss (100%) rename client/src/app/shared/shared-forms/{ => select}/select-tags.component.ts (96%) 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 @@
- + +
@@ -60,11 +61,12 @@
- + +
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] { @include peertube-select-container($form-base-input-width); } +my-select-checkbox { + @include ng-select($form-base-input-width); +} + input[type=submit] { @include peertube-button; @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 @@ -import { SelectItem } from 'primeng/api' import { forkJoin } from 'rxjs' import { ViewportScroller } from '@angular/common' import { AfterViewChecked, Component, OnInit, ViewChild } from '@angular/core' import { ConfigService } from '@app/+admin/config/shared/config.service' import { Notifier } from '@app/core' import { ServerService } from '@app/core/server/server.service' -import { CustomConfigValidatorsService, FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' +import { + CustomConfigValidatorsService, + FormReactive, + FormValidatorService, + SelectOptionsItem, + UserValidatorsService +} from '@app/shared/shared-forms' import { NgbNav } from '@ng-bootstrap/ng-bootstrap' import { I18n } from '@ngx-translate/i18n-polyfill' import { CustomConfig, ServerConfig } from '@shared/models' @@ -25,8 +30,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A resolutions: { id: string, label: string, description?: string }[] = [] transcodingThreadOptions: { label: string, value: number }[] = [] - languageItems: SelectItem[] = [] - categoryItems: SelectItem[] = [] + languageItems: SelectOptionsItem[] = [] + categoryItems: SelectOptionsItem[] = [] private serverConfig: ServerConfig @@ -290,22 +295,6 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A ) } - getSelectedLanguageLabel () { - return this.i18n('{{\'{0} languages selected') - } - - getDefaultLanguageLabel () { - return this.i18n('No language') - } - - getSelectedCategoryLabel () { - return this.i18n('{{\'{0} categories selected') - } - - getDefaultCategoryLabel () { - return this.i18n('No category') - } - gotoAnchor () { const hashToNav = { 'customizations': 'advanced-configuration' @@ -331,8 +320,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A ([ config, languages, categories ]) => { this.customConfig = config - this.languageItems = languages.map(l => ({ label: l.label, value: l.id })) - this.categoryItems = categories.map(l => ({ label: l.label, value: l.id })) + this.languageItems = languages.map(l => ({ label: l.label, id: l.id })) + this.categoryItems = categories.map(l => ({ label: l.label, id: l.id + '' })) this.updateForm() // Force form validation diff --git a/client/src/app/+admin/users/user-list/user-list.component.html b/client/src/app/+admin/users/user-list/user-list.component.html index 3090247e5..d02f6526f 100644 --- a/client/src/app/+admin/users/user-list/user-list.component.html +++ b/client/src/app/+admin/users/user-list/user-list.component.html @@ -57,12 +57,12 @@