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/videos/+video-edit/video-add.component.ts | |
parent | 25acef90a85c1584880dec96aa402f896af8364a (diff) | |
download | PeerTube-d18d64787b3ea174f7dc2740c8c8c9555625047e.tar.gz PeerTube-d18d64787b3ea174f7dc2740c8c8c9555625047e.tar.zst PeerTube-d18d64787b3ea174f7dc2740c8c8c9555625047e.zip |
Form validators refractoring
Diffstat (limited to 'client/src/app/videos/+video-edit/video-add.component.ts')
-rw-r--r-- | client/src/app/videos/+video-edit/video-add.component.ts | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/client/src/app/videos/+video-edit/video-add.component.ts b/client/src/app/videos/+video-edit/video-add.component.ts index a615fd92c..332f757d7 100644 --- a/client/src/app/videos/+video-edit/video-add.component.ts +++ b/client/src/app/videos/+video-edit/video-add.component.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import { HttpEventType, HttpResponse } from '@angular/common/http' | 1 | import { HttpEventType, HttpResponse } from '@angular/common/http' |
2 | import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core' | 2 | import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core' |
3 | import { FormBuilder, FormGroup } from '@angular/forms' | ||
4 | import { Router } from '@angular/router' | 3 | import { Router } from '@angular/router' |
5 | import { UserService } from '@app/shared' | 4 | import { UserService } from '@app/shared' |
6 | import { CanComponentDeactivate } from '@app/shared/guards/can-deactivate-guard.service' | 5 | import { CanComponentDeactivate } from '@app/shared/guards/can-deactivate-guard.service' |
@@ -11,11 +10,11 @@ import { Subscription } from 'rxjs' | |||
11 | import { VideoPrivacy } from '../../../../../shared/models/videos' | 10 | import { VideoPrivacy } from '../../../../../shared/models/videos' |
12 | import { AuthService, ServerService } from '../../core' | 11 | import { AuthService, ServerService } from '../../core' |
13 | import { FormReactive } from '../../shared' | 12 | import { FormReactive } from '../../shared' |
14 | import { ValidatorMessage } from '../../shared/forms/form-validators/validator-message' | ||
15 | import { populateAsyncUserVideoChannels } from '../../shared/misc/utils' | 13 | import { populateAsyncUserVideoChannels } from '../../shared/misc/utils' |
16 | import { VideoEdit } from '../../shared/video/video-edit.model' | 14 | import { VideoEdit } from '../../shared/video/video-edit.model' |
17 | import { VideoService } from '../../shared/video/video.service' | 15 | import { VideoService } from '../../shared/video/video.service' |
18 | import { I18n } from '@ngx-translate/i18n-polyfill' | 16 | import { I18n } from '@ngx-translate/i18n-polyfill' |
17 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' | ||
19 | 18 | ||
20 | @Component({ | 19 | @Component({ |
21 | selector: 'my-videos-add', | 20 | selector: 'my-videos-add', |
@@ -39,10 +38,6 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy | |||
39 | } | 38 | } |
40 | videoFileName: string | 39 | videoFileName: string |
41 | 40 | ||
42 | form: FormGroup | ||
43 | formErrors: { [ id: string ]: string } = {} | ||
44 | validationMessages: ValidatorMessage = {} | ||
45 | |||
46 | userVideoChannels: { id: number, label: string, support: string }[] = [] | 41 | userVideoChannels: { id: number, label: string, support: string }[] = [] |
47 | userVideoQuotaUsed = 0 | 42 | userVideoQuotaUsed = 0 |
48 | videoPrivacies = [] | 43 | videoPrivacies = [] |
@@ -50,7 +45,7 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy | |||
50 | firstStepChannelId = 0 | 45 | firstStepChannelId = 0 |
51 | 46 | ||
52 | constructor ( | 47 | constructor ( |
53 | private formBuilder: FormBuilder, | 48 | protected formValidatorService: FormValidatorService, |
54 | private router: Router, | 49 | private router: Router, |
55 | private notificationsService: NotificationsService, | 50 | private notificationsService: NotificationsService, |
56 | private authService: AuthService, | 51 | private authService: AuthService, |
@@ -67,13 +62,8 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy | |||
67 | return this.serverService.getConfig().video.file.extensions.join(',') | 62 | return this.serverService.getConfig().video.file.extensions.join(',') |
68 | } | 63 | } |
69 | 64 | ||
70 | buildForm () { | ||
71 | this.form = this.formBuilder.group({}) | ||
72 | this.form.valueChanges.subscribe(data => this.onValueChanged(data)) | ||
73 | } | ||
74 | |||
75 | ngOnInit () { | 65 | ngOnInit () { |
76 | this.buildForm() | 66 | this.buildForm({}) |
77 | 67 | ||
78 | populateAsyncUserVideoChannels(this.authService, this.userVideoChannels) | 68 | populateAsyncUserVideoChannels(this.authService, this.userVideoChannels) |
79 | .then(() => this.firstStepChannelId = this.userVideoChannels[0].id) | 69 | .then(() => this.firstStepChannelId = this.userVideoChannels[0].id) |