aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-account/my-account-settings/my-account-change-password
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-change-password
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-change-password')
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts28
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 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { FormBuilder, FormGroup } from '@angular/forms'
3import { NotificationsService } from 'angular2-notifications' 2import { NotificationsService } from 'angular2-notifications'
4import { FormReactive, USER_PASSWORD, UserService } from '../../../shared' 3import { FormReactive, USER_PASSWORD, UserService } from '../../../shared'
5import { I18n } from '@ngx-translate/i18n-polyfill' 4import { I18n } from '@ngx-translate/i18n-polyfill'
5import { 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'
12export class MyAccountChangePasswordComponent extends FormReactive implements OnInit { 12export 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 () {