refs #5888 create address-autocomplete
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2023-07-11 15:29:38 +02:00
parent eb75a75362
commit bd205418a0
3 changed files with 57 additions and 25 deletions

View File

@ -1,21 +1,27 @@
<vn-horizontal>
<vn-textfield
vn-one
label="Street"
ng-model="$ctrl.addressData.street"
rule
vn-focus>
</vn-textfield>
</vn-horizontal>
<tpl-item class="address">
<span>
{{::street}}, {{::postCode}}, {{::city}}, {{::province.name}}
</span>
</tpl-item>
<append>
<vn-icon-button
ui-sref="client.card.address.edit({id: $ctrl.clientId, addressId: $ctrl.addressId})"
icon="edit"
vn-tooltip="Edit address">
</vn-icon-button>
</append>
<vn-crud-model
auto-load="true"
url="Postcodes/location"
data="$ctrl.locations"
order="code">
</vn-crud-model>
<vn-autocomplete
vn-two
vn-id="location"
label="Location"
vn-name="location"
ng-model="$ctrl.postCode"
data="$ctrl.locations">
<tpl-item class="address">
<span>
{{::name}}
</span>
</tpl-item>
<append>
<vn-icon-button
ui-sref="client.card.address.edit({id: $ctrl.clientId, addressId: $ctrl.addressId})"
icon="edit"
vn-tooltip="Edit address">
</vn-icon-button>
</append>
</vn-autocomplete>

View File

@ -24,11 +24,32 @@ export default class AddressAutocomplete extends Component {
}
set addressData(value) {
if (!value) return;
console.log(value);
this._addressData = value;
this.url = 'Postcodes/location';
// if (value)
// this.input.value = value.street;
}
get locations() {
return this._locations;
}
set locations(value) {
if (!value) return;
console.log('set locations');
console.log(value);
for (let location of value) {
location.map(l => {
return {
name: l.code + ' ' + l.town.name + ', ' + l.town.province.name + ', ' + l.town.province.country.name,
postalCode: l.code,
townFk: l.town.id,
provinceFk: l.town.province.id,
countryFk: l.town.province.country.id,
};
});
}
console.log('location', location);
this._locations = value;
}
}
@ -36,6 +57,7 @@ ngModule.vnComponent('vnAddressAutocomplete', {
template: require('./index.html'),
controller: AddressAutocomplete,
bindings: {
addressData: '<?'
addressData: '<?',
postCode: '<?'
}
});

View File

@ -195,6 +195,10 @@
label="Address"
address-data="$ctrl.supplier"
ng-model="$ctrl.supplier.postCode"
post-code="$ctrl.supplier.postCode"
town="$ctrl.supplier.city"
province="$ctrl.supplier.provinceFk"
country="$ctrl.supplier.countryFk"
/>
</vn-horizontal>
<vn-horizontal>