Skip to content

Commit

Permalink
feat(layer): queryable layers can optionnally have a have indicating …
Browse files Browse the repository at this point in the history
…that they are queryable
  • Loading branch information
cbourget committed May 2, 2019
1 parent 0b65283 commit 41930f0
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ export class CapabilitiesService {
const metadata = layer.DataURL ? layer.DataURL[0] : undefined;
const abstract = layer.Abstract ? layer.Abstract : undefined;
const keywordList = layer.KeywordList ? layer.KeywordList : undefined;
const queryable = layer.queryable;
const timeFilter = this.getTimeFilter(layer);
const timeFilterable =
timeFilter && Object.keys(timeFilter).length > 0 ? true : false;
const timeFilterable = timeFilter && Object.keys(timeFilter).length > 0;

const options: WMSDataSourceOptions = ObjectUtils.removeUndefined({
_layerOptionsFromCapabilities: {
Expand All @@ -176,6 +176,7 @@ export class CapabilitiesService {
keywordList
}
},
queryable,
timeFilter: timeFilterable ? timeFilter : undefined,
timeFilterable: timeFilterable ? true : undefined
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ <h4 matLine [matTooltip]="tooltipText" matTooltipShowDelay="500">{{layer.title}}
('igo.geo.layer.showLayer' | translate)"
(click)="toggleVisibility()">
<mat-icon
matBadge="?"
matBadgeColor="accent"
matBadgeSize="small"
matBadgePosition="after"
[matBadgeHidden]="queryBadgeHidden$ | async"
[ngClass]="{disabled: !(inResolutionRange$ | async)}">
<ng-container *ngIf="layer.visible">
visibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@
mat-icon.disabled {
color: rgba(0, 0, 0, 0.38);
}

.mat-badge-small .mat-badge-content {
font-size: 12px;
}
20 changes: 19 additions & 1 deletion packages/geo/src/lib/layer/layer-item/layer-item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ import {
} from '@angular/core';
import { Subscription, BehaviorSubject } from 'rxjs';

<<<<<<< Updated upstream
import { Layer, TooltipType } from '../shared/layers';
import { MetadataLayerOptions } from '../../metadata/shared/metadata.interface';
=======
import { QueryableDataSourceOptions } from '../../query/shared/query.interfaces';
import { Layer } from '../shared/layers';
>>>>>>> Stashed changes

@Component({
selector: 'igo-layer-item',
Expand All @@ -23,6 +28,8 @@ export class LayerItemComponent implements OnInit, OnDestroy {

inResolutionRange$: BehaviorSubject<boolean> = new BehaviorSubject(true);

queryBadgeHidden$: BehaviorSubject<boolean> = new BehaviorSubject(true);

private resolution$$: Subscription;

@Input() layer: Layer;
Expand All @@ -33,6 +40,8 @@ export class LayerItemComponent implements OnInit, OnDestroy {

@Input() orderable: boolean = true;

@Input() queryBadge: boolean = false;

get removable(): boolean { return this.layer.options.removable !== false; }

get opacity() { return this.layer.opacity * 100; }
Expand All @@ -47,7 +56,8 @@ export class LayerItemComponent implements OnInit, OnDestroy {
if (this.layer.visible && this.expandLegendIfVisible) {
legendCollapsed = false;
}
this.showLegend$.next(!legendCollapsed);
this.toggleLegend(legendCollapsed);
this.updateQueryBadge();

const resolution$ = this.layer.map.viewController.resolution$;
this.resolution$$ = resolution$.subscribe((resolution: number) => {
Expand All @@ -69,6 +79,7 @@ export class LayerItemComponent implements OnInit, OnDestroy {
if (this.toggleLegendOnVisibilityChange) {
this.toggleLegend(!this.layer.visible);
}
this.updateQueryBadge();
}

computeTooltip(): string {
Expand Down Expand Up @@ -101,4 +112,11 @@ export class LayerItemComponent implements OnInit, OnDestroy {
private onResolutionChange(resolution: number) {
this.inResolutionRange$.next(this.layer.isInResolutionsRange);
}

private updateQueryBadge() {
const hidden = this.queryBadge === false ||
this.layer.visible === false ||
(this.layer.dataSource.options as QueryableDataSourceOptions).queryable !== true;
this.queryBadgeHidden$.next(hidden);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class LayerListBindingDirective implements OnInit, AfterViewInit, OnDestr
.getMap()
.layers$.subscribe((layers: Layer[]) => {
this.component.layers = layers.filter((layer: Layer) => {
return layer.options.showInLayerList !== false;
return layer.showInLayerList === true;
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
igoListItem
[layer]="layer"
[orderable]="orderable"
[queryBadge]="queryBadge"
[expandLegendIfVisible]="expandLegendOfVisibleLayers"
[toggleLegendOnVisibilityChange]="toggleLegendOnVisibilityChange">

Expand Down
2 changes: 2 additions & 0 deletions packages/geo/src/lib/layer/layer-list/layer-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export class LayerListComponent implements OnInit, OnDestroy {

@Input() expandLegendOfVisibleLayers: boolean = false;

@Input() queryBadge: boolean = false;

get keyword(): string { return this.layerListService.keyword; }
set keyword(value: string) {
this.layerListService.keyword = value;
Expand Down
4 changes: 3 additions & 1 deletion packages/geo/src/lib/layer/layer.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
MatButtonModule,
MatTooltipModule,
MatListModule,
MatSliderModule
MatSliderModule,
MatBadgeModule
} from '@angular/material';

import { IgoLanguageModule } from '@igo2/core';
Expand Down Expand Up @@ -37,6 +38,7 @@ import { LayerListBindingDirective } from './layer-list/layer-list-binding.direc
MatTooltipModule,
MatListModule,
MatSliderModule,
MatBadgeModule,
IgoLanguageModule,
IgoListModule,
IgoCollapsibleModule,
Expand Down
2 changes: 2 additions & 0 deletions packages/geo/src/lib/layer/shared/layers/layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ export abstract class Layer {
return resolution >= minResolution && resolution <= maxResolution;
}

get showInLayerList(): boolean { return this.options.showInLayerList !== false; }

constructor(options: LayerOptions) {
this.options = options;
this.dataSource = this.options.source;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ export interface VectorLayerOptions extends LayerOptions {
| ArcGISRestDataSourceOptions;
style?: { [key: string]: any } | olStyle | olStyle[];
browsable?: boolean;
exportable?: boolean;
ol?: olLayerVector;
}
4 changes: 4 additions & 0 deletions packages/geo/src/lib/layer/shared/layers/vector-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export class VectorLayer extends Layer {
public options: VectorLayerOptions;
public ol: olLayerVector;

get browsable(): boolean { return this.options.browsable !== false; }

get exportable(): boolean { return this.options.exportable !== false; }

constructor(options: VectorLayerOptions) {
super(options);
}
Expand Down

0 comments on commit 41930f0

Please sign in to comment.