aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-account/my-account-video-channels
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
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')
-rw-r--r--client/src/app/+my-account/my-account-video-channels/my-account-video-channel-create.component.ts32
-rw-r--r--client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts32
2 files changed, 14 insertions, 50 deletions
diff --git a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-create.component.ts b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-create.component.ts
index a4073728b..e38eaae9c 100644
--- a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-create.component.ts
+++ b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-create.component.ts
@@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core'
2import { Router } from '@angular/router' 2import { 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 { VideoChannelCreate } from '../../../../../shared/models/videos' 5import { VideoChannelCreate } from '../../../../../shared/models/videos'
7import { 6import {
8 VIDEO_CHANNEL_DESCRIPTION, 7 VIDEO_CHANNEL_DESCRIPTION,
@@ -12,6 +11,7 @@ import {
12import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' 11import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
13import { AuthService } from '@app/core' 12import { AuthService } from '@app/core'
14import { I18n } from '@ngx-translate/i18n-polyfill' 13import { I18n } from '@ngx-translate/i18n-polyfill'
14import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
15 15
16@Component({ 16@Component({
17 selector: 'my-account-video-channel-create', 17 selector: 'my-account-video-channel-create',
@@ -21,41 +21,23 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
21export class MyAccountVideoChannelCreateComponent extends MyAccountVideoChannelEdit implements OnInit { 21export class MyAccountVideoChannelCreateComponent extends MyAccountVideoChannelEdit implements OnInit {
22 error: string 22 error: string
23 23
24 form: FormGroup
25 formErrors = {
26 'display-name': '',
27 'description': '',
28 'support': ''
29 }
30 validationMessages = {
31 'display-name': VIDEO_CHANNEL_DISPLAY_NAME.MESSAGES,
32 'description': VIDEO_CHANNEL_DESCRIPTION.MESSAGES,
33 'support': VIDEO_CHANNEL_SUPPORT.MESSAGES
34 }
35
36 constructor ( 24 constructor (
25 protected formValidatorService: FormValidatorService,
37 private authService: AuthService, 26 private authService: AuthService,
38 private notificationsService: NotificationsService, 27 private notificationsService: NotificationsService,
39 private router: Router, 28 private router: Router,
40 private formBuilder: FormBuilder,
41 private videoChannelService: VideoChannelService, 29 private videoChannelService: VideoChannelService,
42 private i18n: I18n 30 private i18n: I18n
43 ) { 31 ) {
44 super() 32 super()
45 } 33 }
46 34
47 buildForm () {
48 this.form = this.formBuilder.group({
49 'display-name': [ '', VIDEO_CHANNEL_DISPLAY_NAME.VALIDATORS ],
50 description: [ '', VIDEO_CHANNEL_DESCRIPTION.VALIDATORS ],
51 support: [ '', VIDEO_CHANNEL_SUPPORT.VALIDATORS ]
52 })
53
54 this.form.valueChanges.subscribe(data => this.onValueChanged(data))
55 }
56
57 ngOnInit () { 35 ngOnInit () {
58 this.buildForm() 36 this.buildForm({
37 'display-name': VIDEO_CHANNEL_DISPLAY_NAME,
38 description: VIDEO_CHANNEL_DESCRIPTION,
39 support: VIDEO_CHANNEL_SUPPORT
40 })
59 } 41 }
60 42
61 formValidated () { 43 formValidated () {
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']