aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/+video-edit/shared
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-12-07 11:15:19 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-12-07 11:15:19 +0100
commitff249f499ccca2e37757f338384e7ba44c906a69 (patch)
treecb8f88c105536e5edf4bf02030edecfe6b6c0d17 /client/src/app/videos/+video-edit/shared
parent59aa1e5e7541f604363d2a1ebfd670a5d1db245f (diff)
downloadPeerTube-ff249f499ccca2e37757f338384e7ba44c906a69.tar.gz
PeerTube-ff249f499ccca2e37757f338384e7ba44c906a69.tar.zst
PeerTube-ff249f499ccca2e37757f338384e7ba44c906a69.zip
Move video form inside a component
Diffstat (limited to 'client/src/app/videos/+video-edit/shared')
-rw-r--r--client/src/app/videos/+video-edit/shared/video-edit.component.html85
-rw-r--r--client/src/app/videos/+video-edit/shared/video-edit.component.ts83
-rw-r--r--client/src/app/videos/+video-edit/shared/video-edit.module.ts7
3 files changed, 173 insertions, 2 deletions
diff --git a/client/src/app/videos/+video-edit/shared/video-edit.component.html b/client/src/app/videos/+video-edit/shared/video-edit.component.html
new file mode 100644
index 000000000..e087b71a4
--- /dev/null
+++ b/client/src/app/videos/+video-edit/shared/video-edit.component.html
@@ -0,0 +1,85 @@
1<div [formGroup]="form">
2 <div class="form-group">
3 <label for="name">Name</label>
4 <input
5 type="text" class="form-control" id="name"
6 formControlName="name"
7 >
8 <div *ngIf="formErrors.name" class="alert alert-danger">
9 {{ formErrors.name }}
10 </div>
11 </div>
12
13 <div class="form-group">
14 <label for="privacy">Privacy</label>
15 <select class="form-control" id="privacy" formControlName="privacy">
16 <option></option>
17 <option *ngFor="let privacy of videoPrivacies" [value]="privacy.id">{{ privacy.label }}</option>
18 </select>
19
20 <div *ngIf="formErrors.privacy" class="alert alert-danger">
21 {{ formErrors.privacy }}
22 </div>
23 </div>
24
25 <div class="form-group">
26 <input
27 type="checkbox" id="nsfw"
28 formControlName="nsfw"
29 >
30 <label for="nsfw">This video contains mature or explicit content</label>
31 </div>
32
33 <div class="form-group">
34 <label for="category">Category</label>
35 <select class="form-control" id="category" formControlName="category">
36 <option></option>
37 <option *ngFor="let category of videoCategories" [value]="category.id">{{ category.label }}</option>
38 </select>
39
40 <div *ngIf="formErrors.category" class="alert alert-danger">
41 {{ formErrors.category }}
42 </div>
43 </div>
44
45 <div class="form-group">
46 <label for="licence">Licence</label>
47 <select class="form-control" id="licence" formControlName="licence">
48 <option></option>
49 <option *ngFor="let licence of videoLicences" [value]="licence.id">{{ licence.label }}</option>
50 </select>
51
52 <div *ngIf="formErrors.licence" class="alert alert-danger">
53 {{ formErrors.licence }}
54 </div>
55 </div>
56
57 <div class="form-group">
58 <label for="language">Language</label>
59 <select class="form-control" id="language" formControlName="language">
60 <option></option>
61 <option *ngFor="let language of videoLanguages" [value]="language.id">{{ language.label }}</option>
62 </select>
63
64 <div *ngIf="formErrors.language" class="alert alert-danger">
65 {{ formErrors.language }}
66 </div>
67 </div>
68
69 <div class="form-group">
70 <label class="label-tags">Tags</label> <span class="little-information">(press enter to add the tag)</span>
71 <tag-input
72 [ngModel]="tags" [validators]="tagValidators" [errorMessages]="tagValidatorsMessages"
73 formControlName="tags" maxItems="5" modelAsStrings="true"
74 ></tag-input>
75 </div>
76
77 <div class="form-group">
78 <label for="description">Description</label>
79 <my-video-description formControlName="description"></my-video-description>
80
81 <div *ngIf="formErrors.description" class="alert alert-danger">
82 {{ formErrors.description }}
83 </div>
84 </div>
85</div>
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
new file mode 100644
index 000000000..5b1cc3f9c
--- /dev/null
+++ b/client/src/app/videos/+video-edit/shared/video-edit.component.ts
@@ -0,0 +1,83 @@
1import { Component, Input, OnInit } from '@angular/core'
2import { FormBuilder, FormControl, FormGroup } from '@angular/forms'
3import { ActivatedRoute, Router } from '@angular/router'
4import { NotificationsService } from 'angular2-notifications'
5import { ServerService } from 'app/core'
6import { VideoEdit } from 'app/shared/video/video-edit.model'
7import 'rxjs/add/observable/forkJoin'
8import { VideoPrivacy } from '../../../../../shared/models/videos/video-privacy.enum'
9import {
10 ValidatorMessage,
11 VIDEO_CATEGORY,
12 VIDEO_DESCRIPTION,
13 VIDEO_LANGUAGE,
14 VIDEO_LICENCE,
15 VIDEO_NAME,
16 VIDEO_PRIVACY,
17 VIDEO_TAGS
18} from '../../../shared/forms/form-validators'
19
20@Component({
21 selector: 'my-video-edit',
22 styleUrls: [ './video-edit.component.scss' ],
23 templateUrl: './video-edit.component.html'
24})
25
26export class VideoEditComponent implements OnInit {
27 @Input() form: FormGroup
28 @Input() formErrors: { [ id: string ]: string } = {}
29 @Input() validationMessages: ValidatorMessage = {}
30 @Input() videoPrivacies = []
31
32 tags: string[] = []
33 videoCategories = []
34 videoLicences = []
35 videoLanguages = []
36 video: VideoEdit
37
38 tagValidators = VIDEO_TAGS.VALIDATORS
39 tagValidatorsMessages = VIDEO_TAGS.MESSAGES
40
41 error: string = null
42
43 constructor (
44 private formBuilder: FormBuilder,
45 private route: ActivatedRoute,
46 private router: Router,
47 private notificationsService: NotificationsService,
48 private serverService: ServerService
49 ) { }
50
51 updateForm () {
52 this.formErrors['name'] = ''
53 this.formErrors['privacy'] = ''
54 this.formErrors['category'] = ''
55 this.formErrors['licence'] = ''
56 this.formErrors['language'] = ''
57 this.formErrors['description'] = ''
58
59 this.validationMessages['name'] = VIDEO_NAME.MESSAGES
60 this.validationMessages['privacy'] = VIDEO_PRIVACY.MESSAGES
61 this.validationMessages['category'] = VIDEO_CATEGORY.MESSAGES
62 this.validationMessages['licence'] = VIDEO_LICENCE.MESSAGES
63 this.validationMessages['language'] = VIDEO_LANGUAGE.MESSAGES
64 this.validationMessages['description'] = VIDEO_DESCRIPTION.MESSAGES
65
66 this.form.addControl('name', new FormControl('', VIDEO_NAME.VALIDATORS))
67 this.form.addControl('privacy', new FormControl('', VIDEO_PRIVACY.VALIDATORS))
68 this.form.addControl('nsfw', new FormControl(false))
69 this.form.addControl('category', new FormControl('', VIDEO_CATEGORY.VALIDATORS))
70 this.form.addControl('licence', new FormControl('', VIDEO_LICENCE.VALIDATORS))
71 this.form.addControl('language', new FormControl('', VIDEO_LANGUAGE.VALIDATORS))
72 this.form.addControl('description', new FormControl('', VIDEO_DESCRIPTION.VALIDATORS))
73 this.form.addControl('tags', new FormControl(''))
74 }
75
76 ngOnInit () {
77 this.updateForm()
78
79 this.videoCategories = this.serverService.getVideoCategories()
80 this.videoLicences = this.serverService.getVideoLicences()
81 this.videoLanguages = this.serverService.getVideoLanguages()
82 }
83}
diff --git a/client/src/app/videos/+video-edit/shared/video-edit.module.ts b/client/src/app/videos/+video-edit/shared/video-edit.module.ts
index cdab694f9..c7ed8c351 100644
--- a/client/src/app/videos/+video-edit/shared/video-edit.module.ts
+++ b/client/src/app/videos/+video-edit/shared/video-edit.module.ts
@@ -5,6 +5,7 @@ import { TabsModule } from 'ngx-bootstrap/tabs'
5 5
6import { MarkdownService, VideoDescriptionComponent } from '../../shared' 6import { MarkdownService, VideoDescriptionComponent } from '../../shared'
7import { SharedModule } from '../../../shared' 7import { SharedModule } from '../../../shared'
8import { VideoEditComponent } from './video-edit.component'
8 9
9@NgModule({ 10@NgModule({
10 imports: [ 11 imports: [
@@ -15,14 +16,16 @@ import { SharedModule } from '../../../shared'
15 ], 16 ],
16 17
17 declarations: [ 18 declarations: [
18 VideoDescriptionComponent 19 VideoDescriptionComponent,
20 VideoEditComponent
19 ], 21 ],
20 22
21 exports: [ 23 exports: [
22 TagInputModule, 24 TagInputModule,
23 TabsModule, 25 TabsModule,
24 26
25 VideoDescriptionComponent 27 VideoDescriptionComponent,
28 VideoEditComponent
26 ], 29 ],
27 30
28 providers: [ 31 providers: [