aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-forms
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-08-17 14:42:53 +0200
committerChocobozzz <me@florianbigard.com>2021-08-18 08:35:06 +0200
commit9df52d660feb722404be00a50f3c8a612bec1c15 (patch)
treedde52880fa012874d24c60f64eb596b0a789cc8b /client/src/app/shared/shared-forms
parentadb8809d43648ea0a64d6845bb39aa3bd0e005a6 (diff)
downloadPeerTube-9df52d660feb722404be00a50f3c8a612bec1c15.tar.gz
PeerTube-9df52d660feb722404be00a50f3c8a612bec1c15.tar.zst
PeerTube-9df52d660feb722404be00a50f3c8a612bec1c15.zip
Migrate client to eslint
Diffstat (limited to 'client/src/app/shared/shared-forms')
-rw-r--r--client/src/app/shared/shared-forms/form-reactive.ts6
-rw-r--r--client/src/app/shared/shared-forms/form-validator.service.ts8
-rw-r--r--client/src/app/shared/shared-forms/reactive-file.component.ts2
3 files changed, 8 insertions, 8 deletions
diff --git a/client/src/app/shared/shared-forms/form-reactive.ts b/client/src/app/shared/shared-forms/form-reactive.ts
index adf6cb894..f2ce82360 100644
--- a/client/src/app/shared/shared-forms/form-reactive.ts
+++ b/client/src/app/shared/shared-forms/form-reactive.ts
@@ -51,7 +51,7 @@ export abstract class FormReactive {
51 } 51 }
52 52
53 // clear previous error message (if any) 53 // clear previous error message (if any)
54 formErrors[ field ] = '' 54 formErrors[field] = ''
55 const control = form.get(field) 55 const control = form.get(field)
56 56
57 if (control.dirty) this.formChanged = true 57 if (control.dirty) this.formChanged = true
@@ -59,9 +59,9 @@ export abstract class FormReactive {
59 // Don't care if dirty on force check 59 // Don't care if dirty on force check
60 const isDirty = control.dirty || forceCheck === true 60 const isDirty = control.dirty || forceCheck === true
61 if (control && isDirty && control.enabled && !control.valid) { 61 if (control && isDirty && control.enabled && !control.valid) {
62 const messages = validationMessages[ field ] 62 const messages = validationMessages[field]
63 for (const key of Object.keys(control.errors)) { 63 for (const key of Object.keys(control.errors)) {
64 formErrors[ field ] += messages[ key ] + ' ' 64 formErrors[field] += messages[key] + ' '
65 } 65 }
66 } 66 }
67 } 67 }
diff --git a/client/src/app/shared/shared-forms/form-validator.service.ts b/client/src/app/shared/shared-forms/form-validator.service.ts
index 41c8b76bd..c0664de5f 100644
--- a/client/src/app/shared/shared-forms/form-validator.service.ts
+++ b/client/src/app/shared/shared-forms/form-validator.service.ts
@@ -28,11 +28,11 @@ export class FormValidatorService {
28 continue 28 continue
29 } 29 }
30 30
31 if (field && field.MESSAGES) validationMessages[name] = field.MESSAGES as { [ name: string ]: string } 31 if (field?.MESSAGES) validationMessages[name] = field.MESSAGES as { [ name: string ]: string }
32 32
33 const defaultValue = defaultValues[name] || '' 33 const defaultValue = defaultValues[name] || ''
34 34
35 if (field && field.VALIDATORS) group[name] = [ defaultValue, field.VALIDATORS ] 35 if (field?.VALIDATORS) group[name] = [ defaultValue, field.VALIDATORS ]
36 else group[name] = [ defaultValue ] 36 else group[name] = [ defaultValue ]
37 } 37 }
38 38
@@ -62,11 +62,11 @@ export class FormValidatorService {
62 continue 62 continue
63 } 63 }
64 64
65 if (field && field.MESSAGES) validationMessages[name] = field.MESSAGES as { [ name: string ]: string } 65 if (field?.MESSAGES) validationMessages[name] = field.MESSAGES as { [ name: string ]: string }
66 66
67 const defaultValue = defaultValues[name] || '' 67 const defaultValue = defaultValues[name] || ''
68 68
69 if (field && field.VALIDATORS) form.addControl(name, new FormControl(defaultValue, field.VALIDATORS as ValidatorFn[])) 69 if (field?.VALIDATORS) form.addControl(name, new FormControl(defaultValue, field.VALIDATORS as ValidatorFn[]))
70 else form.addControl(name, new FormControl(defaultValue)) 70 else form.addControl(name, new FormControl(defaultValue))
71 } 71 }
72 } 72 }
diff --git a/client/src/app/shared/shared-forms/reactive-file.component.ts b/client/src/app/shared/shared-forms/reactive-file.component.ts
index fac3dfb3a..9d27ad07a 100644
--- a/client/src/app/shared/shared-forms/reactive-file.component.ts
+++ b/client/src/app/shared/shared-forms/reactive-file.component.ts
@@ -43,7 +43,7 @@ export class ReactiveFileComponent implements OnInit, ControlValueAccessor {
43 } 43 }
44 44
45 fileChange (event: any) { 45 fileChange (event: any) {
46 if (event.target.files && event.target.files.length) { 46 if (event.target.files?.length) {
47 const [ file ] = event.target.files 47 const [ file ] = event.target.files
48 48
49 if (file.size > this.maxFileSize) { 49 if (file.size > this.maxFileSize) {