Skip to content

Commit

Permalink
fix(search): Fix cadastre and pointer summary setting (#550)
Browse files Browse the repository at this point in the history
* fix(cadastre)text search cause the service to crash

* fix(search-bar) Propagate if the pointerposition is enabled to the search-settings

* refactor(search) change property name

* refactor(*) lint
  • Loading branch information
pelord authored and mbarbeau committed Jan 20, 2020
1 parent e3dc8b7 commit 15612e4
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion demo/src/app/geo/search/search.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<igo-panel title="Search">
<igo-search-bar
(pointerSummaryEnabled)="onPointerSummaryEnabledChange($event)"
(pointerSummaryStatus)="onPointerSummaryStatusChange($event)"
[searchSettings]="true"
(searchTermChange)="onSearchTermChange($event)"
(search)="onSearch($event)"
Expand Down
2 changes: 1 addition & 1 deletion demo/src/app/geo/search/search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class AppSearchComponent implements OnInit, OnDestroy {
});
}

onPointerSummaryEnabledChange(value) {
onPointerSummaryStatusChange(value) {
this.igoSearchPointerSummaryEnabled = value;
}

Expand Down
6 changes: 3 additions & 3 deletions packages/geo/src/lib/filter/shared/ogc-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,10 @@ export class OgcFilterWriter {
}

public handleOgcFiltersAppliedValue(
options: OgcFilterableDataSourceOptions,
fieldNameGeometry: string,
options: OgcFilterableDataSourceOptions,
fieldNameGeometry: string,
extent?: [number, number, number, number],
proj?: olProjection): string{
proj?: olProjection): string {
const ogcFilters = options.ogcFilters;
if (!ogcFilters) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@

<igo-search-settings
*ngIf="searchSettings"
(pointerSummaryEnabled)="pointerSummaryEnabled.emit($event)"
[pointerSummaryEnabled]="pointerSummaryEnabled"
(pointerSummaryStatus)="pointerSummaryStatus.emit($event)"
(searchSourceChange)="onSearchSettingsChange()">
</igo-search-settings>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class SearchBarComponent implements OnInit, OnDestroy {
/**
* Event emitted when the pointer summary is activated by the searchbar setting
*/
@Output() pointerSummaryEnabled = new EventEmitter<boolean>();
@Output() pointerSummaryStatus = new EventEmitter<boolean>();

/**
* Search term
Expand All @@ -120,6 +120,7 @@ export class SearchBarComponent implements OnInit, OnDestroy {
}
readonly disabled$: BehaviorSubject<boolean> = new BehaviorSubject(false);

@Input() pointerSummaryEnabled: boolean = false;
/**
* Whether a float label should be displayed
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ export class SearchResultsComponent implements OnInit, OnDestroy {

return Array.from(grouped.keys()).map((source: SearchSource) => {
if (this.pageIterator[source.getId()] === undefined) {
this.pageIterator[source.getId()] = 1
};
this.pageIterator[source.getId()] = 1;
}
return {source, results: grouped.get(source)};
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<span class="pointer-summary-slide-toggle-container mat-typography">
<mat-slide-toggle class="pointer-summary-option" (change)="changePointerReverseSearch($event)" tooltip-position="below"
matTooltipShowDelay="500" [matTooltip]="'igo.geo.search.pointerSearchSummary.tooltip' | translate"
(click)="$event.stopPropagation()" [checked]="pointerReverseSearchEnabled" [labelPosition]="'after'">
(click)="$event.stopPropagation()" [checked]="pointerSummaryEnabled" [labelPosition]="'after'">
{{'igo.geo.search.pointerSearchSummary.title' | translate}}
</mat-slide-toggle>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
EventEmitter,
ChangeDetectionStrategy,
OnInit,
HostListener
HostListener,
Input
} from '@angular/core';

import { SearchSourceService } from '../shared/search-source.service';
Expand Down Expand Up @@ -34,7 +35,6 @@ import { MediaService } from '@igo2/core';
})
export class SearchSettingsComponent implements OnInit {

public pointerReverseSearchEnabled: boolean = false;
public hasPointerReverseSearchSource: boolean = false;

public buffer = [];
Expand All @@ -44,6 +44,8 @@ export class SearchSettingsComponent implements OnInit {
return this.mediaService.isTouchScreen();
}

@Input() pointerSummaryEnabled: boolean = false;

/**
* Event emitted when the enabled search source changes
*/
Expand All @@ -52,14 +54,14 @@ export class SearchSettingsComponent implements OnInit {
/**
* Event emitted when the pointer summary is activated
*/
@Output() pointerSummaryEnabled = new EventEmitter<boolean>();
@Output() pointerSummaryStatus = new EventEmitter<boolean>();

@HostListener('document:keydown', ['$event'])
handleKeyboardEvent(event: KeyboardEvent) {

if (event.keyCode === 113) {
this.pointerReverseSearchEnabled = !this.pointerReverseSearchEnabled;
this.pointerSummaryEnabled.emit(this.pointerReverseSearchEnabled);
this.pointerSummaryEnabled = !this.pointerSummaryEnabled;
this.pointerSummaryStatus.emit(this.pointerSummaryEnabled);
}
}

Expand Down Expand Up @@ -180,7 +182,7 @@ export class SearchSettingsComponent implements OnInit {

getAvailableHashtagsValues(setting: SettingOptions) {
if (setting.hashtags) {
let output: string[] = [];
const output: string[] = [];
for (let value of setting.hashtags) {
value = '#' + value;
output.push(value);
Expand All @@ -197,11 +199,11 @@ export class SearchSettingsComponent implements OnInit {
changePointerReverseSearch(event, fromTitleButton?: boolean) {
if (fromTitleButton) {
event.stopPropagation();
this.pointerReverseSearchEnabled = !this.pointerReverseSearchEnabled;
this.pointerSummaryEnabled = !this.pointerSummaryEnabled;
} else {
this.pointerReverseSearchEnabled = event.checked;
this.pointerSummaryEnabled = event.checked;
}

this.pointerSummaryEnabled.emit(this.pointerReverseSearchEnabled);
this.pointerSummaryStatus.emit(this.pointerSummaryEnabled);
}
}
2 changes: 1 addition & 1 deletion packages/geo/src/lib/search/shared/sources/cadastre.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class CadastreSearchSource extends SearchSource implements TextSearch {
term = term.startsWith(',') ? term.substr(1) : term;

const params = this.computeSearchRequestParams(term, options || {});
if (!params.get('numero')) {
if (!params.get('numero') || !params.get('numero').match(/^[0-9,]+$/g)) {
return of([]);
}
return this.http
Expand Down

0 comments on commit 15612e4

Please sign in to comment.