Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstract on layer in catalog #725

Merged
merged 1 commit into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<mat-list-item>
<mat-icon *ngIf="haveGroup()" mat-list-avatar svgIcon="blank"></mat-icon>
<h4 mat-line matTooltipShowDelay="500" [ngClass]="(catalogAllowLegend)?'igo-cataloglayer-title':''" (click)="askForLegend($event)" [matTooltip]="title">{{title}}</h4>
<h4 mat-line matTooltipShowDelay="500" [ngClass]="(catalogAllowLegend)?'igo-cataloglayer-title':''" (click)="askForLegend($event)" [matTooltip]="computeTitleTooltip()">{{title}}</h4>

<igo-metadata-button [layer]="layer"></igo-metadata-button>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { CatalogItemLayer } from '../shared';
import { BehaviorSubject } from 'rxjs';
import { LayerService } from '../../layer/shared/layer.service';
import { first } from 'rxjs/operators';
import { Layer } from '../../layer/shared/layers';
import { Layer, TooltipType } from '../../layer/shared/layers';
import { MetadataLayerOptions } from '../../metadata/shared/metadata.interface';

/**
* Catalog browser layer item
Expand Down Expand Up @@ -78,6 +79,33 @@ export class CatalogBrowserLayerComponent implements OnInit {
this.isPreview$.subscribe(value => this.addedLayerIsPreview.emit(value));
}

computeTitleTooltip(): string {
const layerOptions = this.layer.options;
if (!layerOptions.tooltip) {
return getEntityTitle(this.layer);
}
const layerTooltip = layerOptions.tooltip;
const layerMetadata = (layerOptions as MetadataLayerOptions).metadata;
switch (layerOptions.tooltip.type) {
case TooltipType.TITLE:
return this.layer.title;
case TooltipType.ABSTRACT:
if (layerMetadata && layerMetadata.abstract) {
return layerMetadata.abstract;
} else {
return this.layer.title;
}
case TooltipType.CUSTOM:
if (layerTooltip && layerTooltip.text) {
return layerTooltip.text;
} else {
return this.layer.title;
}
default:
return this.layer.title;
}
}

/**
* On mouse event, mouseenter /mouseleave
* @internal
Expand Down
3 changes: 2 additions & 1 deletion packages/geo/src/lib/catalog/shared/catalog.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ export class CatalogService {
minResolution: getResolutionFromScale(layer.MinScaleDenominator),
metadata: {
url: metadata ? metadata.OnlineResource : undefined,
extern: metadata ? true : undefined
extern: metadata ? true : undefined,
abstract: layer.Abstract
},
legendOptions,
tooltip: { type: catalog.tooltipType },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class LayerLegendComponent implements OnInit, OnDestroy {
if (layerOptions && layerOptions.legendOptions) {
const translate = this.languageService.translate;
const title = translate.instant('igo.geo.layer.legend.default');
let stylesAvailable = [{ name: '', title } as ItemStyleOptions];
const stylesAvailable = [{ name: '', title } as ItemStyleOptions];
if (layerOptions.legendOptions.stylesAvailable) {
stylesAvailable.concat(layerOptions.legendOptions.stylesAvailable.filter(sA => (
sA.name.normalize('NFD').replace(/[\u0300-\u036f]/gi, '') !== 'default' &&
Expand Down