X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fforms%2Fform-validators%2Fvideo-playlist-validators.service.ts;h=a2c9a5368926d00784f290a87ccea20bfb29a5d1;hb=978c9d497b36e52196eb7e755406571e5d57cbc7;hp=726084b47ef34c2f9ad63b4c97eccec69025a456;hpb=c5e4e36d2a1ad777233177c11f7f742df717a8e8;p=github%2FChocobozzz%2FPeerTube.git 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 @@ import { I18n } from '@ngx-translate/i18n-polyfill' -import { Validators } from '@angular/forms' +import { AbstractControl, FormControl, Validators } from '@angular/forms' import { Injectable } from '@angular/core' import { BuildFormValidator } from '@app/shared' +import { VideoPlaylistPrivacy } from '@shared/models' @Injectable() export class VideoPlaylistValidatorsService { @@ -46,7 +47,20 @@ export class VideoPlaylistValidatorsService { this.VIDEO_PLAYLIST_CHANNEL_ID = { VALIDATORS: [ ], - MESSAGES: { } + MESSAGES: { + 'required': this.i18n('The channel is required when the playlist is public.') + } + } + } + + setChannelValidator (channelControl: AbstractControl, privacy: VideoPlaylistPrivacy) { + if (privacy.toString() === VideoPlaylistPrivacy.PUBLIC.toString()) { + channelControl.setValidators([ Validators.required ]) + } else { + channelControl.setValidators(null) } + + channelControl.markAsDirty() + channelControl.updateValueAndValidity() } }