diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/dialogs/select-entity-dialog.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/maps/dialogs/select-entity-dialog.component.html
index a2169cc129..99740ac601 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/dialogs/select-entity-dialog.component.html
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/dialogs/select-entity-dialog.component.html
@@ -31,7 +31,7 @@
entity.entity
- {{ entity.entityName }}
+ {{ entity.entityParseName }}
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/dialogs/select-entity-dialog.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/dialogs/select-entity-dialog.component.ts
index 9822f6dca9..f2b3d09b5c 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/dialogs/select-entity-dialog.component.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/dialogs/select-entity-dialog.component.ts
@@ -20,7 +20,7 @@ import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { Router } from '@angular/router';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
-import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
+import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { FormattedData } from '@shared/models/widget.models';
export interface SelectEntityDialogData {
@@ -33,14 +33,13 @@ export interface SelectEntityDialogData {
styleUrls: ['./select-entity-dialog.component.scss']
})
export class SelectEntityDialogComponent extends DialogComponent {
-
- selectEntityFormGroup: UntypedFormGroup;
+ selectEntityFormGroup: FormGroup;
constructor(protected store: Store,
protected router: Router,
@Inject(MAT_DIALOG_DATA) public data: SelectEntityDialogData,
public dialogRef: MatDialogRef,
- public fb: UntypedFormBuilder) {
+ public fb: FormBuilder) {
super(store, router, dialogRef);
this.selectEntityFormGroup = this.fb.group(
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts
index a78dd27431..7b63176203 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts
@@ -36,7 +36,7 @@ import { Observable, of } from 'rxjs';
import { Polyline } from './polyline';
import { Polygon } from './polygon';
import { Circle } from './circle';
-import { createTooltip, isCutPolygon, isJSON } from '@home/components/widget/lib/maps/maps-utils';
+import { createTooltip, entitiesParseName, isCutPolygon, isJSON } from '@home/components/widget/lib/maps/maps-utils';
import { checkLngLat, createLoadingDiv } from '@home/components/widget/lib/maps/common-maps-utils';
import { WidgetContext } from '@home/models/widget-component.models';
import {
@@ -182,20 +182,40 @@ export default abstract class LeafletMap {
private selectEntityWithoutLocationDialog(shapes: L.PM.SUPPORTED_SHAPES): Observable {
let entities;
+ let labelSettings;
switch (shapes) {
case 'Polygon':
case 'Rectangle':
entities = this.datasources.filter(pData => !this.isValidPolygonPosition(pData));
+ labelSettings = {
+ showLabel: this.options.showPolygonLabel,
+ useLabelFunction: this.options.usePolygonLabelFunction,
+ parsedLabelFunction: this.options.parsedPolygonLabelFunction,
+ label: this.options.polygonLabel
+ };
break;
case 'Marker':
entities = this.datasources.filter(mData => !this.extractPosition(mData));
+ labelSettings = {
+ showLabel: this.options.showLabel,
+ useLabelFunction: this.options.useLabelFunction,
+ parsedLabelFunction: this.options.parsedLabelFunction,
+ label: this.options.label
+ };
break;
case 'Circle':
entities = this.datasources.filter(mData => !this.isValidCircle(mData));
+ labelSettings = {
+ showLabel: this.options.showCircleLabel,
+ useLabelFunction: this.options.useCircleLabelFunction,
+ parsedLabelFunction: this.options.parsedCircleLabelFunction,
+ label: this.options.circleLabel
+ };
break;
default:
return of(null);
}
+ entities = entitiesParseName(entities, labelSettings);
if (entities.length === 1) {
return of(entities[0]);
}
@@ -219,38 +239,38 @@ export default abstract class LeafletMap {
let customTranslation;
switch (type) {
case 'tbMarker':
- tooltipText = this.translateService.instant('widgets.maps.tooltips.placeMarker', {entityName: data.entityName});
+ tooltipText = this.translateService.instant('widgets.maps.tooltips.placeMarker', {entityName: data.entityParseName});
// @ts-ignore
this.map.pm.Draw.tbMarker._hintMarker.setTooltipContent(tooltipText);
break;
case 'tbCircle':
- tooltipText = this.translateService.instant('widgets.maps.tooltips.startCircle', {entityName: data.entityName});
+ tooltipText = this.translateService.instant('widgets.maps.tooltips.startCircle', {entityName: data.entityParseName});
// @ts-ignore
this.map.pm.Draw.tbCircle._hintMarker.setTooltipContent(tooltipText);
customTranslation = {
tooltips: {
- finishCircle: this.translateService.instant('widgets.maps.tooltips.finishCircle', {entityName: data.entityName})
+ finishCircle: this.translateService.instant('widgets.maps.tooltips.finishCircle', {entityName: data.entityParseName})
}
};
break;
case 'tbRectangle':
- tooltipText = this.translateService.instant('widgets.maps.tooltips.firstVertex', {entityName: data.entityName});
+ tooltipText = this.translateService.instant('widgets.maps.tooltips.firstVertex', {entityName: data.entityParseName});
// @ts-ignore
this.map.pm.Draw.tbRectangle._hintMarker.setTooltipContent(tooltipText);
customTranslation = {
tooltips: {
- finishRect: this.translateService.instant('widgets.maps.tooltips.finishRect', {entityName: data.entityName})
+ finishRect: this.translateService.instant('widgets.maps.tooltips.finishRect', {entityName: data.entityParseName})
}
};
break;
case 'tbPolygon':
- tooltipText = this.translateService.instant('widgets.maps.tooltips.firstVertex', {entityName: data.entityName});
+ tooltipText = this.translateService.instant('widgets.maps.tooltips.firstVertex', {entityName: data.entityParseName});
// @ts-ignore
this.map.pm.Draw.tbPolygon._hintMarker.setTooltipContent(tooltipText);
customTranslation = {
tooltips: {
- continueLine: this.translateService.instant('widgets.maps.tooltips.continueLine', {entityName: data.entityName}),
- finishPoly: this.translateService.instant('widgets.maps.tooltips.finishPoly', {entityName: data.entityName})
+ continueLine: this.translateService.instant('widgets.maps.tooltips.continueLine', {entityName: data.entityParseName}),
+ finishPoly: this.translateService.instant('widgets.maps.tooltips.finishPoly', {entityName: data.entityParseName})
}
};
break;
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts
index 4b4de38712..4aad829eac 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts
@@ -16,9 +16,12 @@
import L from 'leaflet';
import {
+ GenericFunction,
ShowTooltipAction, WidgetToolipSettings
} from './map-models';
-import { Datasource } from '@app/shared/models/widget.models';
+import { Datasource, FormattedData } from '@app/shared/models/widget.models';
+import { fillDataPattern, processDataPattern, safeExecute } from '@core/utils';
+import { parseWithTranslation } from '@home/components/widget/lib/maps/common-maps-utils';
export function createTooltip(target: L.Layer,
settings: Partial,
@@ -83,3 +86,27 @@ export function isJSON(data: string): boolean {
return false;
}
}
+
+interface labelSettings {
+ showLabel: boolean;
+ useLabelFunction: boolean;
+ parsedLabelFunction: GenericFunction;
+ label: string;
+}
+
+export function entitiesParseName(entities: FormattedData[], labelSettings: labelSettings): FormattedData[] {
+ const div = document.createElement('div');
+ for (const entity of entities) {
+ if (labelSettings?.showLabel) {
+ const pattern = labelSettings.useLabelFunction ? safeExecute(labelSettings.parsedLabelFunction,
+ [entity, entities, entity.dsIndex]) : labelSettings.label;
+ const markerLabelText = parseWithTranslation.prepareProcessPattern(pattern, true);
+ const replaceInfoLabelMarker = processDataPattern(pattern, entity);
+ div.innerHTML = fillDataPattern(markerLabelText, replaceInfoLabelMarker, entity);
+ entity.entityParseName = div.textContent || div.innerText || '';
+ } else {
+ entity.entityParseName = entity.entityName;
+ }
+ }
+ return entities;
+}