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-video-settings | |
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-video-settings')
-rw-r--r-- | client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.ts | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.ts b/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.ts index 4588f73db..85b3a48cc 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.ts | |||
@@ -1,10 +1,11 @@ | |||
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 { UserUpdateMe } from '../../../../../../shared' | 3 | import { UserUpdateMe } from '../../../../../../shared' |
5 | import { AuthService } from '../../../core' | 4 | import { AuthService } from '../../../core' |
6 | import { FormReactive, User, UserService } from '../../../shared' | 5 | import { FormReactive, User, UserService } from '../../../shared' |
7 | import { I18n } from '@ngx-translate/i18n-polyfill' | 6 | import { I18n } from '@ngx-translate/i18n-polyfill' |
7 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' | ||
8 | import { Subject } from 'rxjs/Subject' | ||
8 | 9 | ||
9 | @Component({ | 10 | @Component({ |
10 | selector: 'my-account-video-settings', | 11 | selector: 'my-account-video-settings', |
@@ -13,14 +14,11 @@ import { I18n } from '@ngx-translate/i18n-polyfill' | |||
13 | }) | 14 | }) |
14 | export class MyAccountVideoSettingsComponent extends FormReactive implements OnInit { | 15 | export class MyAccountVideoSettingsComponent extends FormReactive implements OnInit { |
15 | @Input() user: User = null | 16 | @Input() user: User = null |
16 | 17 | @Input() userInformationLoaded: Subject<any> | |
17 | form: FormGroup | ||
18 | formErrors = {} | ||
19 | validationMessages = {} | ||
20 | 18 | ||
21 | constructor ( | 19 | constructor ( |
20 | protected formValidatorService: FormValidatorService, | ||
22 | private authService: AuthService, | 21 | private authService: AuthService, |
23 | private formBuilder: FormBuilder, | ||
24 | private notificationsService: NotificationsService, | 22 | private notificationsService: NotificationsService, |
25 | private userService: UserService, | 23 | private userService: UserService, |
26 | private i18n: I18n | 24 | private i18n: I18n |
@@ -28,17 +26,18 @@ export class MyAccountVideoSettingsComponent extends FormReactive implements OnI | |||
28 | super() | 26 | super() |
29 | } | 27 | } |
30 | 28 | ||
31 | buildForm () { | 29 | ngOnInit () { |
32 | this.form = this.formBuilder.group({ | 30 | this.buildForm({ |
33 | nsfwPolicy: [ this.user.nsfwPolicy ], | 31 | nsfwPolicy: null, |
34 | autoPlayVideo: [ this.user.autoPlayVideo ] | 32 | autoPlayVideo: null |
35 | }) | 33 | }) |
36 | 34 | ||
37 | this.form.valueChanges.subscribe(data => this.onValueChanged(data)) | 35 | this.userInformationLoaded.subscribe(() => { |
38 | } | 36 | this.form.patchValue({ |
39 | 37 | nsfwPolicy: this.user.nsfwPolicy, | |
40 | ngOnInit () { | 38 | autoPlayVideo: this.user.autoPlayVideo === true ? 'true' : 'false' |
41 | this.buildForm() | 39 | }) |
40 | }) | ||
42 | } | 41 | } |
43 | 42 | ||
44 | updateDetails () { | 43 | updateDetails () { |