diff --git a/client/client/src/billing-data/index.html b/client/client/src/billing-data/index.html index ef4d9fc476..a001ba49e0 100644 --- a/client/client/src/billing-data/index.html +++ b/client/client/src/billing-data/index.html @@ -1,21 +1,24 @@ + vn-id="watcher" + data="bill.client" + form="form" + save="put">
Información de facturación - - - - + + + + @@ -34,7 +37,6 @@ - diff --git a/client/core/src/autocomplete/index.js b/client/core/src/autocomplete/index.js index 4acf3c7904..9a99ef2a4b 100644 --- a/client/core/src/autocomplete/index.js +++ b/client/core/src/autocomplete/index.js @@ -12,20 +12,25 @@ export default class Autocomplete extends Component { this.item = null; this.data = null; this.popover = null; - this.popoverData = null; + this.displayData = null; this.timeoutId = null; this.lastSearch = null; this.lastRequest = null; this.currentRequest = null; this.moreData = false; this.activeOption = -1; - this.maxRows = 10; - this.requestDelay = 350; this.locked = false; this.$http = $http; this.$scope = $scope; this.vnPopover = vnPopover; + Object.assign(this, { + maxRows: 10, + requestDelay: 350, + showField: 'name', + valueField: 'id' + }); + componentHandler.upgradeElement($element[0].firstChild); } set field(value) { @@ -36,13 +41,23 @@ export default class Autocomplete extends Component { get field() { return this.value; } - set initialValue(value) { + set initialData(value) { if (value) { if (!this.data) this.data = []; this.data.push(value); } } + set selectFields(value) { + this._selectFields = []; + + if (!value) + return; + + let res = value.split(','); + for (let i of res) + this._selectFields.push(i.trim()); + } mdlUpdate() { let mdlField = this.element.firstChild.MaterialTextfield; if (mdlField) @@ -52,7 +67,7 @@ export default class Autocomplete extends Component { textFilter = textFilter ? textFilter : ''; if (this.lastSearch === textFilter) { - this.popoverDataReady(); + this.showPopoverIfFocus(); return; } @@ -72,6 +87,11 @@ export default class Autocomplete extends Component { let fields = {}; fields[this.valueField] = true; fields[this.showField] = true; + + if (this._selectFields) + for (let field of this._selectFields) + fields[field] = true; + return fields; } requestData(textFilter, append) { @@ -112,28 +132,30 @@ export default class Autocomplete extends Component { else this.data = this.data.concat(data); - this.setPopoverData(this.data); + this.setDisplayData(this.data); } localFilter(textFilter) { let regex = new RegExp(textFilter, 'i'); let data = this.data.filter(item => { return regex.test(item[this.showField]); }); - this.setPopoverData(data); + this.setDisplayData(data); } - setPopoverData(data) { - this.popoverData = data; - this.popoverDataReady(); + setDisplayData(data) { + this.displayData = data; + this.showPopoverIfFocus(); } - popoverDataReady() { + showPopoverIfFocus() { if (this.hasFocus) this.showPopover(); } showPopover() { - if (!this.data) return; + let data = this.displayData; + + if (!data) + return; let fragment = this.document.createDocumentFragment(); - let data = this.popoverData; for (let i = 0; i < data.length; i++) { let li = this.document.createElement('li'); @@ -171,8 +193,8 @@ export default class Autocomplete extends Component { } selectPopoverOption(index) { if (!this.popover || index === -1) return; - if (index < this.popoverData.length) { - this.selectOptionByDataIndex(this.popoverData, index); + if (index < this.displayData.length) { + this.selectOptionByDataIndex(this.displayData, index); this.hidePopover(); } else this.requestData(this.lastRequest, true); @@ -276,7 +298,7 @@ export default class Autocomplete extends Component { let popover = this.popover; let childs = popover.childNodes; - let len = this.popoverData.length; + let len = this.displayData.length; if (this.activeOption >= 0) childs[this.activeOption].className = ''; @@ -332,11 +354,8 @@ export default class Autocomplete extends Component { this.showItem(item); let value = item ? item[this.valueField] : undefined; - if (!this.locked) { + if (!this.locked) this.value = value; - setTimeout( - () => this.$scope.$apply()); - } } showItem(item) { this.input.value = item ? item[this.showField] : ''; @@ -350,9 +369,10 @@ module.component('vnAutocomplete', { template: require('./index.html'), bindings: { url: '@', - showField: '@', - valueField: '@', - initialValue: '<', + showField: '@?', + valueField: '@?', + selectFields: '@?', + initialData: '