diff options
| author | beccabroek <beccabroek@gmail.com> | 2019-01-23 14:26:55 -0600 |
|---|---|---|
| committer | Ed Tanous <ed.tanous@intel.com> | 2019-02-02 01:09:14 +0000 |
| commit | a09cc2da1b3a9bad0eaf34fbfdec8a3ee32d47f8 (patch) | |
| tree | 596738144339961f447244c709d904dc7725f362 /app/common/directives | |
| parent | 97280b3efde6a19a517096940fd8e68c3c192331 (diff) | |
| download | phosphor-webui-a09cc2da1b3a9bad0eaf34fbfdec8a3ee32d47f8.tar.gz phosphor-webui-a09cc2da1b3a9bad0eaf34fbfdec8a3ee32d47f8.zip | |
Form validation on login page
Using ngMessages, adds form validation to login page. Also creates a
directive, hasError, to be used to validate form field by passing
in a boolean. This is a proposed pattern to be used moving forward,
as form validation is added to additional pages.
Validation error messages are shown on $touched and on submit.
Unreachable Server and Invalid username and password error messages
remain until input is no longer $pristine after form submission.
In addition, this removes unneeded and unused css styling
Resolves openbmc/phosphor-webui#47
Change-Id: I7a067af67ac74d4cf2977d10f66445720ecae9eb
Signed-off-by: beccabroek <beccabroek@gmail.com>
Diffstat (limited to 'app/common/directives')
| -rw-r--r-- | app/common/directives/form-input-error.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/common/directives/form-input-error.js b/app/common/directives/form-input-error.js new file mode 100644 index 0000000..69b0487 --- /dev/null +++ b/app/common/directives/form-input-error.js @@ -0,0 +1,11 @@ +angular.module('app.common.directives').directive('hasError', function() { + return { + scope: {hasError: '='}, + require: 'ngModel', + link: function(scope, elm, attrs, ngModel) { + scope.$watch('hasError', function(value) { + ngModel.$setValidity('hasError', value ? false : true); + }); + } + }; +}); |

