solved merge comflics with item tags

This commit is contained in:
Carlos Jimenez 2018-02-27 13:40:33 +01:00
commit cdfc2a6779
7 changed files with 112 additions and 97 deletions

View File

@ -5,16 +5,18 @@
<div pad-medium class="data">
<h6>{{$ctrl.client.name}}</h6>
<div>
<span translate>Id</span> {{$ctrl.client.id}}
<span class="label" translate>Id</span> {{$ctrl.client.id}}
</div>
<div>
<span translate>Phone</span> {{$ctrl.client.phone | phone}}
<span class="label" translate>Phone</span> {{$ctrl.client.phone | phone}}
</div>
<div>
<span translate>Credit</span> {{$ctrl.client.credit | number:2}}€
<span class="label" translate>Credit</span> {{$ctrl.client.credit | currency:'€':2}}
</div>
<div>
<span translate>Secured credit</span> {{$ctrl.client.creditInsurance || 0 | number:2}}€
<span class="label" translate>Secured credit</span>
<span ng-if="$ctrl.client.creditInsurance">{{$ctrl.client.creditInsurance | currency:'€':2}}</span>
<span ng-if="!$ctrl.client.creditInsurance">-</span>
</div>
</div>
</vn-card>

View File

@ -1,5 +1,5 @@
vn-client-descriptor {
.data span {
.data .label {
font-size: .9em;
color: #666;
}

View File

@ -210,7 +210,8 @@ export default class Watcher extends Component {
onConfirmResponse(response) {
if (response === 'ACCEPT') {
Object.assign(this.data, this.orgData);
if (this.data)
Object.assign(this.data, this.orgData);
this.$state.go(this.state);
} else {
this.state = null;

View File

@ -23,4 +23,5 @@ Preview: Vista previa
Clone: Clonar
Do you want to clone this item?: ¿Desea clonar este artículo?
Yes, clone: Si, clonar
Value: Valor
Value: Valor
Priority: Prioridad

View File

@ -5,6 +5,7 @@
<form name="form" ng-submit="$ctrl.submit()">
<vn-card>
<vn-vertical pad-large>
<<<<<<< HEAD
<vn-one margin-medium-top>
<vn-title>Item tags</vn-title>
<mg-ajax path="/item/api/Tags" options="mgIndex as tags"></mg-ajax>
@ -45,6 +46,38 @@
</vn-icon>
</vn-one>
</vn-horizontal>
=======
<vn-title>Item tags</vn-title>
<mg-ajax path="/item/api/Tags" options="mgIndex as tags"></mg-ajax>
<vn-horizontal ng-repeat="itemTag in $ctrl.itemTags track by $index">
<vn-autocomplete
vn-one
initial-data = "itemTag.tag"
field = "itemTag.tagFk"
data = "tags.model"
show-field = "name"
label = "Tag">
</vn-autocomplete>
<vn-textfield vn-three label="Value" model="itemTag.value"></vn-textfield>
<vn-textfield vn-one type="number" label="Priority" model="itemTag.priority"></vn-textfield>
<vn-one pad-medium-top>
<vn-icon
pointer
medium-grey
icon="remove_circle_outline"
ng-click="$ctrl.removeItemTag($index)">
</vn-icon>
<vn-icon
pointer
margin-medium-left
orange
icon="add_circle"
ng-if = "itemTag.showAddIcon && tags.model.length > $ctrl.itemTags.length"
ng-click="$ctrl.addItemTag()">
</vn-icon>
</vn-one>
</vn-horizontal>
>>>>>>> 688881fac41a4018ebf187fc3b71e2030220853d
</vn-vertical>
</vn-card>
<vn-button-bar>

View File

@ -58,7 +58,7 @@ describe('Client Create', () => {
name: 'Wade',
userName: 'Deadpool',
email: 'Deadpool@marvel.com',
fi: 'DP',
fi: '16195279J',
socialName: 'Deadpool Marvel',
salesPersonFk: 1
};

View File

@ -1,97 +1,75 @@
module.exports = fi => {
if (fi === undefined || fi === null) {
module.exports = fiWithCountry => {
if (fiWithCountry == null)
return true;
}
let dni = fi;
let getLetterDni = dni => {
const regExpDni = 'TRWAGMYFPDXBNJZSQVHLCKE';
const letterDni = dni.toUpperCase().substring(0, 1);
let positionLetter = parseInt(dni) % 23;
let getLetter = regExpDni.substring(positionLetter + 1, positionLetter);
switch (letterDni) {
case 'X': case 'Y': case 'Z':
positionLetter = parseInt(dni.replace(letterDni, letterDni.charCodeAt(0) - 88)) % 23;
getLetter = regExpDni.substring(positionLetter + 1, positionLetter);
fiWithCountry = fiWithCountry.toUpperCase();
if (!/^[A-Z]{2}/.test(fiWithCountry))
fiWithCountry = `ES${fiWithCountry}`;
let country = fiWithCountry.substring(0, 2).toLowerCase();
let fi = fiWithCountry.substring(2);
let len = fi.length;
let validators = {
es: {
regExp: /^[A-Z0-9]\d{7}[A-Z0-9]$/,
validate: () => {
let isCif = /[A-W]/.test(fi.charAt(0));
let lastDigit = fi.charAt(len - 1);
let computedDigit;
if (isCif) {
let numbers = fi.substring(1, 8)
.split('')
.map(x => parseInt(x));
let pairSum = numbers
.filter((_, i) => i % 2 != 0)
.reduce((a, x) => a + x);
let oddSum = numbers
.filter((_, i) => i % 2 == 0)
.map(x => x * 2)
.join('')
.split('')
.map(x => parseInt(x))
.reduce((a, x) => a + x);
let sum = (pairSum + oddSum).toString();
let units = parseInt(sum.charAt(sum.length - 1));
let control = units != 0 ? 10 - units : 0;
let index = 'JABCDEFGHI'.indexOf(lastDigit);
computedDigit = index == -1 ? control.toString() : index;
} else {
// Foreign NIF
let index = 'XYZ'.indexOf(fi.charAt(0));
let nif = index == -1 ? fi : index.toString() + fi.substring(1);
let number = parseInt(nif.substring(0, 8));
let rest = number % 23;
computedDigit = 'TRWAGMYFPDXBNJZSQVHLCKE'.charAt(rest);
}
return computedDigit == lastDigit;
}
},
pt: {
regExp: /^\d{9}$/
},
fr: {
regExp: /^[A-Z0-9]{2}\d{9}$/
},
it: {
regExp: /^\d{11}$/
}
return getLetter;
};
let getDniSpain = (dniNumeric, dniLetter) => {
let returnValue = false;
switch (dni.length) {
case 9:
if (dniLetter === getLetterDni(dni))
returnValue = true;
}
return returnValue;
};
let validator = validators[country];
let getDniForeign = (dniNumeric, dniLetter) => {
let returnValue = false;
switch (dni.length) {
case 9:
if (dniLetter === getLetterDni(dni))
returnValue = true;
}
return returnValue;
};
let getDniBusiness = () => {
if (dni.length == 9)
return true;
if (!validator)
return false;
};
let getDniFrance = dniLetterCountry => {
let returnValue = false;
switch (dni.length) {
case 13:
if (dniLetter === 'R')
returnValue = true;
}
return returnValue;
};
let getDniItaly = dniLetterCountry => {
let returnValue = false;
switch (dni.length) {
case 13:
if (dniLetter === 'T')
returnValue = true;
}
return returnValue;
};
let getDni = () => {
const dniNumeric = dni.substring(0, 8);
const dniLetter = dni.substring(8, 9);
const dniLetterCountry = dni.substring(0, 1);
const dniLetterAscii = parseInt(dniLetterCountry.charCodeAt(0));
let dniValue = false;
switch (true) {
case (dni.length === 9 && !isNaN(dni)): // dni Portugal (9 digitos)
dniValue = true;
break;
case (dniLetterAscii >= 88 && dniLetterAscii <= 90): // X-Z
dniValue = getDniForeign(dniNumeric, dniLetter);
break;
case (dniLetterAscii === 66): // B
dniValue = getDniBusiness();
break;
case (dniLetterAscii === 70): // F
dniValue = getDniFrance(dniLetterCountry);
break;
case (dniLetterAscii === 73): // I
dniValue = getDniItaly(dniLetterCountry);
break;
case (dni.length === 9 && dniLetterAscii >= 48 && dniLetterAscii <= 57): // 0- 9
dniValue = getDniSpain(dniNumeric, dniLetter);
break;
default:
dniValue = true;
}
return dniValue;
};
return getDni();
return validator.regExp.test(fi)
&& (!validator.validate || validator.validate());
};