aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-05 10:58:45 +0200
committerChocobozzz <me@florianbigard.com>2018-06-05 10:58:45 +0200
commitd18d64787b3ea174f7dc2740c8c8c9555625047e (patch)
treee65089e0ca81117c1ada981b9b8a524afa8d70f5 /client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts
parent25acef90a85c1584880dec96aa402f896af8364a (diff)
downloadPeerTube-d18d64787b3ea174f7dc2740c8c8c9555625047e.tar.gz
PeerTube-d18d64787b3ea174f7dc2740c8c8c9555625047e.tar.zst
PeerTube-d18d64787b3ea174f7dc2740c8c8c9555625047e.zip
Form validators refractoring
Diffstat (limited to 'client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts')
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts35
1 files changed, 14 insertions, 21 deletions
diff --git a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts
index 35843ecd9..1fe337da0 100644
--- a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts
+++ b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts
@@ -1,9 +1,10 @@
1import { Component, Input, OnInit } from '@angular/core' 1import { Component, Input, OnInit } from '@angular/core'
2import { FormBuilder, FormGroup } from '@angular/forms'
3import { NotificationsService } from 'angular2-notifications' 2import { NotificationsService } from 'angular2-notifications'
4import { FormReactive, USER_DESCRIPTION, USER_DISPLAY_NAME, UserService } from '../../../shared' 3import { FormReactive, USER_DESCRIPTION, USER_DISPLAY_NAME, UserService } from '../../../shared'
5import { User } from '@app/shared' 4import { User } from '@app/shared'
6import { I18n } from '@ngx-translate/i18n-polyfill' 5import { I18n } from '@ngx-translate/i18n-polyfill'
6import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
7import { Subject } from 'rxjs/Subject'
7 8
8@Component({ 9@Component({
9 selector: 'my-account-profile', 10 selector: 'my-account-profile',
@@ -12,21 +13,12 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
12}) 13})
13export class MyAccountProfileComponent extends FormReactive implements OnInit { 14export class MyAccountProfileComponent extends FormReactive implements OnInit {
14 @Input() user: User = null 15 @Input() user: User = null
16 @Input() userInformationLoaded: Subject<any>
15 17
16 error: string = null 18 error: string = null
17 19
18 form: FormGroup
19 formErrors = {
20 'display-name': '',
21 'description': ''
22 }
23 validationMessages = {
24 'display-name': USER_DISPLAY_NAME.MESSAGES,
25 'description': USER_DESCRIPTION.MESSAGES
26 }
27
28 constructor ( 20 constructor (
29 private formBuilder: FormBuilder, 21 protected formValidatorService: FormValidatorService,
30 private notificationsService: NotificationsService, 22 private notificationsService: NotificationsService,
31 private userService: UserService, 23 private userService: UserService,
32 private i18n: I18n 24 private i18n: I18n
@@ -34,17 +26,18 @@ export class MyAccountProfileComponent extends FormReactive implements OnInit {
34 super() 26 super()
35 } 27 }
36 28
37 buildForm () { 29 ngOnInit () {
38 this.form = this.formBuilder.group({ 30 this.buildForm({
39 'display-name': [ this.user.account.displayName, USER_DISPLAY_NAME.VALIDATORS ], 31 'display-name': USER_DISPLAY_NAME,
40 'description': [ this.user.account.description, USER_DESCRIPTION.VALIDATORS ] 32 description: USER_DESCRIPTION
41 }) 33 })
42 34
43 this.form.valueChanges.subscribe(data => this.onValueChanged(data)) 35 this.userInformationLoaded.subscribe(() => {
44 } 36 this.form.patchValue({
45 37 'display-name': this.user.account.displayName,
46 ngOnInit () { 38 description: this.user.account.description
47 this.buildForm() 39 })
40 })
48 } 41 }
49 42
50 updateMyProfile () { 43 updateMyProfile () {