Skip to content

Commit

Permalink
Ogc filter (#458)
Browse files Browse the repository at this point in the history
* refactor(ogc-filter) missing icon

* refactor(ogcFilter)Behavior of not editable ogcFilters

* refactor(filterable-datasource) Catch empty filter with pushbuttons

* refactor(ogcfilter)Placeholder on input fields

* Delete 3-release.bat
  • Loading branch information
pelord authored and mbarbeau committed Oct 10, 2019
1 parent 6f37684 commit 2c9ffa8
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export class WFSDataSource extends DataSource {
const ogcFilterWriter = new OgcFilterWriter();
(this.options as OgcFilterableDataSourceOptions).ogcFilters =
ogcFilterWriter.defineOgcFiltersDefaultOptions(ogcFilters, fieldNameGeometry);
if ((this.options as OgcFilterableDataSourceOptions).ogcFilters.enabled) {
if (
(this.options as OgcFilterableDataSourceOptions).ogcFilters.enabled &&
(this.options as OgcFilterableDataSourceOptions).ogcFilters.editable
) {
this.wfsService.getSourceFieldsFromWFS(this.options);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class WMSDataSource extends DataSource {
console.log('*******************************');
}

if (options.paramsWFS && initOgcFilters && initOgcFilters.enabled) {
if (options.paramsWFS && initOgcFilters && initOgcFilters.enabled && initOgcFilters.editable) {
this.wfsService.getSourceFieldsFromWFS(options);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@

<!-- PropertyIsEqualTo -->
<span *ngIf="currentFilter.operator === 'PropertyIsEqualTo' || currentFilter.operator === 'PropertyIsNotEqualTo'">
<mat-form-field>
<input [disabled]="!currentFilter.active" matInput [matAutocomplete]="auto" #expressionequalto (keyup)="changeProperty(currentFilter,'expression',expressionequalto.value)"
<mat-form-field [floatLabel]="floatLabel">
<input [placeholder]="'igo.geo.filter.placeholder' | translate" [disabled]="!currentFilter.active" matInput [matAutocomplete]="auto" #expressionequalto (keyup)="changeProperty(currentFilter,'expression',expressionequalto.value)"
(ngModelChange)="changeProperty(currentFilter,'expression',expressionequalto.value)" [ngModel]="currentFilter.expression">
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let value of values" [value]="value">
Expand All @@ -58,8 +58,8 @@

<!-- PropertyIsLike -->
<span *ngIf="currentFilter.operator === 'PropertyIsLike'">
<mat-form-field>
<input [disabled]="!currentFilter.active" matInput [matAutocomplete]="auto" #pattern (keyup)="changeProperty(currentFilter,'pattern',pattern.value)"
<mat-form-field [floatLabel]="floatLabel">
<input [placeholder]="'igo.geo.filter.placeholder' | translate" [disabled]="!currentFilter.active" matInput [matAutocomplete]="auto" #pattern (keyup)="changeProperty(currentFilter,'pattern',pattern.value)"
(ngModelChange)="changeProperty(currentFilter,'pattern',pattern.value)" [ngModel]="currentFilter.pattern">
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let value of values" [value]="value">
Expand All @@ -80,8 +80,8 @@

<!-- PropertyIs_Than -->
<span *ngIf="currentFilter.operator === 'PropertyIsGreaterThan' || currentFilter.operator === 'PropertyIsGreaterThanOrEqualTo' || currentFilter.operator === 'PropertyIsLessThan' || currentFilter.operator === 'PropertyIsLessThanOrEqualTo'">
<mat-form-field>
<input [disabled]="!currentFilter.active" matInput [matAutocomplete]="auto" #expressionthan type="number" (keyup)="changeNumericProperty(currentFilter,'expression',expressionthan.value)"
<mat-form-field [floatLabel]="floatLabel">
<input [placeholder]="'igo.geo.filter.placeholder' | translate" [disabled]="!currentFilter.active" matInput [matAutocomplete]="auto" #expressionthan type="number" (keyup)="changeNumericProperty(currentFilter,'expression',expressionthan.value)"
(ngModelChange)="changeNumericProperty(currentFilter,'expression',expressionthan.value)" [ngModel]="currentFilter.expression">
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let value of values" [value]="value">
Expand All @@ -98,8 +98,8 @@

<!-- PropertyIsBetween -->
<span *ngIf="currentFilter.operator === 'PropertyIsBetween'">
<mat-form-field>
<input [disabled]="!currentFilter.active" matInput [matAutocomplete]="auto" #lowerBoundary type="number" (keyup)="changeNumericProperty(currentFilter,'lowerBoundary',lowerBoundary.value)"
<mat-form-field [floatLabel]="floatLabel">
<input [placeholder]="'igo.geo.filter.placeholder' | translate" [disabled]="!currentFilter.active" matInput [matAutocomplete]="auto" #lowerBoundary type="number" (keyup)="changeNumericProperty(currentFilter,'lowerBoundary',lowerBoundary.value)"
(ngModelChange)="changeNumericProperty(currentFilter,'lowerBoundary',lowerBoundary.value)" [ngModel]="currentFilter.lowerBoundary">
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let value of values" [value]="value">
Expand All @@ -110,8 +110,8 @@
<mat-icon svgIcon="close"></mat-icon>
</button>
</mat-form-field>
<mat-form-field>
<input [disabled]="!currentFilter.active" matInput [matAutocomplete]="auto" #upperBoundary type="number" (keyup)="changeNumericProperty(currentFilter,'upperBoundary',upperBoundary.value)"
<mat-form-field [floatLabel]="floatLabel">
<input [placeholder]="'igo.geo.filter.placeholder' | translate" [disabled]="!currentFilter.active" matInput [matAutocomplete]="auto" #upperBoundary type="number" (keyup)="changeNumericProperty(currentFilter,'upperBoundary',upperBoundary.value)"
(ngModelChange)="changeNumericProperty(currentFilter,'upperBoundary',upperBoundary.value)" [ngModel]="currentFilter.upperBoundary">
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let value of values" [value]="value">
Expand All @@ -129,8 +129,8 @@

<!-- During -->
<span *ngIf="currentFilter.operator === 'During'">
<mat-form-field>
<input [disabled]="!currentFilter.active" matInput [matAutocomplete]="auto" #begin (keyup)="changeProperty(currentFilter,'begin',begin.value)"
<mat-form-field [floatLabel]="floatLabel">
<input [placeholder]="'igo.geo.filter.placeholder' | translate" [disabled]="!currentFilter.active" matInput [matAutocomplete]="auto" #begin (keyup)="changeProperty(currentFilter,'begin',begin.value)"
(ngModelChange)="changeProperty(currentFilter,'begin',begin.value)" [ngModel]="currentFilter.begin">
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let value of values " [value]="value">
Expand All @@ -142,8 +142,8 @@
</button>
</mat-form-field>

<mat-form-field>
<input [disabled]="!currentFilter.active" matInput [matAutocomplete]="auto" #end (keyup)="changeProperty(currentFilter,'end',end.value)"
<mat-form-field [floatLabel]="floatLabel">
<input [placeholder]="'igo.geo.filter.placeholder' | translate" [disabled]="!currentFilter.active" matInput [matAutocomplete]="auto" #end (keyup)="changeProperty(currentFilter,'end',end.value)"
(ngModelChange)="changeProperty(currentFilter,'end',end.value)" [ngModel]="currentFilter.end">
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let value of values" [value]="value">
Expand Down Expand Up @@ -182,8 +182,8 @@
</button>


<mat-form-field *ngIf="currentFilter.igoSpatialSelector === 'snrc'">
<input matInput #htmlSnrc (keyup)="changeGeometry(currentFilter,htmlSnrc.value)" (blur)="changeGeometry(currentFilter,htmlSnrc.value)"
<mat-form-field *ngIf="currentFilter.igoSpatialSelector === 'snrc'" [floatLabel]="floatLabel">
<input [placeholder]="'igo.geo.filter.placeholderSnrc' | translate" matInput #htmlSnrc (keyup)="changeGeometry(currentFilter,htmlSnrc.value)" (blur)="changeGeometry(currentFilter,htmlSnrc.value)"
[(ngModel)]="snrc">
<button mat-button *ngIf="snrc" matSuffix mat-icon-button aria-label="Clear" (click)="snrc=''">
<mat-icon svgIcon="close"></mat-icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { OgcFilterWriter } from '../../filter/shared/ogc-filter';
import { WktService } from '../../wkt/shared/wkt.service';
import { IgoMap } from '../../map';
import { OgcFilterOperatorType } from '../../filter/shared/ogc-filter.enum';
import { FloatLabelType } from '@angular/material';

@Component({
selector: 'igo-ogc-filter-form',
Expand All @@ -39,6 +40,8 @@ export class OgcFilterFormComponent implements OnInit {

@Input() currentFilter: any;

@Input() floatLabel: FloatLabelType = 'never';

get activeFilters() {
this.updateField();
return this.datasource.options.ogcFilters.interfaceOgcFilters.filter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
</igo-ogc-filter-toggle-button>
</igo-list>

<igo-list *ngIf="advancedOgcFilters" [navigation]="false" [selection]="true">
<ng-template ngFor let-currentFilter [ngForOf]="this.datasource.options.ogcFilters.interfaceOgcFilters">
<igo-list *ngIf="advancedOgcFilters && datasource.options.ogcFilters.editable " [navigation]="false" [selection]="true">
<ng-template ngFor let-currentFilter [ngForOf]="datasource.options.ogcFilters.interfaceOgcFilters">
<igo-ogc-filter-form igoListItem [color]="color" [currentFilter]="currentFilter" [datasource]="datasource"
[map]="map" [refreshFilters]="refreshFunc">
</igo-ogc-filter-form>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<span *ngIf="filtersAreEditable">
<mat-list-item>

<mat-icon *ngIf="ogcFiltersHeaderShown" class="igo-chevron" mat-list-avatar igoCollapse [target]="ogcFilters" [collapsed]="filtersCollapsed" svgIcon="chevron-up">
Expand All @@ -12,24 +11,22 @@ <h4 *ngIf="!ogcFiltersHeaderShown" matLine></h4>
<mat-icon svgIcon="download"></mat-icon>
</button>
</span>
<button *ngIf="isAdvancedOgcFilters()" [disabled]="addFilterDisabled()" mat-icon-button tooltip-position="below" matTooltipShowDelay="500"
<button *ngIf="isAdvancedOgcFilters() && filtersAreEditable" [disabled]="addFilterDisabled()" mat-icon-button tooltip-position="below" matTooltipShowDelay="500"
[matTooltip]="'igo.geo.filter.addFilter' | translate" [color]="color" (click)="addFilterToSequence()">
<mat-icon svgIcon="plus"></mat-icon>
</button>
<button *ngIf="!layer.visible && ogcFiltersHeaderShown" mat-icon-button tooltip-position="below"
matTooltipShowDelay="500" [matTooltip]="'igo.geo.layer.showLayer' | translate" color="warn" (click)="setVisible()">
<mat-icon svgIcon="alert-circle-outline"></mat-icon>
</button>
</mat-list-item>

<button *ngIf="!layer.visible && ogcFiltersHeaderShown" mat-icon-button tooltip-position="below" matTooltipShowDelay="500" [matTooltip]="'igo.geo.layer.showLayer' | translate"
color="warn" (click)="setVisible()">
<mat-icon svgIcon="error-outline"></mat-icon>
</button>

<div #ogcFilters class="igo-datasource-filters-container">
<igo-ogc-filterable-form [datasource]="datasource" [map]="map" [refreshFilters]="refreshFunc">
</igo-ogc-filterable-form>

<mat-checkbox labelPosition='before' *ngIf="hasPushButton" (change)="changeOgcFilterType($event)"
<mat-checkbox labelPosition='before' *ngIf="hasPushButton && filtersAreEditable" (change)="changeOgcFilterType($event)"
[(ngModel)]="datasource.options.ogcFilters.advancedOgcFilters">
{{'igo.geo.filter.advancedOgcFilters' | translate}}
</mat-checkbox>
</div>
</span>
16 changes: 12 additions & 4 deletions packages/geo/src/lib/filter/shared/filterable-datasource.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,21 @@ export class FilterableDataSourcePipe implements PipeTransform {
return dataSource.options.timeFilterable;
}

private isOgcFilterable(dataSource: OgcFilterableDataSource) {
private isOgcFilterable(dataSource: OgcFilterableDataSource): boolean {
let isOgcFilterable = false;
if (
dataSource.options.ogcFilters &&
dataSource.options.ogcFilters.enabled
dataSource.options.ogcFilters.enabled &&
dataSource.options.ogcFilters.editable
) {
return true;
isOgcFilterable = true;
}
if (
dataSource.options.ogcFilters &&
dataSource.options.ogcFilters.enabled &&
dataSource.options.ogcFilters.pushButtons) {
isOgcFilterable = true;
}
return false;
return isOgcFilterable;
}
}
6 changes: 4 additions & 2 deletions packages/geo/src/locale/en.geo.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@
"layerFiltered": "This layer is currently filtered",
"layerFilterable": "This layer is filterable",
"filterBy": "Filter by",
"advancedOgcFilters": "Advanced filters"
"advancedOgcFilters": "Advanced filters",
"placeholder": "Enter a value",
"placeholderSnrc": "Ex: 21L14"
},
"spatialSelector": {
"fixedExtent": "Fixed extent",
"btnSetExtent": "Define the extent of the spatial filter to the current view",
"snrc": "SNRC (ex:21L14)",
"snrc": "SNRC",
"selectFeature": "",
"drawFeature": ""
},
Expand Down
6 changes: 4 additions & 2 deletions packages/geo/src/locale/fr.geo.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@
"layerFiltered": "Cette couche d'information est présentement filtrée.",
"layerFilterable": "Cette couche d'information est filtrable",
"filterBy": "Filtrer par",
"advancedOgcFilters": "Filtres avancés"
"advancedOgcFilters": "Filtres avancés",
"placeholder": "Saisir une valeur",
"placeholderSnrc": "Ex: 21L14"
},
"spatialSelector": {
"fixedExtent": "Étendue fixe",
"btnSetExtent": "Définir l'étendue du filtre selon l'étendue courante de la carte",
"snrc": "SNRC (ex:21L14)",
"snrc": "SNRC",
"selectFeature": "",
"drawFeature": ""
},
Expand Down

0 comments on commit 2c9ffa8

Please sign in to comment.