diff options
Diffstat (limited to 'old/moon_gui/static/app/services/gui/form.service.js')
-rwxr-xr-x | old/moon_gui/static/app/services/gui/form.service.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/old/moon_gui/static/app/services/gui/form.service.js b/old/moon_gui/static/app/services/gui/form.service.js new file mode 100755 index 00000000..e436593c --- /dev/null +++ b/old/moon_gui/static/app/services/gui/form.service.js @@ -0,0 +1,47 @@ +/** + * @author arnaud marhin<arnaud.marhin@orange.com> + */ + +(function() { + + 'use strict'; + + angular + .module('moon') + .factory('formService', formService); + + function formService() { + + var service = {}; + + service.isInvalid = isInvalid; + service.checkFieldsValidity = checkFieldsValidity; + + return service; + + function isInvalid(form) { + return form.$invalid; + } + + function checkFieldsValidity(form) { + + var validationErrorKeys = _.keys(form.$error); + + _(validationErrorKeys).each(function(anErrorKey) { + + var formFields = _.values(form.$error[anErrorKey]); + + _(formFields).each(function(aFormField) { + + aFormField.$dirty = true; + aFormField.$setValidity(anErrorKey, false); + + }); + + }); + + } + + } + +})(); |