diff --git a/src/app/form/orientation-form/orientation-form.component.ts b/src/app/form/orientation-form/orientation-form.component.ts index 31b2c36d0739011568ed088b17966434370f4175..50b648f25e42a26f6acf91a7b9ad0b3d46b3544f 100644 --- a/src/app/form/orientation-form/orientation-form.component.ts +++ b/src/app/form/orientation-form/orientation-form.component.ts @@ -1,8 +1,6 @@ -import { stringify } from '@angular/compiler/src/util'; -import { Component, EventEmitter, HostListener, OnInit, Output } from '@angular/core'; -import { AbstractControl, Form, FormArray, FormControl, FormGroup, Validators } from '@angular/forms'; +import { Component, HostListener, OnInit } from '@angular/core'; +import { AbstractControl, FormArray, FormControl, FormGroup, Validators } from '@angular/forms'; import { Meta } from '@angular/platform-browser'; -import { GeoJson } from '../../map/models/geojson.model'; import { Address } from '../../models/address.model'; import { OrientationFormFilters } from '../../models/orientation-filter.object'; import { Structure } from '../../models/structure.model'; @@ -10,14 +8,13 @@ import { GeojsonService } from '../../services/geojson.service'; import { RouterListenerService } from '../../services/routerListener.service'; import { StructureService } from '../../services/structure.service'; import { CategoryEnum } from '../../shared/enum/category.enum'; -import * as _ from 'lodash'; import { Category } from '../../structure-list/models/category.model'; import { Filter } from '../../structure-list/models/filter.model'; import { Module } from '../../structure-list/models/module.model'; import { SearchService } from '../../structure-list/services/search.service'; -import { PageTypeEnum } from './pageType.enum'; -import { Utils } from '../../utils/utils'; import { CustomRegExp } from '../../utils/CustomRegExp'; +import { Utils } from '../../utils/utils'; +import { PageTypeEnum } from './pageType.enum'; @Component({ selector: 'app-orientation-form', @@ -163,6 +160,7 @@ export class OrientationFormComponent implements OnInit { numero: new FormControl(''), street: new FormControl('', Validators.required), commune: new FormControl('', Validators.required), + postcode: new FormControl(''), }), structureAccompaniment: new FormControl(orientationFormFilters.structureAccompaniment, Validators.required), contactAccompanimentPhone: new FormControl( @@ -344,6 +342,7 @@ export class OrientationFormComponent implements OnInit { this.getOrientationControl('address').get('numero').setValue(address.numero); this.getOrientationControl('address').get('street').setValue(address.street); this.getOrientationControl('address').get('commune').setValue(address.commune); + this.getOrientationControl('address').get('postcode').setValue(address.postcode); this.userLocation = address.coordinates; } else { this.orientationForm.get('address').reset(); @@ -441,7 +440,11 @@ export class OrientationFormComponent implements OnInit { private setStructuresAndCoord(): void { this.geoJsonService - .getCoord(this.orientationForm.value.address.numero, this.orientationForm.value.address.street, '69000') + .getCoord( + this.orientationForm.value.address.numero, + this.orientationForm.value.address.street, + this.orientationForm.value.address.postcode ? this.orientationForm.value.address.postcode : '69000' + ) .subscribe((res) => { this.structureService.getStructures(this.filters.filter((elem) => elem.checked == true)).subscribe((data) => { data.map((structure) => { @@ -518,6 +521,7 @@ export class OrientationFormComponent implements OnInit { } this.getOrientationControl('address').get('street').setValue(location.properties.street); this.getOrientationControl('address').get('commune').setValue(location.properties.city); + this.getOrientationControl('address').get('postcode').setValue(location.properties.postcode); this.setValidationsForm(); this.isLoading = false; }, diff --git a/src/app/models/address.model.ts b/src/app/models/address.model.ts index 0b30ddc1cfb70325d383260bd511831f61d8fcb8..8ef6bc349a222c69531a34eac3331b4174c974a2 100644 --- a/src/app/models/address.model.ts +++ b/src/app/models/address.model.ts @@ -1,6 +1,7 @@ -export class Address { - numero: string = null; - street: string = null; - commune: string = null; - coordinates? = []; -} +export class Address { + numero: string = null; + street: string = null; + commune: string = null; + postcode?: number = null; + coordinates? = []; +} diff --git a/src/app/shared/components/address-autocomplete/address-autocomplete.component.ts b/src/app/shared/components/address-autocomplete/address-autocomplete.component.ts index 45710320a46494229892ebfe77369aaeaf4ebbd1..f079a7934fa946e79aea7cd21c6dbf759f4788e9 100644 --- a/src/app/shared/components/address-autocomplete/address-autocomplete.component.ts +++ b/src/app/shared/components/address-autocomplete/address-autocomplete.component.ts @@ -59,6 +59,7 @@ export class AddressAutocompleteComponent implements OnInit { address.numero = hit.properties.housenumber ? hit.properties.housenumber : null; address.commune = hit.properties.city; address.coordinates = hit.geometry.coordinates; + address.postcode = hit.properties.postcode; if (hit.properties.street) { address.street = hit.properties.street; } else {