diff options
Diffstat (limited to 'client/src/app/shared')
8 files changed, 31 insertions, 27 deletions
diff --git a/client/src/app/shared/form-validators/form-validator.model.ts b/client/src/app/shared/form-validators/form-validator.model.ts index 248a3b1d3..07b1ea075 100644 --- a/client/src/app/shared/form-validators/form-validator.model.ts +++ b/client/src/app/shared/form-validators/form-validator.model.ts | |||
@@ -10,5 +10,5 @@ export type BuildFormArgument = { | |||
10 | } | 10 | } |
11 | 11 | ||
12 | export type BuildFormDefaultValues = { | 12 | export type BuildFormDefaultValues = { |
13 | [ name: string ]: string | string[] | BuildFormDefaultValues | 13 | [ name: string ]: number | string | string[] | BuildFormDefaultValues |
14 | } | 14 | } |
diff --git a/client/src/app/shared/shared-forms/select/select-channel.component.ts b/client/src/app/shared/shared-forms/select/select-channel.component.ts index 1d91d59bc..40a7c53bb 100644 --- a/client/src/app/shared/shared-forms/select/select-channel.component.ts +++ b/client/src/app/shared/shared-forms/select/select-channel.component.ts | |||
@@ -1,13 +1,7 @@ | |||
1 | import { Component, forwardRef, Input } from '@angular/core' | 1 | import { Component, forwardRef, Input, OnChanges } from '@angular/core' |
2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' | 2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' |
3 | import { VideoChannel } from '@app/shared/shared-main' | 3 | import { VideoChannel } from '@app/shared/shared-main' |
4 | 4 | import { SelectChannelItem } from '../../../../types/select-options-item.model' | |
5 | export type SelectChannelItem = { | ||
6 | id: number | ||
7 | label: string | ||
8 | support: string | ||
9 | avatarPath?: string | ||
10 | } | ||
11 | 5 | ||
12 | @Component({ | 6 | @Component({ |
13 | selector: 'my-select-channel', | 7 | selector: 'my-select-channel', |
@@ -21,9 +15,10 @@ export type SelectChannelItem = { | |||
21 | } | 15 | } |
22 | ] | 16 | ] |
23 | }) | 17 | }) |
24 | export class SelectChannelComponent implements ControlValueAccessor { | 18 | export class SelectChannelComponent implements ControlValueAccessor, OnChanges { |
25 | @Input() items: SelectChannelItem[] = [] | 19 | @Input() items: SelectChannelItem[] = [] |
26 | 20 | ||
21 | channels: SelectChannelItem[] = [] | ||
27 | selectedId: number | 22 | selectedId: number |
28 | 23 | ||
29 | // ng-select options | 24 | // ng-select options |
@@ -32,10 +27,14 @@ export class SelectChannelComponent implements ControlValueAccessor { | |||
32 | clearable = false | 27 | clearable = false |
33 | searchable = false | 28 | searchable = false |
34 | 29 | ||
35 | get channels () { | 30 | ngOnChanges () { |
36 | return this.items.map(c => Object.assign(c, { | 31 | this.channels = this.items.map(c => { |
37 | avatarPath: c.avatarPath ? c.avatarPath : VideoChannel.GET_DEFAULT_AVATAR_URL() | 32 | const avatarPath = c.avatarPath |
38 | })) | 33 | ? c.avatarPath |
34 | : VideoChannel.GET_DEFAULT_AVATAR_URL() | ||
35 | |||
36 | return Object.assign({}, c, { avatarPath }) | ||
37 | }) | ||
39 | } | 38 | } |
40 | 39 | ||
41 | propagateChange = (_: any) => { /* empty */ } | 40 | propagateChange = (_: any) => { /* empty */ } |
diff --git a/client/src/app/shared/shared-forms/select/select-checkbox.component.ts b/client/src/app/shared/shared-forms/select/select-checkbox.component.ts index eb0c49034..c2523f15c 100644 --- a/client/src/app/shared/shared-forms/select/select-checkbox.component.ts +++ b/client/src/app/shared/shared-forms/select/select-checkbox.component.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { Component, forwardRef, Input, OnInit } from '@angular/core' | 1 | import { Component, forwardRef, Input, OnInit } from '@angular/core' |
2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' | 2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' |
3 | import { SelectOptionsItem } from './select-options.component' | 3 | import { SelectOptionsItem } from '../../../../types/select-options-item.model' |
4 | 4 | ||
5 | export type ItemSelectCheckboxValue = { id?: string | number, group?: string } | string | 5 | export type ItemSelectCheckboxValue = { id?: string | number, group?: string } | string |
6 | 6 | ||
diff --git a/client/src/app/shared/shared-forms/select/select-custom-value.component.html b/client/src/app/shared/shared-forms/select/select-custom-value.component.html index 5fdf432ff..9dc8c2ec2 100644 --- a/client/src/app/shared/shared-forms/select/select-custom-value.component.html +++ b/client/src/app/shared/shared-forms/select/select-custom-value.component.html | |||
@@ -10,5 +10,9 @@ | |||
10 | (ngModelChange)="onModelChange()" | 10 | (ngModelChange)="onModelChange()" |
11 | ></my-select-options> | 11 | ></my-select-options> |
12 | 12 | ||
13 | <input *ngIf="isCustomValue()" [(ngModel)]="customValue" (ngModelChange)="onModelChange()" type="text" class="form-control" /> | 13 | <ng-container *ngIf="isCustomValue()"> |
14 | <input [(ngModel)]="customValue" (ngModelChange)="onModelChange()" [type]="inputType" class="form-control" /> | ||
15 | |||
16 | <span *ngIf="inputSuffix" class="input-suffix">{{ inputSuffix }}</span> | ||
17 | </ng-container> | ||
14 | </div> | 18 | </div> |
diff --git a/client/src/app/shared/shared-forms/select/select-custom-value.component.ts b/client/src/app/shared/shared-forms/select/select-custom-value.component.ts index a8e5ad0d3..bc6b863c7 100644 --- a/client/src/app/shared/shared-forms/select/select-custom-value.component.ts +++ b/client/src/app/shared/shared-forms/select/select-custom-value.component.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { Component, forwardRef, Input, OnChanges } from '@angular/core' | 1 | import { Component, forwardRef, Input, OnChanges } from '@angular/core' |
2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' | 2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' |
3 | import { SelectOptionsItem } from './select-options.component' | 3 | import { SelectOptionsItem } from '../../../../types/select-options-item.model' |
4 | 4 | ||
5 | @Component({ | 5 | @Component({ |
6 | selector: 'my-select-custom-value', | 6 | selector: 'my-select-custom-value', |
@@ -20,6 +20,8 @@ export class SelectCustomValueComponent implements ControlValueAccessor, OnChang | |||
20 | @Input() searchable = false | 20 | @Input() searchable = false |
21 | @Input() groupBy: string | 21 | @Input() groupBy: string |
22 | @Input() labelForId: string | 22 | @Input() labelForId: string |
23 | @Input() inputSuffix: string | ||
24 | @Input() inputType = 'text' | ||
23 | 25 | ||
24 | customValue: number | string = '' | 26 | customValue: number | string = '' |
25 | selectedId: number | string | 27 | selectedId: number | string |
diff --git a/client/src/app/shared/shared-forms/select/select-options.component.ts b/client/src/app/shared/shared-forms/select/select-options.component.ts index 51a3f515d..2890670e5 100644 --- a/client/src/app/shared/shared-forms/select/select-options.component.ts +++ b/client/src/app/shared/shared-forms/select/select-options.component.ts | |||
@@ -1,13 +1,6 @@ | |||
1 | import { Component, forwardRef, Input } from '@angular/core' | 1 | import { Component, forwardRef, Input } from '@angular/core' |
2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' | 2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' |
3 | 3 | import { SelectOptionsItem } from '../../../../types/select-options-item.model' | |
4 | export type SelectOptionsItem = { | ||
5 | id: string | number | ||
6 | label: string | ||
7 | description?: string | ||
8 | group?: string | ||
9 | groupLabel?: string | ||
10 | } | ||
11 | 4 | ||
12 | @Component({ | 5 | @Component({ |
13 | selector: 'my-select-options', | 6 | selector: 'my-select-options', |
diff --git a/client/src/app/shared/shared-forms/select/select-shared.component.scss b/client/src/app/shared/shared-forms/select/select-shared.component.scss index 1a4192b55..80196b8df 100644 --- a/client/src/app/shared/shared-forms/select/select-shared.component.scss +++ b/client/src/app/shared/shared-forms/select/select-shared.component.scss | |||
@@ -33,15 +33,20 @@ ng-select ::ng-deep { | |||
33 | 33 | ||
34 | .root { | 34 | .root { |
35 | display:flex; | 35 | display:flex; |
36 | align-items: center; | ||
36 | 37 | ||
37 | > my-select-options { | 38 | > my-select-options { |
38 | flex-grow: 1; | 39 | flex-grow: 1; |
39 | } | 40 | } |
40 | } | 41 | } |
41 | 42 | ||
42 | input[type=text] { | 43 | my-select-options + input { |
43 | margin-left: 5px; | 44 | margin-left: 5px; |
44 | 45 | ||
45 | @include peertube-input-text($form-base-input-width); | 46 | @include peertube-input-text($form-base-input-width); |
46 | display: block; | 47 | display: block; |
47 | } | 48 | } |
49 | |||
50 | .input-suffix { | ||
51 | margin-left: 5px; | ||
52 | } | ||
diff --git a/client/src/app/shared/shared-user-settings/user-video-settings.component.ts b/client/src/app/shared/shared-user-settings/user-video-settings.component.ts index 2497e001c..d74c2b2d8 100644 --- a/client/src/app/shared/shared-user-settings/user-video-settings.component.ts +++ b/client/src/app/shared/shared-user-settings/user-video-settings.component.ts | |||
@@ -3,9 +3,10 @@ import { forkJoin, Subject, Subscription } from 'rxjs' | |||
3 | import { first } from 'rxjs/operators' | 3 | import { first } from 'rxjs/operators' |
4 | import { Component, Input, OnDestroy, OnInit } from '@angular/core' | 4 | import { Component, Input, OnDestroy, OnInit } from '@angular/core' |
5 | import { AuthService, Notifier, ServerService, User, UserService } from '@app/core' | 5 | import { AuthService, Notifier, ServerService, User, UserService } from '@app/core' |
6 | import { FormReactive, FormValidatorService, ItemSelectCheckboxValue, SelectOptionsItem } from '@app/shared/shared-forms' | 6 | import { FormReactive, FormValidatorService, ItemSelectCheckboxValue } from '@app/shared/shared-forms' |
7 | import { UserUpdateMe } from '@shared/models' | 7 | import { UserUpdateMe } from '@shared/models' |
8 | import { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type' | 8 | import { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type' |
9 | import { SelectOptionsItem } from '../../../types/select-options-item.model' | ||
9 | 10 | ||
10 | @Component({ | 11 | @Component({ |
11 | selector: 'my-user-video-settings', | 12 | selector: 'my-user-video-settings', |