diff options
author | Chocobozzz <me@florianbigard.com> | 2018-06-05 10:58:45 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-06-05 10:58:45 +0200 |
commit | d18d64787b3ea174f7dc2740c8c8c9555625047e (patch) | |
tree | e65089e0ca81117c1ada981b9b8a524afa8d70f5 /client/src/app/+my-account/my-account-settings/my-account-change-password | |
parent | 25acef90a85c1584880dec96aa402f896af8364a (diff) | |
download | PeerTube-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-change-password')
-rw-r--r-- | client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts b/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts index 1a88aa82e..56e644f39 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component, 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_PASSWORD, UserService } from '../../../shared' | 3 | import { FormReactive, USER_PASSWORD, UserService } from '../../../shared' |
5 | import { I18n } from '@ngx-translate/i18n-polyfill' | 4 | import { I18n } from '@ngx-translate/i18n-polyfill' |
5 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' | ||
6 | 6 | ||
7 | @Component({ | 7 | @Component({ |
8 | selector: 'my-account-change-password', | 8 | selector: 'my-account-change-password', |
@@ -12,18 +12,8 @@ import { I18n } from '@ngx-translate/i18n-polyfill' | |||
12 | export class MyAccountChangePasswordComponent extends FormReactive implements OnInit { | 12 | export class MyAccountChangePasswordComponent extends FormReactive implements OnInit { |
13 | error: string = null | 13 | error: string = null |
14 | 14 | ||
15 | form: FormGroup | ||
16 | formErrors = { | ||
17 | 'new-password': '', | ||
18 | 'new-confirmed-password': '' | ||
19 | } | ||
20 | validationMessages = { | ||
21 | 'new-password': USER_PASSWORD.MESSAGES, | ||
22 | 'new-confirmed-password': USER_PASSWORD.MESSAGES | ||
23 | } | ||
24 | |||
25 | constructor ( | 15 | constructor ( |
26 | private formBuilder: FormBuilder, | 16 | protected formValidatorService: FormValidatorService, |
27 | private notificationsService: NotificationsService, | 17 | private notificationsService: NotificationsService, |
28 | private userService: UserService, | 18 | private userService: UserService, |
29 | private i18n: I18n | 19 | private i18n: I18n |
@@ -31,17 +21,11 @@ export class MyAccountChangePasswordComponent extends FormReactive implements On | |||
31 | super() | 21 | super() |
32 | } | 22 | } |
33 | 23 | ||
34 | buildForm () { | ||
35 | this.form = this.formBuilder.group({ | ||
36 | 'new-password': [ '', USER_PASSWORD.VALIDATORS ], | ||
37 | 'new-confirmed-password': [ '', USER_PASSWORD.VALIDATORS ] | ||
38 | }) | ||
39 | |||
40 | this.form.valueChanges.subscribe(data => this.onValueChanged(data)) | ||
41 | } | ||
42 | |||
43 | ngOnInit () { | 24 | ngOnInit () { |
44 | this.buildForm() | 25 | this.buildForm({ |
26 | 'new-password': USER_PASSWORD, | ||
27 | 'new-confirmed-password': USER_PASSWORD | ||
28 | }) | ||
45 | } | 29 | } |
46 | 30 | ||
47 | changePassword () { | 31 | changePassword () { |