diff --git a/front/core/components/index.js b/front/core/components/index.js index 86ab89212..b42ebb6ae 100644 --- a/front/core/components/index.js +++ b/front/core/components/index.js @@ -53,3 +53,4 @@ import './datalist'; import './contextmenu'; import './rating'; import './smart-table'; +import './input-account'; diff --git a/front/core/components/input-account/index.js b/front/core/components/input-account/index.js new file mode 100644 index 000000000..f0e0326db --- /dev/null +++ b/front/core/components/input-account/index.js @@ -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 +}); diff --git a/modules/supplier/front/fiscal-data/index.html b/modules/supplier/front/fiscal-data/index.html index 77a5cce4e..85c62f41d 100644 --- a/modules/supplier/front/fiscal-data/index.html +++ b/modules/supplier/front/fiscal-data/index.html @@ -56,12 +56,12 @@ - - +