From 398ede37d02250975c5dbaa535566c601419dc74 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 7 Mar 2017 13:01:24 +0100 Subject: [PATCH] Correcciones varias --- .eslintrc.yml | 3 ++- client/client/src/addresses/index.html | 2 +- client/client/src/addresses/index.js | 13 +------------ client/core/src/directives/validation.js | 10 +++------- client/core/src/lib/validator.js | 18 +++++++++++++++--- 5 files changed, 22 insertions(+), 24 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index d92eef6f2..7a6f54021 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -2,7 +2,8 @@ extends: google installedESLint: true rules: indent: [error, 4] - no-undef: 0 require-jsdoc: 0 + no-undef: 0 max-len: 0 eqeqeq: 0 + operator-linebreak: 0 diff --git a/client/client/src/addresses/index.html b/client/client/src/addresses/index.html index 58266db6f..197c7ace5 100644 --- a/client/client/src/addresses/index.html +++ b/client/client/src/addresses/index.html @@ -26,7 +26,7 @@ diff --git a/client/client/src/addresses/index.js b/client/client/src/addresses/index.js index 8afad6631..0c0dc0846 100644 --- a/client/client/src/addresses/index.js +++ b/client/client/src/addresses/index.js @@ -1,17 +1,6 @@ import {module} from '../module'; -class Controller { - constructor($state) { - this.$state = $state; - } - onNewAddressClick() { - this.$state.go('clientCard.addressCreate', {id: this.$state.params.id}); - } -} -Controller.$inject = ['$state']; - export const component = { - template: require('./index.html'), - controller: Controller + template: require('./index.html') }; module.component('vnClientAddresses', component); diff --git a/client/core/src/directives/validation.js b/client/core/src/directives/validation.js index 24fe52efb..943f11797 100644 --- a/client/core/src/directives/validation.js +++ b/client/core/src/directives/validation.js @@ -2,7 +2,7 @@ import {module} from '../module'; import {validateAll} from '../lib/validator'; import {firstUpper} from '../lib/string'; -directive.$inject = ['$interpolate', '$compile', '$window'] +directive.$inject = ['$interpolate', '$compile', '$window']; export function directive(interpolate, compile, $window) { return { restrict: 'A', @@ -38,26 +38,22 @@ export function directive(interpolate, compile, $window) { let input = ctrl[0]; let form = ctrl[1]; + let parent = element.parent(); input.$validators.entity = function(value) { - let parent = element.parent(); - try { validateAll(value, validations); + return true; } catch (e) { errorMsg.text(e.message); parent.attr('title', e.message); return false; } - - return true; }; scope.$watch(function() { return (form.$submitted || input.$dirty) && input.$invalid; }, function(value) { - let parent = element.parent(); - if (value) { parent.addClass('invalid'); errorMsg[0].style.display = 'block'; diff --git a/client/core/src/lib/validator.js b/client/core/src/lib/validator.js index fa32bf38a..b27fdf8d8 100644 --- a/client/core/src/lib/validator.js +++ b/client/core/src/lib/validator.js @@ -58,11 +58,23 @@ export const validators = { } }; +/** + * Checks if value satisfies a set of validations. + * + * @param {*} value The value + * @param {Array} validations Array with validations + */ export function validateAll(value, validations) { for (let conf of validations) validate(value, conf); } +/** + * Checks if value satisfies a validation. + * + * @param {*} value The value + * @param {Object} conf The validation configuration + */ export function validate(value, conf) { let validator = validators[conf.validation]; try { @@ -75,10 +87,10 @@ export function validate(value, conf) { } /** - * Checks if value is null. + * Checks if value satisfies a not null validation. * - * @param {value} value The value - * @param {Object} conf The configuration for the field + * @param {*} value The value + * @param {Object} conf The validation configuration */ export function checkNull(value, conf) { if (typeof value === 'undefined') {