From bf57d5eebf8b0fa2361b7973ce9772abd1bb4828 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sun, 27 Nov 2016 18:10:26 +0100 Subject: [PATCH 1/1] Client: try to improve ux for the upload form --- client/src/app/shared/forms/form-reactive.ts | 16 ++++++ .../videos/video-add/video-add.component.html | 12 ++++- .../videos/video-add/video-add.component.scss | 5 +- .../videos/video-add/video-add.component.ts | 52 ++++++++++--------- 4 files changed, 57 insertions(+), 28 deletions(-) diff --git a/client/src/app/shared/forms/form-reactive.ts b/client/src/app/shared/forms/form-reactive.ts index 1e8a69771..a5732e083 100644 --- a/client/src/app/shared/forms/form-reactive.ts +++ b/client/src/app/shared/forms/form-reactive.ts @@ -21,4 +21,20 @@ export abstract class FormReactive { } } } + + // Same as onValueChanged but force checking even if the field is not dirty + protected forceCheck() { + for (const field in this.formErrors) { + // clear previous error message (if any) + this.formErrors[field] = ''; + const control = this.form.get(field); + + if (control && !control.valid) { + const messages = this.validationMessages[field]; + for (const key in control.errors) { + this.formErrors[field] += messages[key] + ' '; + } + } + } + } } diff --git a/client/src/app/videos/video-add/video-add.component.html b/client/src/app/videos/video-add/video-add.component.html index 14c7a0136..b6be0d782 100644 --- a/client/src/app/videos/video-add/video-add.component.html +++ b/client/src/app/videos/video-add/video-add.component.html @@ -15,7 +15,7 @@
- + (press enter to add the tag)
+
+ {{ tagsError }} +
+
@@ -39,6 +43,7 @@
@@ -50,6 +55,10 @@ +
+ {{ fileError }} +
+