diff options
author | Chocobozzz <me@florianbigard.com> | 2020-08-20 16:18:16 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-08-21 15:39:51 +0200 |
commit | 7294aab0c879ef96c0fde15c389a2c4c1463d3c7 (patch) | |
tree | bad1176720ee04266eba5470e9956e3a7871e349 /client/src/app/shared/shared-forms | |
parent | f95628636b6ccdf3eae2449ca718e075b072f678 (diff) | |
download | PeerTube-7294aab0c879ef96c0fde15c389a2c4c1463d3c7.tar.gz PeerTube-7294aab0c879ef96c0fde15c389a2c4c1463d3c7.tar.zst PeerTube-7294aab0c879ef96c0fde15c389a2c4c1463d3c7.zip |
Add ability to set custom field to video form
Diffstat (limited to 'client/src/app/shared/shared-forms')
4 files changed, 75 insertions, 2 deletions
diff --git a/client/src/app/shared/shared-forms/dynamic-form-field.component.html b/client/src/app/shared/shared-forms/dynamic-form-field.component.html new file mode 100644 index 000000000..c111ea7df --- /dev/null +++ b/client/src/app/shared/shared-forms/dynamic-form-field.component.html | |||
@@ -0,0 +1,35 @@ | |||
1 | <div [formGroup]="form"> | ||
2 | <label *ngIf="setting.type !== 'input-checkbox'" [attr.for]="setting.name" [innerHTML]="setting.label"></label> | ||
3 | |||
4 | <input *ngIf="setting.type === 'input'" type="text" [id]="setting.name" [formControlName]="setting.name" /> | ||
5 | |||
6 | <textarea *ngIf="setting.type === 'input-textarea'" type="text" [id]="setting.name" [formControlName]="setting.name"></textarea> | ||
7 | |||
8 | <my-help *ngIf="setting.type === 'markdown-text'" helpType="markdownText"></my-help> | ||
9 | |||
10 | <my-help *ngIf="setting.type === 'markdown-enhanced'" helpType="markdownEnhanced"></my-help> | ||
11 | |||
12 | <my-markdown-textarea | ||
13 | *ngIf="setting.type === 'markdown-text'" | ||
14 | markdownType="text" [id]="setting.name" [formControlName]="setting.name" textareaWidth="500px" | ||
15 | [classes]="{ 'input-error': formErrors['settings.name'] }" | ||
16 | ></my-markdown-textarea> | ||
17 | |||
18 | <my-markdown-textarea | ||
19 | *ngIf="setting.type === 'markdown-enhanced'" | ||
20 | markdownType="enhanced" [id]="setting.name" [formControlName]="setting.name" textareaWidth="500px" | ||
21 | [classes]="{ 'input-error': formErrors['settings.name'] }" | ||
22 | ></my-markdown-textarea> | ||
23 | |||
24 | <my-peertube-checkbox | ||
25 | *ngIf="setting.type === 'input-checkbox'" | ||
26 | [id]="setting.name" | ||
27 | [formControlName]="setting.name" | ||
28 | [labelInnerHTML]="setting.label" | ||
29 | ></my-peertube-checkbox> | ||
30 | |||
31 | <div *ngIf="formErrors[setting.name]" class="form-error"> | ||
32 | {{ formErrors[setting.name] }} | ||
33 | </div> | ||
34 | |||
35 | </div> | ||
diff --git a/client/src/app/shared/shared-forms/dynamic-form-field.component.scss b/client/src/app/shared/shared-forms/dynamic-form-field.component.scss new file mode 100644 index 000000000..70b3cf6c3 --- /dev/null +++ b/client/src/app/shared/shared-forms/dynamic-form-field.component.scss | |||
@@ -0,0 +1,18 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | input:not([type=submit]) { | ||
5 | @include peertube-input-text(340px); | ||
6 | |||
7 | display: block; | ||
8 | } | ||
9 | |||
10 | textarea { | ||
11 | @include peertube-textarea(340px, 200px); | ||
12 | |||
13 | display: block; | ||
14 | } | ||
15 | |||
16 | .peertube-select-container { | ||
17 | @include peertube-select-container(340px); | ||
18 | } | ||
diff --git a/client/src/app/shared/shared-forms/dynamic-form-field.component.ts b/client/src/app/shared/shared-forms/dynamic-form-field.component.ts new file mode 100644 index 000000000..b63890797 --- /dev/null +++ b/client/src/app/shared/shared-forms/dynamic-form-field.component.ts | |||
@@ -0,0 +1,15 @@ | |||
1 | import { Component, Input } from '@angular/core' | ||
2 | import { FormGroup } from '@angular/forms' | ||
3 | import { RegisterClientFormFieldOptions } from '@shared/models' | ||
4 | |||
5 | @Component({ | ||
6 | selector: 'my-dynamic-form-field', | ||
7 | templateUrl: './dynamic-form-field.component.html', | ||
8 | styleUrls: [ './dynamic-form-field.component.scss' ] | ||
9 | }) | ||
10 | |||
11 | export class DynamicFormFieldComponent { | ||
12 | @Input() form: FormGroup | ||
13 | @Input() formErrors: any | ||
14 | @Input() setting: RegisterClientFormFieldOptions | ||
15 | } | ||
diff --git a/client/src/app/shared/shared-forms/shared-form.module.ts b/client/src/app/shared/shared-forms/shared-form.module.ts index 1946ac21f..a28988f87 100644 --- a/client/src/app/shared/shared-forms/shared-form.module.ts +++ b/client/src/app/shared/shared-forms/shared-form.module.ts | |||
@@ -15,6 +15,7 @@ import { ReactiveFileComponent } from './reactive-file.component' | |||
15 | import { SelectChannelComponent, SelectCheckboxComponent, SelectOptionsComponent, SelectTagsComponent } from './select' | 15 | import { SelectChannelComponent, SelectCheckboxComponent, SelectOptionsComponent, SelectTagsComponent } from './select' |
16 | import { TextareaAutoResizeDirective } from './textarea-autoresize.directive' | 16 | import { TextareaAutoResizeDirective } from './textarea-autoresize.directive' |
17 | import { TimestampInputComponent } from './timestamp-input.component' | 17 | import { TimestampInputComponent } from './timestamp-input.component' |
18 | import { DynamicFormFieldComponent } from './dynamic-form-field.component' | ||
18 | 19 | ||
19 | @NgModule({ | 20 | @NgModule({ |
20 | imports: [ | 21 | imports: [ |
@@ -41,7 +42,9 @@ import { TimestampInputComponent } from './timestamp-input.component' | |||
41 | SelectChannelComponent, | 42 | SelectChannelComponent, |
42 | SelectOptionsComponent, | 43 | SelectOptionsComponent, |
43 | SelectTagsComponent, | 44 | SelectTagsComponent, |
44 | SelectCheckboxComponent | 45 | SelectCheckboxComponent, |
46 | |||
47 | DynamicFormFieldComponent | ||
45 | ], | 48 | ], |
46 | 49 | ||
47 | exports: [ | 50 | exports: [ |
@@ -63,7 +66,9 @@ import { TimestampInputComponent } from './timestamp-input.component' | |||
63 | SelectChannelComponent, | 66 | SelectChannelComponent, |
64 | SelectOptionsComponent, | 67 | SelectOptionsComponent, |
65 | SelectTagsComponent, | 68 | SelectTagsComponent, |
66 | SelectCheckboxComponent | 69 | SelectCheckboxComponent, |
70 | |||
71 | DynamicFormFieldComponent | ||
67 | ], | 72 | ], |
68 | 73 | ||
69 | providers: [ | 74 | providers: [ |