diff --git a/front/core/components/autocomplete/autocomplete.js b/front/core/components/autocomplete/autocomplete.js index 45e28350b..91a88704a 100755 --- a/front/core/components/autocomplete/autocomplete.js +++ b/front/core/components/autocomplete/autocomplete.js @@ -1,6 +1,7 @@ import ngModule from '../../module'; import Input from '../../lib/input'; import assignProps from '../../lib/assign-props'; +import {mergeWhere} from 'vn-loopback/util/filter'; import './style.scss'; /** @@ -163,6 +164,8 @@ export default class Autocomplete extends Input { else where[this.valueField] = this._field; + where = mergeWhere(where, this.fetchFunction); + let filter = { fields: this.$.dropDown.getFields(), where: where @@ -292,6 +295,17 @@ export default class Autocomplete extends Input { this.assignDropdownProps(); this.$.dropDown.show(this.input, search); } + + get fetchFunction() { + return this._fetchFunction; + } + + set fetchFunction(value) { + this._fetchFunction = value; + + if (value) + this.refreshSelection(); + } } Autocomplete.$inject = ['$element', '$scope', '$http', '$transclude', '$translate', '$interpolate']; @@ -317,7 +331,8 @@ ngModule.component('vnAutocomplete', { order: '@?', limit: ' { expect(controller.address.city).toEqual('New York'); expect(controller.address.provinceFk).toEqual(1); - expect(controller.address.countryFk).toEqual(2); }); }); }); diff --git a/modules/client/front/address/edit/index.html b/modules/client/front/address/edit/index.html index b54e98901..c2dce8f37 100644 --- a/modules/client/front/address/edit/index.html +++ b/modules/client/front/address/edit/index.html @@ -60,9 +60,10 @@ url="/api/Postcodes/location" fields="['code', 'townFk']" field="$ctrl.address.postalCode" + where="{townFk: town.selection.id}" selection="$ctrl.postcodeSelection" search-function="{code: $search}" - where="{townFk: town.selection.id}" + fetch-function="{townFk: town.selection.id}" order="code, townFk" show-field="code" value-field="code" diff --git a/modules/client/front/address/edit/index.spec.js b/modules/client/front/address/edit/index.spec.js index 9ce61bfe2..33aacb672 100644 --- a/modules/client/front/address/edit/index.spec.js +++ b/modules/client/front/address/edit/index.spec.js @@ -79,7 +79,6 @@ describe('Client', () => { expect(controller.address.city).toEqual('New York'); expect(controller.address.provinceFk).toEqual(1); - expect(controller.address.countryFk).toEqual(2); }); }); }); diff --git a/modules/client/front/fiscal-data/index.html b/modules/client/front/fiscal-data/index.html index 04bd1815f..67d7705ce 100644 --- a/modules/client/front/fiscal-data/index.html +++ b/modules/client/front/fiscal-data/index.html @@ -28,12 +28,39 @@ + + + + + + + + @@ -42,31 +69,6 @@ ({{town.province.country.country}}) - - - - - - - -