Skip to content
Snippets Groups Projects
Commit 67a2106e authored by Yoan VALLET's avatar Yoan VALLET
Browse files

fix(orientation): wrong result with address on 2 postcodes

parent f3a2f27d
Branches
Tags
2 merge requests!2921.17,!248fix(orientation): wrong result with address on 2 postcodes
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;
},
......
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? = [];
}
......@@ -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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment