From 3bca15708fcd274da62428d1513afccfb324f9a8 Mon Sep 17 00:00:00 2001 From: gerard Date: Mon, 2 Jul 2018 13:13:26 +0200 Subject: [PATCH] Bug #312 Autocomplete intenta mostrar el valor antes de tener los datos --- .../core/src/components/autocomplete/autocomplete.js | 9 +++++++++ .../src/components/autocomplete/autocomplete.spec.js | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/client/core/src/components/autocomplete/autocomplete.js b/client/core/src/components/autocomplete/autocomplete.js index e8dfe906f..ffa353ea2 100755 --- a/client/core/src/components/autocomplete/autocomplete.js +++ b/client/core/src/components/autocomplete/autocomplete.js @@ -31,6 +31,15 @@ export default class Autocomplete extends Input { this.element.querySelector('.mdl-textfield')); } + set url(value) { + this._url = value; + this.refreshSelection(); + } + + get url() { + return this._url; + } + /** * @type {any} The autocomplete value. */ diff --git a/client/core/src/components/autocomplete/autocomplete.spec.js b/client/core/src/components/autocomplete/autocomplete.spec.js index 6ed409af2..adb4415f6 100644 --- a/client/core/src/components/autocomplete/autocomplete.spec.js +++ b/client/core/src/components/autocomplete/autocomplete.spec.js @@ -21,6 +21,16 @@ describe('Component vnAutocomplete', () => { controller = _$componentController_('vnAutocomplete', {$element, $scope, $httpBackend, $transclude: null}); })); + describe('url() setter', () => { + it(`should set url controllers property and call refreshSelection`, () => { + spyOn(controller, "refreshSelection"); + controller.url = "url"; + + expect(controller.url).toEqual("url"); + expect(controller.refreshSelection).toHaveBeenCalledWith(); + }); + }); + describe('field() setter/getter', () => { it(`should set field controllers property`, () => { controller.field = data.id;