Skip to content
Snippets Groups Projects
Commit 13617b91 authored by Jérémie BRISON's avatar Jérémie BRISON
Browse files

fix(autoComplete) : fix adress response

parent 1b1dbe85
No related branches found
No related tags found
3 merge requests!103Recette,!102Dev,!92Fix/auto complete
...@@ -28,7 +28,7 @@ export class AddressAutocompleteComponent implements OnInit { ...@@ -28,7 +28,7 @@ export class AddressAutocompleteComponent implements OnInit {
if (!this.isAlreadySearching) { if (!this.isAlreadySearching) {
this.isAlreadySearching = true; this.isAlreadySearching = true;
this.addressService.searchAddress(searchString).subscribe((data) => { this.addressService.searchAddress(searchString).subscribe((data) => {
this.data = data.hits.hits.slice(0, this.AUTOCOMPLETE_NBR); this.data = data.features;
this.isAlreadySearching = false; this.isAlreadySearching = false;
}); });
} }
...@@ -37,9 +37,9 @@ export class AddressAutocompleteComponent implements OnInit { ...@@ -37,9 +37,9 @@ export class AddressAutocompleteComponent implements OnInit {
public selectedResult(hit: any): void { public selectedResult(hit: any): void {
const address = new Address(); const address = new Address();
address.numero = hit._source['data-fr'].properties.numero_str; address.numero = hit.properties.housenumber ? hit.properties.housenumber : 0;
address.street = hit._source['data-fr'].properties.voie_str; address.street = hit.properties.street;
address.commune = hit._source['data-fr'].properties.commune_str; address.commune = hit.properties.city;
const value = this.parseHitToAddress(hit); const value = this.parseHitToAddress(hit);
// Set input value // Set input value
this.searchAddress.nativeElement.value = value; this.searchAddress.nativeElement.value = value;
...@@ -50,6 +50,9 @@ export class AddressAutocompleteComponent implements OnInit { ...@@ -50,6 +50,9 @@ export class AddressAutocompleteComponent implements OnInit {
} }
public parseHitToAddress(hit: any): string { public parseHitToAddress(hit: any): string {
return `${hit._source['data-fr'].properties.numero_str} ${hit._source['data-fr'].properties.voie_str} ${hit._source['data-fr'].properties.commune_str}`; if (hit.properties.housenumber) {
return `${hit.properties.housenumber} ${hit.properties.street} ${hit.properties.city}`;
}
return `${hit.properties.street} ${hit.properties.city}`;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment