aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/forms/form-validators/video-playlist-validators.service.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-03-14 14:55:10 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-03-18 11:17:59 +0100
commit978c9d497b36e52196eb7e755406571e5d57cbc7 (patch)
tree6984ab06e2c64542221f7329f7560d9e8025e660 /client/src/app/shared/forms/form-validators/video-playlist-validators.service.ts
parentc5e4e36d2a1ad777233177c11f7f742df717a8e8 (diff)
downloadPeerTube-978c9d497b36e52196eb7e755406571e5d57cbc7.tar.gz
PeerTube-978c9d497b36e52196eb7e755406571e5d57cbc7.tar.zst
PeerTube-978c9d497b36e52196eb7e755406571e5d57cbc7.zip
Add playlist channel validator when playlist is public
Diffstat (limited to 'client/src/app/shared/forms/form-validators/video-playlist-validators.service.ts')
-rw-r--r--client/src/app/shared/forms/form-validators/video-playlist-validators.service.ts18
1 files changed, 16 insertions, 2 deletions
diff --git a/client/src/app/shared/forms/form-validators/video-playlist-validators.service.ts b/client/src/app/shared/forms/form-validators/video-playlist-validators.service.ts
index 726084b47..a2c9a5368 100644
--- a/client/src/app/shared/forms/form-validators/video-playlist-validators.service.ts
+++ b/client/src/app/shared/forms/form-validators/video-playlist-validators.service.ts
@@ -1,7 +1,8 @@
1import { I18n } from '@ngx-translate/i18n-polyfill' 1import { I18n } from '@ngx-translate/i18n-polyfill'
2import { Validators } from '@angular/forms' 2import { AbstractControl, FormControl, Validators } from '@angular/forms'
3import { Injectable } from '@angular/core' 3import { Injectable } from '@angular/core'
4import { BuildFormValidator } from '@app/shared' 4import { BuildFormValidator } from '@app/shared'
5import { VideoPlaylistPrivacy } from '@shared/models'
5 6
6@Injectable() 7@Injectable()
7export class VideoPlaylistValidatorsService { 8export class VideoPlaylistValidatorsService {
@@ -46,7 +47,20 @@ export class VideoPlaylistValidatorsService {
46 47
47 this.VIDEO_PLAYLIST_CHANNEL_ID = { 48 this.VIDEO_PLAYLIST_CHANNEL_ID = {
48 VALIDATORS: [ ], 49 VALIDATORS: [ ],
49 MESSAGES: { } 50 MESSAGES: {
51 'required': this.i18n('The channel is required when the playlist is public.')
52 }
53 }
54 }
55
56 setChannelValidator (channelControl: AbstractControl, privacy: VideoPlaylistPrivacy) {
57 if (privacy.toString() === VideoPlaylistPrivacy.PUBLIC.toString()) {
58 channelControl.setValidators([ Validators.required ])
59 } else {
60 channelControl.setValidators(null)
50 } 61 }
62
63 channelControl.markAsDirty()
64 channelControl.updateValueAndValidity()
51 } 65 }
52} 66}