aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-04-22 14:25:32 +0200
committerChocobozzz <me@florianbigard.com>2021-04-22 14:35:49 +0200
commit0f319334065fae8756fe7c7eec333000474d07ba (patch)
tree2ddc1fa8bdb9307b82cf52c91c86d3ba7a33cf62 /client/src/app/+videos/+video-edit/shared/video-edit.component.ts
parent87e0b71d36ae3d8f098c2be0ab45a29c9f2854b4 (diff)
downloadPeerTube-0f319334065fae8756fe7c7eec333000474d07ba.tar.gz
PeerTube-0f319334065fae8756fe7c7eec333000474d07ba.tar.zst
PeerTube-0f319334065fae8756fe7c7eec333000474d07ba.zip
Add ability to hide plugin form fields
Diffstat (limited to 'client/src/app/+videos/+video-edit/shared/video-edit.component.ts')
-rw-r--r--client/src/app/+videos/+video-edit/shared/video-edit.component.ts32
1 files changed, 22 insertions, 10 deletions
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 f51f52160..34119f7ab 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
@@ -2,7 +2,7 @@ import { forkJoin } from 'rxjs'
2import { map } from 'rxjs/operators' 2import { map } from 'rxjs/operators'
3import { SelectChannelItem } from 'src/types/select-options-item.model' 3import { SelectChannelItem } from 'src/types/select-options-item.model'
4import { Component, EventEmitter, Input, NgZone, OnDestroy, OnInit, Output, ViewChild } from '@angular/core' 4import { Component, EventEmitter, Input, NgZone, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'
5import { FormArray, FormControl, FormGroup, ValidatorFn, Validators } from '@angular/forms' 5import { FormArray, FormControl, FormGroup, Validators } from '@angular/forms'
6import { HooksService, PluginService, ServerService } from '@app/core' 6import { HooksService, PluginService, ServerService } from '@app/core'
7import { removeElementFromArray } from '@app/helpers' 7import { removeElementFromArray } from '@app/helpers'
8import { 8import {
@@ -21,13 +21,17 @@ import {
21import { FormReactiveValidationMessages, FormValidatorService } from '@app/shared/shared-forms' 21import { FormReactiveValidationMessages, FormValidatorService } from '@app/shared/shared-forms'
22import { InstanceService } from '@app/shared/shared-instance' 22import { InstanceService } from '@app/shared/shared-instance'
23import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main' 23import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main'
24import { LiveVideo, ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models' 24import { LiveVideo, ServerConfig, VideoConstant, VideoDetails, VideoPrivacy } from '@shared/models'
25import { RegisterClientFormFieldOptions, RegisterClientVideoFieldOptions } from '@shared/models/plugins/register-client-form-field.model' 25import { RegisterClientFormFieldOptions, RegisterClientVideoFieldOptions } from '@shared/models/plugins/register-client-form-field.model'
26import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service' 26import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service'
27import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component' 27import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component'
28import { VideoEditType } from './video-edit.type' 28import { VideoEditType } from './video-edit.type'
29 29
30type VideoLanguages = VideoConstant<string> & { group?: string } 30type VideoLanguages = VideoConstant<string> & { group?: string }
31type PluginField = {
32 commonOptions: RegisterClientFormFieldOptions
33 videoFormOptions: RegisterClientVideoFieldOptions
34}
31 35
32@Component({ 36@Component({
33 selector: 'my-video-edit', 37 selector: 'my-video-edit',
@@ -38,9 +42,14 @@ export class VideoEditComponent implements OnInit, OnDestroy {
38 @Input() form: FormGroup 42 @Input() form: FormGroup
39 @Input() formErrors: { [ id: string ]: string } = {} 43 @Input() formErrors: { [ id: string ]: string } = {}
40 @Input() validationMessages: FormReactiveValidationMessages = {} 44 @Input() validationMessages: FormReactiveValidationMessages = {}
45
46 @Input() videoToUpdate: VideoDetails
47
41 @Input() userVideoChannels: SelectChannelItem[] = [] 48 @Input() userVideoChannels: SelectChannelItem[] = []
42 @Input() schedulePublicationPossible = true 49 @Input() schedulePublicationPossible = true
50
43 @Input() videoCaptions: (VideoCaptionEdit & { captionPath?: string })[] = [] 51 @Input() videoCaptions: (VideoCaptionEdit & { captionPath?: string })[] = []
52
44 @Input() waitTranscodingEnabled = true 53 @Input() waitTranscodingEnabled = true
45 @Input() type: VideoEditType 54 @Input() type: VideoEditType
46 @Input() liveVideo: LiveVideo 55 @Input() liveVideo: LiveVideo
@@ -57,9 +66,6 @@ export class VideoEditComponent implements OnInit, OnDestroy {
57 videoLicences: VideoConstant<number>[] = [] 66 videoLicences: VideoConstant<number>[] = []
58 videoLanguages: VideoLanguages[] = [] 67 videoLanguages: VideoLanguages[] = []
59 68
60 tagValidators: ValidatorFn[]
61 tagValidatorsMessages: { [ name: string ]: string }
62
63 pluginDataFormGroup: FormGroup 69 pluginDataFormGroup: FormGroup
64 70
65 schedulePublicationEnabled = false 71 schedulePublicationEnabled = false
@@ -73,10 +79,7 @@ export class VideoEditComponent implements OnInit, OnDestroy {
73 79
74 serverConfig: ServerConfig 80 serverConfig: ServerConfig
75 81
76 pluginFields: { 82 pluginFields: PluginField[] = []
77 commonOptions: RegisterClientFormFieldOptions
78 videoFormOptions: RegisterClientVideoFieldOptions
79 }[] = []
80 83
81 private schedulerInterval: any 84 private schedulerInterval: any
82 private firstPatchDone = false 85 private firstPatchDone = false
@@ -92,7 +95,6 @@ export class VideoEditComponent implements OnInit, OnDestroy {
92 private ngZone: NgZone, 95 private ngZone: NgZone,
93 private hooks: HooksService 96 private hooks: HooksService
94 ) { 97 ) {
95 this.calendarLocale = this.i18nPrimengCalendarService.getCalendarLocale()
96 this.calendarTimezone = this.i18nPrimengCalendarService.getTimezone() 98 this.calendarTimezone = this.i18nPrimengCalendarService.getTimezone()
97 this.calendarDateFormat = this.i18nPrimengCalendarService.getDateFormat() 99 this.calendarDateFormat = this.i18nPrimengCalendarService.getDateFormat()
98 } 100 }
@@ -251,6 +253,16 @@ export class VideoEditComponent implements OnInit, OnDestroy {
251 return this.form.value['permanentLive'] === true 253 return this.form.value['permanentLive'] === true
252 } 254 }
253 255
256 isPluginFieldHidden (pluginField: PluginField) {
257 if (typeof pluginField.commonOptions.hidden !== 'function') return false
258
259 return pluginField.commonOptions.hidden({
260 formValues: this.form.value,
261 videoToUpdate: this.videoToUpdate,
262 liveVideo: this.liveVideo
263 })
264 }
265
254 private sortVideoCaptions () { 266 private sortVideoCaptions () {
255 this.videoCaptions.sort((v1, v2) => { 267 this.videoCaptions.sort((v1, v2) => {
256 if (v1.language.label < v2.language.label) return -1 268 if (v1.language.label < v2.language.label) return -1