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-channels/my-account-video-channel-edit.component.html5
-rw-r--r--client/src/app/shared/forms/markdown-textarea.component.scss1
-rw-r--r--client/src/app/shared/misc/utils.ts4
-rw-r--r--client/src/app/videos/+video-edit/shared/video-edit.component.ts38
-rw-r--r--client/src/app/videos/+video-edit/video-add.component.ts2
-rw-r--r--client/src/app/videos/+video-edit/video-update.component.ts2
6 files changed, 46 insertions, 6 deletions
diff --git a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-edit.component.html b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-edit.component.html
index d5fb6262a..10d408d55 100644
--- a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-edit.component.html
+++ b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-edit.component.html
@@ -28,7 +28,10 @@
28 28
29 <div class="form-group"> 29 <div class="form-group">
30 <label for="support">Support</label> 30 <label for="support">Support</label>
31 <my-help helpType="markdownEnhanced" preHtml="Short text to tell people how they can support your channel (membership platform...)."></my-help> 31 <my-help
32 helpType="markdownEnhanced" preHtml="Short text to tell people how they can support your channel (membership platform...).<br /><br />
33When you will upload a video in this channel, the video support field will be automatically filled by this text."
34 ></my-help>
32 <my-markdown-textarea 35 <my-markdown-textarea
33 id="support" formControlName="support" textareaWidth="500px" [previewColumn]="true" markdownType="enhanced" 36 id="support" formControlName="support" textareaWidth="500px" [previewColumn]="true" markdownType="enhanced"
34 [classes]="{ 'input-error': formErrors['support'] }" 37 [classes]="{ 'input-error': formErrors['support'] }"
diff --git a/client/src/app/shared/forms/markdown-textarea.component.scss b/client/src/app/shared/forms/markdown-textarea.component.scss
index 9c92a67d9..118b38b91 100644
--- a/client/src/app/shared/forms/markdown-textarea.component.scss
+++ b/client/src/app/shared/forms/markdown-textarea.component.scss
@@ -13,6 +13,7 @@
13 .previews { 13 .previews {
14 max-height: 150px; 14 max-height: 150px;
15 overflow-y: auto; 15 overflow-y: auto;
16 flex-grow: 1;
16 } 17 }
17 18
18 /deep/ { 19 /deep/ {
diff --git a/client/src/app/shared/misc/utils.ts b/client/src/app/shared/misc/utils.ts
index 727e33935..11933e90b 100644
--- a/client/src/app/shared/misc/utils.ts
+++ b/client/src/app/shared/misc/utils.ts
@@ -17,7 +17,7 @@ function getParameterByName (name: string, url: string) {
17 return decodeURIComponent(results[2].replace(/\+/g, ' ')) 17 return decodeURIComponent(results[2].replace(/\+/g, ' '))
18} 18}
19 19
20function populateAsyncUserVideoChannels (authService: AuthService, channel: any[]) { 20function populateAsyncUserVideoChannels (authService: AuthService, channel: { id: number, label: string, support: string }[]) {
21 return new Promise(res => { 21 return new Promise(res => {
22 authService.userInformationLoaded 22 authService.userInformationLoaded
23 .subscribe( 23 .subscribe(
@@ -28,7 +28,7 @@ function populateAsyncUserVideoChannels (authService: AuthService, channel: any[
28 const videoChannels = user.videoChannels 28 const videoChannels = user.videoChannels
29 if (Array.isArray(videoChannels) === false) return 29 if (Array.isArray(videoChannels) === false) return
30 30
31 videoChannels.forEach(c => channel.push({ id: c.id, label: c.displayName })) 31 videoChannels.forEach(c => channel.push({ id: c.id, label: c.displayName, support: c.support }))
32 32
33 return res() 33 return res()
34 } 34 }
diff --git a/client/src/app/videos/+video-edit/shared/video-edit.component.ts b/client/src/app/videos/+video-edit/shared/video-edit.component.ts
index d4567e26c..ccfae5fcc 100644
--- a/client/src/app/videos/+video-edit/shared/video-edit.component.ts
+++ b/client/src/app/videos/+video-edit/shared/video-edit.component.ts
@@ -16,6 +16,7 @@ import {
16 VIDEO_TAGS 16 VIDEO_TAGS
17} from '../../../shared/forms/form-validators/video' 17} from '../../../shared/forms/form-validators/video'
18import { VideoEdit } from '../../../shared/video/video-edit.model' 18import { VideoEdit } from '../../../shared/video/video-edit.model'
19import { map } from 'rxjs/operators'
19 20
20@Component({ 21@Component({
21 selector: 'my-video-edit', 22 selector: 'my-video-edit',
@@ -28,7 +29,7 @@ export class VideoEditComponent implements OnInit {
28 @Input() formErrors: { [ id: string ]: string } = {} 29 @Input() formErrors: { [ id: string ]: string } = {}
29 @Input() validationMessages: ValidatorMessage = {} 30 @Input() validationMessages: ValidatorMessage = {}
30 @Input() videoPrivacies = [] 31 @Input() videoPrivacies = []
31 @Input() userVideoChannels = [] 32 @Input() userVideoChannels: { id: number, label: string, support: string }[] = []
32 33
33 videoCategories = [] 34 videoCategories = []
34 videoLicences = [] 35 videoLicences = []
@@ -84,6 +85,37 @@ export class VideoEditComponent implements OnInit {
84 this.form.addControl('thumbnailfile', new FormControl('')) 85 this.form.addControl('thumbnailfile', new FormControl(''))
85 this.form.addControl('previewfile', new FormControl('')) 86 this.form.addControl('previewfile', new FormControl(''))
86 this.form.addControl('support', new FormControl('', VIDEO_SUPPORT.VALIDATORS)) 87 this.form.addControl('support', new FormControl('', VIDEO_SUPPORT.VALIDATORS))
88
89 // We will update the "support" field depending on the channel
90 this.form.controls['channelId']
91 .valueChanges
92 .pipe(map(res => parseInt(res.toString(), 10)))
93 .subscribe(
94 newChannelId => {
95 const oldChannelId = parseInt(this.form.value['channelId'], 10)
96 const currentSupport = this.form.value['support']
97
98 // Not initialized yet
99 if (isNaN(newChannelId)) return
100 const newChannel = this.userVideoChannels.find(c => c.id === newChannelId)
101
102 // First time we set the channel?
103 if (isNaN(oldChannelId)) return this.updateSupportField(newChannel.support)
104 const oldChannel = this.userVideoChannels.find(c => c.id === oldChannelId)
105
106 if (!newChannel || !oldChannel) {
107 console.error('Cannot find new or old channel.')
108 return
109 }
110
111 // If the current support text is not the same than the old channel, the user updated it.
112 // We don't want the user to lose his text, so stop here
113 if (currentSupport && currentSupport !== oldChannel.support) return
114
115 // Update the support text with our new channel
116 this.updateSupportField(newChannel.support)
117 }
118 )
87 } 119 }
88 120
89 ngOnInit () { 121 ngOnInit () {
@@ -93,4 +125,8 @@ export class VideoEditComponent implements OnInit {
93 this.videoLicences = this.serverService.getVideoLicences() 125 this.videoLicences = this.serverService.getVideoLicences()
94 this.videoLanguages = this.serverService.getVideoLanguages() 126 this.videoLanguages = this.serverService.getVideoLanguages()
95 } 127 }
128
129 private updateSupportField (support: string) {
130 return this.form.patchValue({ support: support || '' })
131 }
96} 132}
diff --git a/client/src/app/videos/+video-edit/video-add.component.ts b/client/src/app/videos/+video-edit/video-add.component.ts
index 032504cea..997f033b7 100644
--- a/client/src/app/videos/+video-edit/video-add.component.ts
+++ b/client/src/app/videos/+video-edit/video-add.component.ts
@@ -42,7 +42,7 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy
42 formErrors: { [ id: string ]: string } = {} 42 formErrors: { [ id: string ]: string } = {}
43 validationMessages: ValidatorMessage = {} 43 validationMessages: ValidatorMessage = {}
44 44
45 userVideoChannels = [] 45 userVideoChannels: { id: number, label: string, support: string }[] = []
46 userVideoQuotaUsed = 0 46 userVideoQuotaUsed = 0
47 videoPrivacies = [] 47 videoPrivacies = []
48 firstStepPrivacyId = 0 48 firstStepPrivacyId = 0
diff --git a/client/src/app/videos/+video-edit/video-update.component.ts b/client/src/app/videos/+video-edit/video-update.component.ts
index 339da1bf4..310285f92 100644
--- a/client/src/app/videos/+video-edit/video-update.component.ts
+++ b/client/src/app/videos/+video-edit/video-update.component.ts
@@ -66,7 +66,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
66 .listAccountVideoChannels(video.account) 66 .listAccountVideoChannels(video.account)
67 .pipe( 67 .pipe(
68 map(result => result.data), 68 map(result => result.data),
69 map(videoChannels => videoChannels.map(c => ({ id: c.id, label: c.displayName }))), 69 map(videoChannels => videoChannels.map(c => ({ id: c.id, label: c.displayName, support: c.support }))),
70 map(videoChannels => ({ video, videoChannels })) 70 map(videoChannels => ({ video, videoChannels }))
71 ) 71 )
72 }) 72 })