Correcciones varias
This commit is contained in:
parent
3a16f09494
commit
398ede37d0
|
@ -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
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
<vn-paging index="index"></vn-paging>
|
||||
<vn-float-button
|
||||
fixed-bottom-right
|
||||
ng-click="$ctrl.onNewAddressClick()"
|
||||
ui-sref="clientCard.addressCreate"
|
||||
icon="add">
|
||||
</vn-float-button>
|
||||
</vn-vertical>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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') {
|
||||
|
|
Loading…
Reference in New Issue