From 66e7665296a129925c7124ff63af3c30aee8d51f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petro=CC=81=20Tama=CC=81s?= Date: Thu, 29 Mar 2018 10:34:41 +0200 Subject: [PATCH] fix: Disable getRoute if the segment list is empty Closes #141 --- .../hike-edit-pois-external.component.html | 6 +++++- .../hike-edit-pois-external.component.ts | 9 +++++++-- .../hike-edit-pois-gtrack.component.html | 6 +++++- .../hike-edit-pois-gtrack.component.ts | 11 +++++++++-- src/app/shared/services/admin-map/lib/route-info.ts | 2 +- 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/app/pages/hike-edit/components/hike-edit-pois-external/hike-edit-pois-external.component.html b/src/app/pages/hike-edit/components/hike-edit-pois-external/hike-edit-pois-external.component.html index 9ca78549..210cbb31 100644 --- a/src/app/pages/hike-edit/components/hike-edit-pois-external/hike-edit-pois-external.component.html +++ b/src/app/pages/hike-edit/components/hike-edit-pois-external/hike-edit-pois-external.component.html @@ -1,7 +1,11 @@
- +
diff --git a/src/app/pages/hike-edit/components/hike-edit-pois-external/hike-edit-pois-external.component.ts b/src/app/pages/hike-edit/components/hike-edit-pois-external/hike-edit-pois-external.component.ts index 1f74c0a4..f565d10a 100644 --- a/src/app/pages/hike-edit/components/hike-edit-pois-external/hike-edit-pois-external.component.ts +++ b/src/app/pages/hike-edit/components/hike-edit-pois-external/hike-edit-pois-external.component.ts @@ -11,9 +11,9 @@ import { IExternalPoiType, IExternalPoi, IWikipediaPoi, IGooglePoi, IOsmPoi } from 'app/shared/interfaces'; import { - State, hikeEditPoiActions, IExternalPoiListContextState, commonPoiActions + State, hikeEditPoiActions, IExternalPoiListContextState, commonPoiActions, IHikeEditRoutePlannerState } from 'app/store'; -import { HikeEditMapSelectors, HikeEditPoiSelectors } from 'app/store/selectors' +import { HikeEditMapSelectors, HikeEditPoiSelectors, HikeEditRoutePlannerSelectors } from 'app/store/selectors' import * as _ from 'lodash'; @@ -24,6 +24,7 @@ import * as _ from 'lodash'; export class HikeEditPoisExternalComponent implements OnInit, OnDestroy { @Input() poiType: IExternalPoiType; public pois$: Observable; + public routeInfoData$: Observable; public loading$: Observable; public showOnrouteMarkers$: Observable; public showOffrouteMarkers$: Observable; @@ -36,6 +37,7 @@ export class HikeEditPoisExternalComponent implements OnInit, OnDestroy { private _hikeEditMapSelectors: HikeEditMapSelectors, private _hikeEditPoiSelectors: HikeEditPoiSelectors, private _poiSelectors: PoiSelectors, + private _hikeEditRoutePlannerSelectors: HikeEditRoutePlannerSelectors, private _poiEditorService: PoiEditorService ) {} @@ -51,6 +53,9 @@ export class HikeEditPoisExternalComponent implements OnInit, OnDestroy { // Poi list from store this.pois$ = this._getSubdomainSelector(this.poiType.subdomain); + // Route info from the store (for disabling GET buttons) + this.routeInfoData$ = this._store.select(this._hikeEditRoutePlannerSelectors.getRoutePlanner); + // Update poi properties after poi list loaded this._store .select(this._hikeEditPoiSelectors.getHikeEditContextPropertySelector(this.poiType.subdomain, 'loaded')) diff --git a/src/app/pages/hike-edit/components/hike-edit-pois-gtrack/hike-edit-pois-gtrack.component.html b/src/app/pages/hike-edit/components/hike-edit-pois-gtrack/hike-edit-pois-gtrack.component.html index a46efa15..62360f25 100644 --- a/src/app/pages/hike-edit/components/hike-edit-pois-gtrack/hike-edit-pois-gtrack.component.html +++ b/src/app/pages/hike-edit/components/hike-edit-pois-gtrack/hike-edit-pois-gtrack.component.html @@ -1,7 +1,11 @@
- +
diff --git a/src/app/pages/hike-edit/components/hike-edit-pois-gtrack/hike-edit-pois-gtrack.component.ts b/src/app/pages/hike-edit/components/hike-edit-pois-gtrack/hike-edit-pois-gtrack.component.ts index dc2e1a29..0cbc018c 100644 --- a/src/app/pages/hike-edit/components/hike-edit-pois-gtrack/hike-edit-pois-gtrack.component.ts +++ b/src/app/pages/hike-edit/components/hike-edit-pois-gtrack/hike-edit-pois-gtrack.component.ts @@ -11,9 +11,11 @@ import { AdminMap, AdminMapService, AdminMapMarker } from 'app/shared/services/a import { PoiEditorService } from 'app/shared/services'; import { IGTrackPoi } from 'app/shared/interfaces'; import { - State, hikeEditPoiActions, IExternalPoiListContextState, commonPoiActions, commonGeoSearchActions, hikeEditGeneralInfoActions, + State, hikeEditPoiActions, IExternalPoiListContextState, commonPoiActions, commonGeoSearchActions, hikeEditGeneralInfoActions, IHikeEditRoutePlannerState, } from 'app/store'; -import { HikeEditPoiSelectors, HikeEditMapSelectors, HikeEditGeneralInfoSelectors } from 'app/store/selectors'; +import { + HikeEditPoiSelectors, HikeEditMapSelectors, HikeEditGeneralInfoSelectors, HikeEditRoutePlannerSelectors +} from 'app/store/selectors'; import * as _ from 'lodash'; import * as uuid from 'uuid/v1'; @@ -24,6 +26,7 @@ import * as uuid from 'uuid/v1'; }) export class HikeEditPoisGTrackComponent implements OnInit, OnDestroy { public pois$: Observable; + public routeInfoData$: Observable; public searchContext$: Observable; public showOnrouteMarkers$: Observable; public showOffrouteMarkers$: Observable; @@ -37,6 +40,7 @@ export class HikeEditPoisGTrackComponent implements OnInit, OnDestroy { private _hikeEditMapSelectors: HikeEditMapSelectors, private _hikeEditPoiSelectors: HikeEditPoiSelectors, private _hikeEditGeneralInfoSelectors: HikeEditGeneralInfoSelectors, + private _hikeEditRoutePlannerSelectors: HikeEditRoutePlannerSelectors, private _geoSearchSelectors: GeoSearchSelectors, private _geometryService: GeometryService, private _poiSelectors: PoiSelectors @@ -74,6 +78,9 @@ export class HikeEditPoisGTrackComponent implements OnInit, OnDestroy { this._poiEditorService.refreshPoiMarkers(this._map); }); + // Route info from the store (for disabling GET buttons) + this.routeInfoData$ = this._store.select(this._hikeEditRoutePlannerSelectors.getRoutePlanner); + // // Contexts // diff --git a/src/app/shared/services/admin-map/lib/route-info.ts b/src/app/shared/services/admin-map/lib/route-info.ts index b42e340e..05c9cc4c 100644 --- a/src/app/shared/services/admin-map/lib/route-info.ts +++ b/src/app/shared/services/admin-map/lib/route-info.ts @@ -82,7 +82,7 @@ export class RouteInfo { public getSearchBounds() { let _path = this.getPath(); - if (typeof _path !== 'undefined') { + if (_path) { // declare as 'any' for avoid d3.geoBounds error let _buffer: any = turf.buffer(_path, 1000, {units: 'meters'});