aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts
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-video-channels/my-account-video-channel-update.component.ts
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-video-channels/my-account-video-channel-update.component.ts')
-rw-r--r--client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts32
1 files changed, 7 insertions, 25 deletions
diff --git a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts
index db38c7da9..eda03374a 100644
--- a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts
+++ b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts
@@ -2,7 +2,6 @@ import { Component, OnDestroy, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router' 2import { ActivatedRoute, Router } from '@angular/router'
3import { NotificationsService } from 'angular2-notifications' 3import { NotificationsService } from 'angular2-notifications'
4import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit' 4import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit'
5import { FormBuilder, FormGroup } from '@angular/forms'
6import { VideoChannelUpdate } from '../../../../../shared/models/videos' 5import { VideoChannelUpdate } from '../../../../../shared/models/videos'
7import { 6import {
8 VIDEO_CHANNEL_DESCRIPTION, 7 VIDEO_CHANNEL_DESCRIPTION,
@@ -14,6 +13,7 @@ import { Subscription } from 'rxjs'
14import { VideoChannel } from '@app/shared/video-channel/video-channel.model' 13import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
15import { AuthService } from '@app/core' 14import { AuthService } from '@app/core'
16import { I18n } from '@ngx-translate/i18n-polyfill' 15import { I18n } from '@ngx-translate/i18n-polyfill'
16import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
17 17
18@Component({ 18@Component({
19 selector: 'my-account-video-channel-update', 19 selector: 'my-account-video-channel-update',
@@ -23,45 +23,27 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
23export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelEdit implements OnInit, OnDestroy { 23export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelEdit implements OnInit, OnDestroy {
24 error: string 24 error: string
25 25
26 form: FormGroup
27 formErrors = {
28 'display-name': '',
29 'description': '',
30 'support': ''
31 }
32 validationMessages = {
33 'display-name': VIDEO_CHANNEL_DISPLAY_NAME.MESSAGES,
34 'description': VIDEO_CHANNEL_DESCRIPTION.MESSAGES,
35 'support': VIDEO_CHANNEL_SUPPORT.MESSAGES
36 }
37
38 private videoChannelToUpdate: VideoChannel 26 private videoChannelToUpdate: VideoChannel
39 private paramsSub: Subscription 27 private paramsSub: Subscription
40 28
41 constructor ( 29 constructor (
30 protected formValidatorService: FormValidatorService,
42 private authService: AuthService, 31 private authService: AuthService,
43 private notificationsService: NotificationsService, 32 private notificationsService: NotificationsService,
44 private router: Router, 33 private router: Router,
45 private route: ActivatedRoute, 34 private route: ActivatedRoute,
46 private formBuilder: FormBuilder,
47 private videoChannelService: VideoChannelService, 35 private videoChannelService: VideoChannelService,
48 private i18n: I18n 36 private i18n: I18n
49 ) { 37 ) {
50 super() 38 super()
51 } 39 }
52 40
53 buildForm () {
54 this.form = this.formBuilder.group({
55 'display-name': [ '', VIDEO_CHANNEL_DISPLAY_NAME.VALIDATORS ],
56 description: [ '', VIDEO_CHANNEL_DESCRIPTION.VALIDATORS ],
57 support: [ '', VIDEO_CHANNEL_SUPPORT.VALIDATORS ]
58 })
59
60 this.form.valueChanges.subscribe(data => this.onValueChanged(data))
61 }
62
63 ngOnInit () { 41 ngOnInit () {
64 this.buildForm() 42 this.buildForm({
43 'display-name': VIDEO_CHANNEL_DISPLAY_NAME,
44 description: VIDEO_CHANNEL_DESCRIPTION,
45 support: VIDEO_CHANNEL_SUPPORT
46 })
65 47
66 this.paramsSub = this.route.params.subscribe(routeParams => { 48 this.paramsSub = this.route.params.subscribe(routeParams => {
67 const videoChannelId = routeParams['videoChannelId'] 49 const videoChannelId = routeParams['videoChannelId']