Skip to content
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
11 changes: 11 additions & 0 deletions map-view/src/common/MapUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Fill, Icon, Stroke, Style, Circle as CircleStyle } from "ol/style";
import { FeatureLike } from "ol/Feature";
import RenderFeature from "ol/render/Feature";
import { Coordinate } from "ol/coordinate";
import { Feature, LayerConfig } from "../models";

const defaultFill = new Fill({ color: "magenta" });
const defaultStroke = new Stroke({
Expand Down Expand Up @@ -141,3 +142,13 @@ export function isCoordinateInsideFeature(coordinate: Coordinate, geometry: Geom
return false;
}
}

export function getFeatureAppName(feature: Feature, overlayConfig: LayerConfig) {
const name_from_feat = feature["app_name"];
if (name_from_feat) {
return name_from_feat;
}
const featureType: string = feature["id_"].split(".")[0];
const feature_layer = overlayConfig["layers"].find((l) => l.identifier === featureType);
return feature_layer ? feature_layer["app_name"] : "traffic_control";
}
3 changes: 2 additions & 1 deletion map-view/src/components/FeatureInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import React from "react";
import { APIBaseUrl } from "../consts";
import { Feature, MapConfig } from "../models";
import { withTranslation, WithTranslation } from "react-i18next";
import { getFeatureAppName } from "../common/MapUtils";

const styles = (theme: Theme) =>
createStyles({
Expand Down Expand Up @@ -75,7 +76,7 @@ class FeatureInfo extends React.Component<FeatureInfoProps, FeatureInfoState> {
}

getAdminLink(feature: Feature, featureTypeEditMapping: Record<string, string>) {
const app_name = feature["app_name"];
const app_name = getFeatureAppName(feature, this.props.mapConfig.overlayConfig);
const featureTypeEditName = this.getFeatureTypeEditName(this.getFeatureType(feature), featureTypeEditMapping);
const featureId = feature.getProperties().id;
return `${APIBaseUrl}/admin/${app_name}/${featureTypeEditName.replace(/_/g, "")}/${featureId}/change`;
Expand Down
Loading