removed autocompletion on change postal code #1638
gitea/salix/master This commit looks good Details

This commit is contained in:
Joan Sanchez 2019-09-02 09:11:40 +02:00
parent a1e3ea7ad7
commit 8726aa70c5
5 changed files with 3 additions and 72 deletions

View File

@ -61,17 +61,11 @@
fields="['code', 'townFk']"
field="$ctrl.address.postalCode"
where="{townFk: town.selection.id}"
selection="$ctrl.postcodeSelection"
search-function="{code: $search}"
fetch-function="{townFk: town.selection.id}"
order="code, townFk"
show-field="code"
value-field="code"
label="Postcode">
<tpl-item>
{{code}}, {{town.name}} - {{town.province.name}}
({{town.province.country.country}})
</tpl-item>
</vn-autocomplete>
<vn-icon-button vn-auto margin-medium-v
icon="add_circle"

View File

@ -20,23 +20,6 @@ export default class Controller {
this.$state.go('client.card.address.index');
}
get postcodeSelection() {
return this._postcodeSelection;
}
set postcodeSelection(selection) {
const hasValue = this._postcodeSelection;
this._postcodeSelection = selection;
if (!selection || !hasValue) return;
const town = selection.town;
const province = town.province;
this.address.city = town.name;
this.address.provinceFk = province.id;
}
onResponse(response) {
this.address.postalCode = response.code;
}

View File

@ -55,31 +55,5 @@ describe('Client', () => {
expect(controller.$state.go).toHaveBeenCalledWith('client.card.address.index');
});
});
describe('postcodeSelection() setter', () => {
it(`should set the town, province and contry properties`, () => {
controller.address = {};
controller._postcodeSelection = {townFk: 2};
controller.postcodeSelection = {
townFk: 1,
code: 46001,
town: {
id: 1,
name: 'New York',
province: {
id: 1,
name: 'New york',
country: {
id: 2,
name: 'USA'
}
}
}
};
expect(controller.address.city).toEqual('New York');
expect(controller.address.provinceFk).toEqual(1);
});
});
});
});

View File

@ -58,16 +58,12 @@
url="/api/Postcodes/location"
fields="['code', 'townFk']"
field="$ctrl.client.postcode"
selection="$ctrl.postcodeSelection"
search-function="{code: $search}"
where="{townFk: town.selection.id}"
order="code, townFk"
show-field="code"
value-field="code"
label="Postcode">
<tpl-item>
{{code}}, {{town.name}} - {{town.province.name}}
({{town.province.country.country}})
</tpl-item>
label="Postcode">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal pad-small-v>

View File

@ -56,24 +56,8 @@ export default class Controller {
);
}
}
get postcodeSelection() {
return this._postcodeSelection;
}
set postcodeSelection(selection) {
const hasValue = this._postcodeSelection;
this._postcodeSelection = selection;
if (!selection || !hasValue) return;
const town = selection.town;
const province = town.province;
this.client.city = town.name;
this.client.provinceFk = province.id;
}
}
Controller.$inject = ['$scope', '$http', 'vnApp', '$translate'];
ngModule.component('vnClientFiscalData', {