Skip to content

Commit

Permalink
fix(*): minors fixs
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarbeau committed Aug 29, 2019
1 parent d87babc commit 80b6c38
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 100 deletions.
73 changes: 31 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@igo2/geo": "^1.0.0-alpha.6",
"@igo2/integration": "^1.0.0-alpha.6",
"@igo2/utils": "^1.0.0-alpha.6",
"@mat-datetimepicker/core": "^3.0.0-beta.0",
"classlist.js": "^1.1.20150312",
"core-js": "^2.6.5",
"file-saver": "^1.3.8",
Expand Down
9 changes: 6 additions & 3 deletions src/app/pages/portal/portal.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@
</button>

<igo-search-bar
#searchBar
[term]="searchBarTerm"
[minLength]="minSearchTermLength"
[searchSettings]="true"
(change)="onSearchTermChange($event)"
(search)="onSearch($event)">
(searchTermChange)="onSearchTermChange($event)"
(search)="onSearch($event)"
(clearFeature)="onClearSearch()">
</igo-search-bar>

<app-sidenav
[map]="map"
[(opened)]="sidenavOpened">
[(opened)]="sidenavOpened"
(toolChange)="toolChanged($event)">
</app-sidenav>

<igo-map-browser
Expand Down
21 changes: 15 additions & 6 deletions src/app/pages/portal/portal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import {
ActionStore,
EntityStore,
// getEntityTitle,
Toolbox
Toolbox,
Tool
} from '@igo2/common';
import { AuthService } from '@igo2/auth';
import { DetailedContext } from '@igo2/context';
Expand Down Expand Up @@ -121,6 +122,7 @@ export class PortalComponent implements OnInit, OnDestroy {
};

@ViewChild('mapBrowser', { read: ElementRef }) mapBrowser: ElementRef;
@ViewChild('searchBar', { read: ElementRef }) searchBar: ElementRef;

get map(): IgoMap {
return this.mapState.map;
Expand Down Expand Up @@ -381,13 +383,19 @@ export class PortalComponent implements OnInit, OnDestroy {
this.sidenavOpened ? this.closeSidenav() : this.openSidenav();
}

public toolChanged(tool: Tool) {
if (tool && tool.name === 'searchResults') {
this.searchBar.nativeElement.getElementsByTagName('input')[0].focus();
}
}

private onChangeContext(context: DetailedContext) {
if (context === undefined) {
return;
}

if (this.contextLoaded) {
this.toolState.toolbox.activateTool('mapDetails');
this.toolbox.activateTool('mapDetails');
}

this.contextLoaded = true;
Expand All @@ -398,7 +406,7 @@ export class PortalComponent implements OnInit, OnDestroy {
// this.closeToastPanel();
// }

this.toolState.toolbox.activateTool('searchResults');
this.toolbox.activateTool('searchResults');
this.openSidenav();
}

Expand Down Expand Up @@ -429,17 +437,18 @@ export class PortalComponent implements OnInit, OnDestroy {
// }

addFeatureToMap(result: SearchResult<Feature>) {
const feature = result.data;
const feature = result ? result.data : undefined;

// Somethimes features have no geometry. It happens with some GetFeatureInfo
if (feature.geometry === undefined) {
if (!feature || feature.geometry === undefined) {
this.map.overlay.clear();
return;
}

this.map.overlay.setFeatures([feature], FeatureMotion.Default);
}

private onClearSearch() {
public onClearSearch() {
this.searchStore.clear();
this.map.overlay.clear();
// this.closeToastPanel();
Expand Down
Loading

0 comments on commit 80b6c38

Please sign in to comment.