Add vn-input-account tag and logic
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
9d7e12d861
commit
d30065f90a
|
@ -53,3 +53,4 @@ import './datalist';
|
|||
import './contextmenu';
|
||||
import './rating';
|
||||
import './smart-table';
|
||||
import './input-account';
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
import ngModule from '../../module';
|
||||
import Field from '../field';
|
||||
|
||||
export default class inputAccount extends Field {
|
||||
constructor($element, $scope, $compile) {
|
||||
super($element, $scope, $compile);
|
||||
this.buildInput('text');
|
||||
|
||||
this.element.addEventListener('click', e => {
|
||||
console.log(this.element);
|
||||
|
||||
console.log(e);
|
||||
let targetElement = e.target;
|
||||
console.log(targetElement);
|
||||
|
||||
let currentValue = targetElement.value;
|
||||
|
||||
let arrayValue = currentValue.split('');
|
||||
|
||||
console.log(arrayValue);
|
||||
|
||||
let pointer = 0;
|
||||
|
||||
targetElement.addEventListener('keyup', e => {
|
||||
this.$.$applyAsync(async() =>
|
||||
pointer = await insertFunction(e, targetElement, currentValue, arrayValue, pointer));
|
||||
$scope.digest();
|
||||
});
|
||||
});
|
||||
|
||||
async function insertFunction(e, targetElement, currentValue, arrayValue, pointer) {
|
||||
if (e.key == 'Backspace' || e.key == 'ArrowLeft') {
|
||||
pointer != 0 ? pointer-- : pointer;
|
||||
return pointer;
|
||||
} else if (e.key == 'ArrowRight') {
|
||||
pointer != 10 ? pointer++ : pointer = 0;
|
||||
return pointer;
|
||||
}
|
||||
|
||||
console.log(e);
|
||||
currentValue = targetElement.value;
|
||||
arrayValue = currentValue.split('');
|
||||
|
||||
console.log(arrayValue);
|
||||
|
||||
let keyToInsert = e.key;
|
||||
|
||||
console.log(`Pointer => ${pointer}`);
|
||||
console.log(`InputKey => ${keyToInsert}`);
|
||||
|
||||
arrayValue[pointer] = keyToInsert;
|
||||
|
||||
targetElement.value = arrayValue.join('');
|
||||
|
||||
if (pointer < 10) pointer++;
|
||||
|
||||
if (arrayValue.length > 10) {
|
||||
console.log(`Demasiado largo --> ${arrayValue.length}`);
|
||||
arrayValue = arrayValue.slice(0, 10);
|
||||
console.log(`Se ha eliminado el ultimo elemento añadido --> ${arrayValue}`);
|
||||
targetElement.value = arrayValue.join('');
|
||||
}
|
||||
console.log(targetElement.value);
|
||||
return pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
ngModule.vnComponent('vnInputAccount', {
|
||||
controller: inputAccount
|
||||
});
|
|
@ -56,12 +56,12 @@
|
|||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
<vn-input-account
|
||||
vn-one
|
||||
label="Account"
|
||||
ng-model="$ctrl.supplier.account"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
</vn-input-account>
|
||||
<vn-autocomplete vn-one
|
||||
ng-model="$ctrl.supplier.sageTaxTypeFk"
|
||||
data="sageTaxTypes"
|
||||
|
|
Loading…
Reference in New Issue