diff options
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.ts | 35 |
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 @@ | |||
1 | import { Component, Input, OnInit } from '@angular/core' | 1 | import { Component, Input, OnInit } from '@angular/core' |
2 | import { FormBuilder, FormGroup } from '@angular/forms' | ||
3 | import { NotificationsService } from 'angular2-notifications' | 2 | import { NotificationsService } from 'angular2-notifications' |
4 | import { FormReactive, USER_DESCRIPTION, USER_DISPLAY_NAME, UserService } from '../../../shared' | 3 | import { FormReactive, USER_DESCRIPTION, USER_DISPLAY_NAME, UserService } from '../../../shared' |
5 | import { User } from '@app/shared' | 4 | import { User } from '@app/shared' |
6 | import { I18n } from '@ngx-translate/i18n-polyfill' | 5 | import { I18n } from '@ngx-translate/i18n-polyfill' |
6 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' | ||
7 | import { 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 | }) |
13 | export class MyAccountProfileComponent extends FormReactive implements OnInit { | 14 | export 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 () { |