aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-create.component.ts8
-rw-r--r--client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-edit.component.html14
-rw-r--r--client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-update.component.ts12
-rw-r--r--client/src/app/shared/forms/form-validators/video-playlist-validators.service.ts18
-rw-r--r--client/src/app/shared/video-playlist/video-add-to-playlist.component.html10
-rw-r--r--client/src/app/shared/video-playlist/video-add-to-playlist.component.ts6
6 files changed, 47 insertions, 21 deletions
diff --git a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-create.component.ts b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-create.component.ts
index 61b61e221..87a10961f 100644
--- a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-create.component.ts
+++ b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-create.component.ts
@@ -35,13 +35,17 @@ export class MyAccountVideoPlaylistCreateComponent extends MyAccountVideoPlaylis
35 35
36 ngOnInit () { 36 ngOnInit () {
37 this.buildForm({ 37 this.buildForm({
38 'display-name': this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DISPLAY_NAME, 38 displayName: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DISPLAY_NAME,
39 privacy: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_PRIVACY, 39 privacy: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_PRIVACY,
40 description: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DESCRIPTION, 40 description: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DESCRIPTION,
41 videoChannelId: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_CHANNEL_ID, 41 videoChannelId: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_CHANNEL_ID,
42 thumbnailfile: null 42 thumbnailfile: null
43 }) 43 })
44 44
45 this.form.get('privacy').valueChanges.subscribe(privacy => {
46 this.videoPlaylistValidatorsService.setChannelValidator(this.form.get('videoChannelId'), privacy)
47 })
48
45 populateAsyncUserVideoChannels(this.authService, this.userVideoChannels) 49 populateAsyncUserVideoChannels(this.authService, this.userVideoChannels)
46 50
47 this.serverService.videoPlaylistPrivaciesLoaded.subscribe( 51 this.serverService.videoPlaylistPrivaciesLoaded.subscribe(
@@ -60,7 +64,7 @@ export class MyAccountVideoPlaylistCreateComponent extends MyAccountVideoPlaylis
60 64
61 const body = this.form.value 65 const body = this.form.value
62 const videoPlaylistCreate: VideoPlaylistCreate = { 66 const videoPlaylistCreate: VideoPlaylistCreate = {
63 displayName: body['display-name'], 67 displayName: body.displayName,
64 privacy: body.privacy, 68 privacy: body.privacy,
65 description: body.description || null, 69 description: body.description || null,
66 videoChannelId: body.videoChannelId || null, 70 videoChannelId: body.videoChannelId || null,
diff --git a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-edit.component.html b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-edit.component.html
index 5d1184218..303fc46f7 100644
--- a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-edit.component.html
+++ b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-edit.component.html
@@ -6,13 +6,13 @@
6 <div class="row"> 6 <div class="row">
7 <div class="col-md-12 col-xl-6"> 7 <div class="col-md-12 col-xl-6">
8 <div class="form-group"> 8 <div class="form-group">
9 <label i18n for="display-name">Display name</label> 9 <label i18n for="displayName">Display name</label>
10 <input 10 <input
11 type="text" id="display-name" 11 type="text" id="displayName"
12 formControlName="display-name" [ngClass]="{ 'input-error': formErrors['display-name'] }" 12 formControlName="displayName" [ngClass]="{ 'input-error': formErrors['displayName'] }"
13 > 13 >
14 <div *ngIf="formErrors['display-name']" class="form-error"> 14 <div *ngIf="formErrors['displayName']" class="form-error">
15 {{ formErrors['display-name'] }} 15 {{ formErrors['displayName'] }}
16 </div> 16 </div>
17 </div> 17 </div>
18 18
@@ -50,6 +50,10 @@
50 <option *ngFor="let channel of userVideoChannels" [value]="channel.id">{{ channel.label }}</option> 50 <option *ngFor="let channel of userVideoChannels" [value]="channel.id">{{ channel.label }}</option>
51 </select> 51 </select>
52 </div> 52 </div>
53
54 <div *ngIf="formErrors['videoChannelId']" class="form-error">
55 {{ formErrors['videoChannelId'] }}
56 </div>
53 </div> 57 </div>
54 58
55 <div class="form-group"> 59 <div class="form-group">
diff --git a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-update.component.ts b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-update.component.ts
index 167d7dd09..4887fdfb4 100644
--- a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-update.component.ts
+++ b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-update.component.ts
@@ -41,13 +41,17 @@ export class MyAccountVideoPlaylistUpdateComponent extends MyAccountVideoPlaylis
41 41
42 ngOnInit () { 42 ngOnInit () {
43 this.buildForm({ 43 this.buildForm({
44 'display-name': this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DISPLAY_NAME, 44 displayName: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DISPLAY_NAME,
45 privacy: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_PRIVACY, 45 privacy: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_PRIVACY,
46 description: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DESCRIPTION, 46 description: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DESCRIPTION,
47 videoChannelId: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_CHANNEL_ID, 47 videoChannelId: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_CHANNEL_ID,
48 thumbnailfile: null 48 thumbnailfile: null
49 }) 49 })
50 50
51 this.form.get('privacy').valueChanges.subscribe(privacy => {
52 this.videoPlaylistValidatorsService.setChannelValidator(this.form.get('videoChannelId'), privacy)
53 })
54
51 populateAsyncUserVideoChannels(this.authService, this.userVideoChannels) 55 populateAsyncUserVideoChannels(this.authService, this.userVideoChannels)
52 56
53 this.paramsSub = this.route.params.subscribe(routeParams => { 57 this.paramsSub = this.route.params.subscribe(routeParams => {
@@ -85,8 +89,8 @@ export class MyAccountVideoPlaylistUpdateComponent extends MyAccountVideoPlaylis
85 89
86 const body = this.form.value 90 const body = this.form.value
87 const videoPlaylistUpdate: VideoPlaylistUpdate = { 91 const videoPlaylistUpdate: VideoPlaylistUpdate = {
88 displayName: body['display-name'], 92 displayName: body.displayName,
89 privacy: body['privacy'], 93 privacy: body.privacy,
90 description: body.description || null, 94 description: body.description || null,
91 videoChannelId: body.videoChannelId || null, 95 videoChannelId: body.videoChannelId || null,
92 thumbnailfile: body.thumbnailfile || undefined 96 thumbnailfile: body.thumbnailfile || undefined
@@ -115,7 +119,7 @@ export class MyAccountVideoPlaylistUpdateComponent extends MyAccountVideoPlaylis
115 119
116 private hydrateFormFromPlaylist () { 120 private hydrateFormFromPlaylist () {
117 this.form.patchValue({ 121 this.form.patchValue({
118 'display-name': this.videoPlaylistToUpdate.displayName, 122 displayName: this.videoPlaylistToUpdate.displayName,
119 privacy: this.videoPlaylistToUpdate.privacy.id, 123 privacy: this.videoPlaylistToUpdate.privacy.id,
120 description: this.videoPlaylistToUpdate.description, 124 description: this.videoPlaylistToUpdate.description,
121 videoChannelId: this.videoPlaylistToUpdate.videoChannel ? this.videoPlaylistToUpdate.videoChannel.id : null 125 videoChannelId: this.videoPlaylistToUpdate.videoChannel ? this.videoPlaylistToUpdate.videoChannel.id : null
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}
diff --git a/client/src/app/shared/video-playlist/video-add-to-playlist.component.html b/client/src/app/shared/video-playlist/video-add-to-playlist.component.html
index f85e50d6d..19b326206 100644
--- a/client/src/app/shared/video-playlist/video-add-to-playlist.component.html
+++ b/client/src/app/shared/video-playlist/video-add-to-playlist.component.html
@@ -60,13 +60,13 @@
60 60
61<form class="new-playlist-block dropdown-item" *ngIf="isNewPlaylistBlockOpened" (ngSubmit)="createPlaylist()" [formGroup]="form"> 61<form class="new-playlist-block dropdown-item" *ngIf="isNewPlaylistBlockOpened" (ngSubmit)="createPlaylist()" [formGroup]="form">
62 <div class="form-group"> 62 <div class="form-group">
63 <label i18n for="display-name">Display name</label> 63 <label i18n for="displayName">Display name</label>
64 <input 64 <input
65 type="text" id="display-name" 65 type="text" id="displayName"
66 formControlName="display-name" [ngClass]="{ 'input-error': formErrors['display-name'] }" 66 formControlName="displayName" [ngClass]="{ 'input-error': formErrors['displayName'] }"
67 > 67 >
68 <div *ngIf="formErrors['display-name']" class="form-error"> 68 <div *ngIf="formErrors['displayName']" class="form-error">
69 {{ formErrors['display-name'] }} 69 {{ formErrors['displayName'] }}
70 </div> 70 </div>
71 </div> 71 </div>
72 72
diff --git a/client/src/app/shared/video-playlist/video-add-to-playlist.component.ts b/client/src/app/shared/video-playlist/video-add-to-playlist.component.ts
index c6fb6dbed..705f62404 100644
--- a/client/src/app/shared/video-playlist/video-add-to-playlist.component.ts
+++ b/client/src/app/shared/video-playlist/video-add-to-playlist.component.ts
@@ -5,7 +5,7 @@ import { forkJoin } from 'rxjs'
5import { Video, VideoPlaylistCreate, VideoPlaylistElementCreate, VideoPlaylistPrivacy } from '@shared/models' 5import { Video, VideoPlaylistCreate, VideoPlaylistElementCreate, VideoPlaylistPrivacy } from '@shared/models'
6import { FormReactive, FormValidatorService, VideoPlaylistValidatorsService } from '@app/shared/forms' 6import { FormReactive, FormValidatorService, VideoPlaylistValidatorsService } from '@app/shared/forms'
7import { I18n } from '@ngx-translate/i18n-polyfill' 7import { I18n } from '@ngx-translate/i18n-polyfill'
8import { secondsToTime, timeToInt } from '../../../assets/player/utils' 8import { secondsToTime } from '../../../assets/player/utils'
9 9
10type PlaylistSummary = { 10type PlaylistSummary = {
11 id: number 11 id: number
@@ -54,7 +54,7 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit
54 this.resetOptions(true) 54 this.resetOptions(true)
55 55
56 this.buildForm({ 56 this.buildForm({
57 'display-name': this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DISPLAY_NAME 57 displayName: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DISPLAY_NAME
58 }) 58 })
59 59
60 forkJoin([ 60 forkJoin([
@@ -105,7 +105,7 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit
105 } 105 }
106 106
107 createPlaylist () { 107 createPlaylist () {
108 const displayName = this.form.value[ 'display-name' ] 108 const displayName = this.form.value[ 'displayName' ]
109 109
110 const videoPlaylistCreate: VideoPlaylistCreate = { 110 const videoPlaylistCreate: VideoPlaylistCreate = {
111 displayName, 111 displayName,