diff options
Diffstat (limited to 'client/src/app/videos/+video-edit/video-update.component.ts')
-rw-r--r-- | client/src/app/videos/+video-edit/video-update.component.ts | 46 |
1 files changed, 6 insertions, 40 deletions
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 017781866..01ab0a716 100644 --- a/client/src/app/videos/+video-edit/video-update.component.ts +++ b/client/src/app/videos/+video-edit/video-update.component.ts | |||
@@ -15,6 +15,7 @@ import { | |||
15 | VIDEO_PRIVACY, | 15 | VIDEO_PRIVACY, |
16 | VIDEO_TAGS | 16 | VIDEO_TAGS |
17 | } from '../../shared' | 17 | } from '../../shared' |
18 | import { ValidatorMessage } from '../../shared/forms/form-validators' | ||
18 | import { VideoService } from '../../shared/video/video.service' | 19 | import { VideoService } from '../../shared/video/video.service' |
19 | import { VideoEdit } from '../../shared/video/video-edit.model' | 20 | import { VideoEdit } from '../../shared/video/video-edit.model' |
20 | 21 | ||
@@ -25,34 +26,13 @@ import { VideoEdit } from '../../shared/video/video-edit.model' | |||
25 | }) | 26 | }) |
26 | 27 | ||
27 | export class VideoUpdateComponent extends FormReactive implements OnInit { | 28 | export class VideoUpdateComponent extends FormReactive implements OnInit { |
28 | tags: string[] = [] | ||
29 | videoCategories = [] | ||
30 | videoLicences = [] | ||
31 | videoLanguages = [] | ||
32 | videoPrivacies = [] | ||
33 | video: VideoEdit | 29 | video: VideoEdit |
34 | 30 | ||
35 | tagValidators = VIDEO_TAGS.VALIDATORS | ||
36 | tagValidatorsMessages = VIDEO_TAGS.MESSAGES | ||
37 | |||
38 | error: string = null | 31 | error: string = null |
39 | form: FormGroup | 32 | form: FormGroup |
40 | formErrors = { | 33 | formErrors: { [ id: string ]: string } = {} |
41 | name: '', | 34 | validationMessages: ValidatorMessage = {} |
42 | privacy: '', | 35 | videoPrivacies = [] |
43 | category: '', | ||
44 | licence: '', | ||
45 | language: '', | ||
46 | description: '' | ||
47 | } | ||
48 | validationMessages = { | ||
49 | name: VIDEO_NAME.MESSAGES, | ||
50 | privacy: VIDEO_PRIVACY.MESSAGES, | ||
51 | category: VIDEO_CATEGORY.MESSAGES, | ||
52 | licence: VIDEO_LICENCE.MESSAGES, | ||
53 | language: VIDEO_LANGUAGE.MESSAGES, | ||
54 | description: VIDEO_DESCRIPTION.MESSAGES | ||
55 | } | ||
56 | 36 | ||
57 | fileError = '' | 37 | fileError = '' |
58 | 38 | ||
@@ -68,30 +48,16 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
68 | } | 48 | } |
69 | 49 | ||
70 | buildForm () { | 50 | buildForm () { |
71 | this.form = this.formBuilder.group({ | 51 | this.form = this.formBuilder.group({}) |
72 | name: [ '', VIDEO_NAME.VALIDATORS ], | ||
73 | privacy: [ '', VIDEO_PRIVACY.VALIDATORS ], | ||
74 | nsfw: [ false ], | ||
75 | category: [ '', VIDEO_CATEGORY.VALIDATORS ], | ||
76 | licence: [ '', VIDEO_LICENCE.VALIDATORS ], | ||
77 | language: [ '', VIDEO_LANGUAGE.VALIDATORS ], | ||
78 | description: [ '', VIDEO_DESCRIPTION.VALIDATORS ], | ||
79 | tags: [ '' ] | ||
80 | }) | ||
81 | |||
82 | this.form.valueChanges.subscribe(data => this.onValueChanged(data)) | 52 | this.form.valueChanges.subscribe(data => this.onValueChanged(data)) |
83 | } | 53 | } |
84 | 54 | ||
85 | ngOnInit () { | 55 | ngOnInit () { |
86 | this.buildForm() | 56 | this.buildForm() |
87 | 57 | ||
88 | this.videoCategories = this.serverService.getVideoCategories() | ||
89 | this.videoLicences = this.serverService.getVideoLicences() | ||
90 | this.videoLanguages = this.serverService.getVideoLanguages() | ||
91 | this.videoPrivacies = this.serverService.getVideoPrivacies() | 58 | this.videoPrivacies = this.serverService.getVideoPrivacies() |
92 | 59 | ||
93 | const uuid: string = this.route.snapshot.params['uuid'] | 60 | const uuid: string = this.route.snapshot.params['uuid'] |
94 | |||
95 | this.videoService.getVideo(uuid) | 61 | this.videoService.getVideo(uuid) |
96 | .switchMap(video => { | 62 | .switchMap(video => { |
97 | return this.videoService | 63 | return this.videoService |
@@ -103,7 +69,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
103 | video => { | 69 | video => { |
104 | this.video = new VideoEdit(video) | 70 | this.video = new VideoEdit(video) |
105 | 71 | ||
106 | // We cannot set private a video that was not private anymore | 72 | // We cannot set private a video that was not private |
107 | if (video.privacy !== VideoPrivacy.PRIVATE) { | 73 | if (video.privacy !== VideoPrivacy.PRIVATE) { |
108 | const newVideoPrivacies = [] | 74 | const newVideoPrivacies = [] |
109 | for (const p of this.videoPrivacies) { | 75 | for (const p of this.videoPrivacies) { |