Commit fae08d95 authored by Alish's avatar Alish
Browse files

feat: use default location when creating store or carrier #1016

parent 97756691
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
import { Component, ViewChild, EventEmitter } from '@angular/core';
import {
	Component,
	ViewChild,
	EventEmitter,
	AfterViewInit
} from '@angular/core';
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
import { ToasterService } from 'angular2-toaster';

@@ -16,7 +21,7 @@ import { TranslateService } from '@ngx-translate/core';
	templateUrl: './carrier-mutation.component.html',
	styleUrls: ['./carrier-mutation.component.scss']
})
export class CarrierMutationComponent {
export class CarrierMutationComponent implements AfterViewInit {
	@ViewChild('basicInfoForm', { static: false })
	basicInfoForm: BasicInfoFormComponent;

@@ -66,6 +71,12 @@ export class CarrierMutationComponent {
		return this._translate(this.BUTTON_PREV);
	}

	ngAfterViewInit(): void {
		if (this.locationForm) {
			this.locationForm.setDefaultCoords();
		}
	}

	onGeometrySend(
		geometry:
			| google.maps.places.PlaceGeometry
+11 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import { pick, isEmpty } from 'lodash';
import { ToasterService } from 'angular2-toaster';

import { countries } from '@modules/server.common/data/abbreviation-to-country';
import { environment } from 'environment';

@Component({
	selector: 'ea-location-form',
@@ -206,6 +207,16 @@ export class LocationFormComponent implements AfterViewInit {
		this.showCoordinates = !this.showCoordinates;
	}

	setDefaultCoords() {
		const lat = environment.DEFAULT_LATITUDE;
		const lng = environment.DEFAULT_LONGITUDE;

		if (lat && lng) {
			this.coordinates.setValue([lat, lng]);
			this.onCoordinatesChanged();
		}
	}

	private _applyFormattedAddress(address: string) {
		if (this.searchElement) {
			this.searchElement.nativeElement.value = address;
+4 −0
Original line number Diff line number Diff line
@@ -90,6 +90,10 @@ export class WarehouseMutationComponent implements AfterViewInit {
				elementRef['style']['zIndex'] = 10000;
			}
		}, 2000);

		if (this.locationForm) {
			this.locationForm.setDefaultCoords();
		}
	}

	onCoordinatesChanges(coords: number[]) {