aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-06-20 16:42:21 +0200
committerChocobozzz <me@florianbigard.com>2022-06-20 16:42:21 +0200
commit75084782b767f51f6158ada1984cf339c6302960 (patch)
tree178904ed08269de95683a063623d17cf87e56fad /client/src/app/shared
parent9bc3622320dc43474ce4b60c222ec25e6e657b97 (diff)
downloadPeerTube-75084782b767f51f6158ada1984cf339c6302960.tar.gz
PeerTube-75084782b767f51f6158ada1984cf339c6302960.tar.zst
PeerTube-75084782b767f51f6158ada1984cf339c6302960.zip
Handle input error in custom input text
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/shared-forms/dynamic-form-field.component.html4
-rw-r--r--client/src/app/shared/shared-forms/dynamic-form-field.component.ts11
-rw-r--r--client/src/app/shared/shared-forms/input-text.component.html3
-rw-r--r--client/src/app/shared/shared-forms/input-text.component.ts1
4 files changed, 17 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
index 61f9ae8ff..2dd6cf4ad 100644
--- a/client/src/app/shared/shared-forms/dynamic-form-field.component.html
+++ b/client/src/app/shared/shared-forms/dynamic-form-field.component.html
@@ -18,7 +18,7 @@
18 </select> 18 </select>
19 </div> 19 </div>
20 20
21 <my-input-text *ngIf="setting.type === 'input-password'" [formControlName]="setting.name" [inputId]="setting.name"></my-input-text> 21 <my-input-text *ngIf="setting.type === 'input-password'" [formError]="formErrors['settings.name']" [formControlName]="setting.name" [inputId]="setting.name"></my-input-text>
22 22
23 <textarea *ngIf="setting.type === 'input-textarea'" type="text" [id]="setting.name" [formControlName]="setting.name"></textarea> 23 <textarea *ngIf="setting.type === 'input-textarea'" type="text" [id]="setting.name" [formControlName]="setting.name"></textarea>
24 24
@@ -40,7 +40,7 @@
40 40
41 <div *ngIf="setting.type === 'html'" [innerHTML]="setting.html"></div> 41 <div *ngIf="setting.type === 'html'" [innerHTML]="setting.html"></div>
42 42
43 <div *ngIf="setting.type !== 'markdown-text' && setting.type !== 'markdown-enhanced' && formErrors[setting.name]" class="form-error"> 43 <div *ngIf="hasDedicatedFormError() && formErrors[setting.name]" class="form-error">
44 {{ formErrors[setting.name] }} 44 {{ formErrors[setting.name] }}
45 </div> 45 </div>
46 46
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
index b63890797..e1a1f8034 100644
--- a/client/src/app/shared/shared-forms/dynamic-form-field.component.ts
+++ b/client/src/app/shared/shared-forms/dynamic-form-field.component.ts
@@ -12,4 +12,15 @@ export class DynamicFormFieldComponent {
12 @Input() form: FormGroup 12 @Input() form: FormGroup
13 @Input() formErrors: any 13 @Input() formErrors: any
14 @Input() setting: RegisterClientFormFieldOptions 14 @Input() setting: RegisterClientFormFieldOptions
15
16 hasDedicatedFormError () {
17 const dedicated = new Set<RegisterClientFormFieldOptions['type']>([
18 'input-checkbox',
19 'input',
20 'select',
21 'input-textarea'
22 ])
23
24 return dedicated.has(this.setting.type)
25 }
15} 26}
diff --git a/client/src/app/shared/shared-forms/input-text.component.html b/client/src/app/shared/shared-forms/input-text.component.html
index f890c4f02..abb53a085 100644
--- a/client/src/app/shared/shared-forms/input-text.component.html
+++ b/client/src/app/shared/shared-forms/input-text.component.html
@@ -3,6 +3,7 @@
3 [id]="inputId" [autocomplete]="autocomplete" [value]="value" [placeholder]="placeholder" [tabindex]="tabindex" 3 [id]="inputId" [autocomplete]="autocomplete" [value]="value" [placeholder]="placeholder" [tabindex]="tabindex"
4 [(ngModel)]="value" (ngModelChange)="update()" [readonly]="readonly" 4 [(ngModel)]="value" (ngModelChange)="update()" [readonly]="readonly"
5 #input (click)="input.select()" (input)="update()" (change)="update()" [type]="inputType" class="form-control" 5 #input (click)="input.select()" (input)="update()" (change)="update()" [type]="inputType" class="form-control"
6 [ngClass]="{ 'input-error': formError }"
6 /> 7 />
7 8
8 <button *ngIf="withToggle" (click)="toggle()" type="button" class="btn btn-outline-secondary" [title]="toggleTitle"> 9 <button *ngIf="withToggle" (click)="toggle()" type="button" class="btn btn-outline-secondary" [title]="toggleTitle">
@@ -18,3 +19,5 @@
18 <span class="copy-text">Copy</span> 19 <span class="copy-text">Copy</span>
19 </button> 20 </button>
20</div> 21</div>
22
23<div *ngIf="formError" class="form-error">{{ formError }}</div>
diff --git a/client/src/app/shared/shared-forms/input-text.component.ts b/client/src/app/shared/shared-forms/input-text.component.ts
index ed4637c17..d667ed663 100644
--- a/client/src/app/shared/shared-forms/input-text.component.ts
+++ b/client/src/app/shared/shared-forms/input-text.component.ts
@@ -24,6 +24,7 @@ export class InputTextComponent implements ControlValueAccessor {
24 @Input() withCopy = false 24 @Input() withCopy = false
25 @Input() readonly = false 25 @Input() readonly = false
26 @Input() show = false 26 @Input() show = false
27 @Input() formError: string
27 28
28 constructor (private notifier: Notifier) { } 29 constructor (private notifier: Notifier) { }
29 30