aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/video-add/video-add.component.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-03-22 21:47:05 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-03-22 21:56:02 +0100
commite54163c2d5cc925eb56ead831f2fecd000222a98 (patch)
tree142d0592d66d90b489f592a867770235315bee0c /client/src/app/videos/video-add/video-add.component.ts
parent6e07c3de88791a0b342e0cc319590048117f9c2d (diff)
downloadPeerTube-e54163c2d5cc925eb56ead831f2fecd000222a98.tar.gz
PeerTube-e54163c2d5cc925eb56ead831f2fecd000222a98.tar.zst
PeerTube-e54163c2d5cc925eb56ead831f2fecd000222a98.zip
Relax on tags (accept any characters and not required anymore)
Diffstat (limited to 'client/src/app/videos/video-add/video-add.component.ts')
-rw-r--r--client/src/app/videos/video-add/video-add.component.ts46
1 files changed, 25 insertions, 21 deletions
diff --git a/client/src/app/videos/video-add/video-add.component.ts b/client/src/app/videos/video-add/video-add.component.ts
index 2ef666e17..5ed1d8841 100644
--- a/client/src/app/videos/video-add/video-add.component.ts
+++ b/client/src/app/videos/video-add/video-add.component.ts
@@ -105,10 +105,6 @@ export class VideoAddComponent extends FormReactive implements OnInit {
105 checkForm() { 105 checkForm() {
106 this.forceCheck(); 106 this.forceCheck();
107 107
108 if (this.tags.length === 0) {
109 this.tagsError = 'You have 0 tags';
110 }
111
112 if (this.filename === null) { 108 if (this.filename === null) {
113 this.fileError = 'You did not add a file.'; 109 this.fileError = 'You did not add a file.';
114 } 110 }
@@ -121,25 +117,9 @@ export class VideoAddComponent extends FormReactive implements OnInit {
121 } 117 }
122 118
123 onTagKeyPress(event: KeyboardEvent) { 119 onTagKeyPress(event: KeyboardEvent) {
124 const currentTag = this.form.value['currentTag'];
125
126 // Enter press 120 // Enter press
127 if (event.keyCode === 13) { 121 if (event.keyCode === 13) {
128 // Check if the tag is valid and does not already exist 122 this.addTagIfPossible();
129 if (
130 currentTag.length >= 2 &&
131 this.form.controls['currentTag'].valid &&
132 this.tags.indexOf(currentTag) === -1
133 ) {
134 this.tags.push(currentTag);
135 this.form.patchValue({ currentTag: '' });
136
137 if (this.tags.length >= 3) {
138 this.form.get('currentTag').disable();
139 }
140
141 this.tagsError = '';
142 }
143 } 123 }
144 } 124 }
145 125
@@ -153,6 +133,9 @@ export class VideoAddComponent extends FormReactive implements OnInit {
153 } 133 }
154 134
155 upload() { 135 upload() {
136 // Maybe the user forgot to press "enter" when he filled the field
137 this.addTagIfPossible();
138
156 if (this.checkForm() === false) { 139 if (this.checkForm() === false) {
157 return; 140 return;
158 } 141 }
@@ -199,4 +182,25 @@ export class VideoAddComponent extends FormReactive implements OnInit {
199 182
200 this.uploader.uploadAll(); 183 this.uploader.uploadAll();
201 } 184 }
185
186 private addTagIfPossible() {
187 const currentTag = this.form.value['currentTag'];
188 if (currentTag === undefined) return;
189
190 // Check if the tag is valid and does not already exist
191 if (
192 currentTag.length >= 2 &&
193 this.form.controls['currentTag'].valid &&
194 this.tags.indexOf(currentTag) === -1
195 ) {
196 this.tags.push(currentTag);
197 this.form.patchValue({ currentTag: '' });
198
199 if (this.tags.length >= 3) {
200 this.form.get('currentTag').disable();
201 }
202
203 this.tagsError = '';
204 }
205 }
202} 206}