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

View File

@ -24,11 +24,32 @@ export default class AddressAutocomplete extends Component {
} }
set addressData(value) { set addressData(value) {
if (!value) return;
console.log(value); console.log(value);
this._addressData = 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'), template: require('./index.html'),
controller: AddressAutocomplete, controller: AddressAutocomplete,
bindings: { bindings: {
addressData: '<?' addressData: '<?',
postCode: '<?'
} }
}); });

View File

@ -195,6 +195,10 @@
label="Address" label="Address"
address-data="$ctrl.supplier" address-data="$ctrl.supplier"
ng-model="$ctrl.supplier.postCode" 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>
<vn-horizontal> <vn-horizontal>