diff options
author | Chocobozzz <me@florianbigard.com> | 2020-06-23 14:10:17 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-06-23 16:00:49 +0200 |
commit | 67ed6552b831df66713bac9e672738796128d33f (patch) | |
tree | 59c97d41e0b49d75a90aa3de987968ab9b1ff447 /client/src/app/shared/forms/form-validators/video-playlist-validators.service.ts | |
parent | 0c4bacbff53bc732f5a2677d62a6ead7752e2405 (diff) | |
download | PeerTube-67ed6552b831df66713bac9e672738796128d33f.tar.gz PeerTube-67ed6552b831df66713bac9e672738796128d33f.tar.zst PeerTube-67ed6552b831df66713bac9e672738796128d33f.zip |
Reorganize client shared modules
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.ts | 66 |
1 files changed, 0 insertions, 66 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 deleted file mode 100644 index a2c9a5368..000000000 --- a/client/src/app/shared/forms/form-validators/video-playlist-validators.service.ts +++ /dev/null | |||
@@ -1,66 +0,0 @@ | |||
1 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
2 | import { AbstractControl, FormControl, Validators } from '@angular/forms' | ||
3 | import { Injectable } from '@angular/core' | ||
4 | import { BuildFormValidator } from '@app/shared' | ||
5 | import { VideoPlaylistPrivacy } from '@shared/models' | ||
6 | |||
7 | @Injectable() | ||
8 | export class VideoPlaylistValidatorsService { | ||
9 | readonly VIDEO_PLAYLIST_DISPLAY_NAME: BuildFormValidator | ||
10 | readonly VIDEO_PLAYLIST_PRIVACY: BuildFormValidator | ||
11 | readonly VIDEO_PLAYLIST_DESCRIPTION: BuildFormValidator | ||
12 | readonly VIDEO_PLAYLIST_CHANNEL_ID: BuildFormValidator | ||
13 | |||
14 | constructor (private i18n: I18n) { | ||
15 | this.VIDEO_PLAYLIST_DISPLAY_NAME = { | ||
16 | VALIDATORS: [ | ||
17 | Validators.required, | ||
18 | Validators.minLength(1), | ||
19 | Validators.maxLength(120) | ||
20 | ], | ||
21 | MESSAGES: { | ||
22 | 'required': this.i18n('Display name is required.'), | ||
23 | 'minlength': this.i18n('Display name must be at least 1 character long.'), | ||
24 | 'maxlength': this.i18n('Display name cannot be more than 120 characters long.') | ||
25 | } | ||
26 | } | ||
27 | |||
28 | this.VIDEO_PLAYLIST_PRIVACY = { | ||
29 | VALIDATORS: [ | ||
30 | Validators.required | ||
31 | ], | ||
32 | MESSAGES: { | ||
33 | 'required': this.i18n('Privacy is required.') | ||
34 | } | ||
35 | } | ||
36 | |||
37 | this.VIDEO_PLAYLIST_DESCRIPTION = { | ||
38 | VALIDATORS: [ | ||
39 | Validators.minLength(3), | ||
40 | Validators.maxLength(1000) | ||
41 | ], | ||
42 | MESSAGES: { | ||
43 | 'minlength': i18n('Description must be at least 3 characters long.'), | ||
44 | 'maxlength': i18n('Description cannot be more than 1000 characters long.') | ||
45 | } | ||
46 | } | ||
47 | |||
48 | this.VIDEO_PLAYLIST_CHANNEL_ID = { | ||
49 | VALIDATORS: [ ], | ||
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) | ||
61 | } | ||
62 | |||
63 | channelControl.markAsDirty() | ||
64 | channelControl.updateValueAndValidity() | ||
65 | } | ||
66 | } | ||