- buildForm () {
- this.form = this.formBuilder.group({
- name: [ '', VIDEO_NAME.VALIDATORS ],
- nsfw: [ false ],
- category: [ '', VIDEO_CATEGORY.VALIDATORS ],
- licence: [ '', VIDEO_LICENCE.VALIDATORS ],
- language: [ '', VIDEO_LANGUAGE.VALIDATORS ],
- description: [ '', VIDEO_DESCRIPTION.VALIDATORS ],
- tags: [ '' ]
- })
-
- this.form.valueChanges.subscribe(data => this.onValueChanged(data))
+ ngOnInit () {
+ this.buildForm({})
+
+ this.serverService.videoPrivaciesLoaded
+ .subscribe(() => this.videoPrivacies = this.serverService.getVideoPrivacies())
+
+ this.route.data
+ .pipe(map(data => data.videoData))
+ .subscribe(({ video, videoChannels, videoCaptions }) => {
+ this.video = new VideoEdit(video)
+ this.userVideoChannels = videoChannels
+ this.videoCaptions = videoCaptions
+
+ // We cannot set private a video that was not private
+ if (this.video.privacy !== VideoPrivacy.PRIVATE) {
+ this.videoPrivacies = this.videoPrivacies.filter(p => p.id.toString() !== VideoPrivacy.PRIVATE.toString())
+ } else { // We can schedule video publication only if it it is private
+ this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE
+ }
+
+ // FIXME: Angular does not detect the change inside this subscription, so use the patched setTimeout
+ setTimeout(() => this.hydrateFormFromVideo())
+ },
+
+ err => {
+ console.error(err)
+ this.notificationsService.error(this.i18n('Error'), err.message)
+ }
+ )