Fix: fix icons in mappings which use a builtin svg

This commit is contained in:
Pieter Vander Vennet 2023-05-09 00:05:38 +02:00
parent beb86919a8
commit ab28fbe35c
2 changed files with 33 additions and 31 deletions

View file

@ -11,7 +11,6 @@ import { FixedUiElement } from "../../UI/Base/FixedUiElement"
import Img from "../../UI/Base/Img"
import Combine from "../../UI/Base/Combine"
import {VariableUiElement} from "../../UI/Base/VariableUIElement"
import Constants from "../Constants";
export default class PointRenderingConfig extends WithContextLoader {
static readonly allowed_location_codes: ReadonlySet<string> = new Set<string>([
@ -110,7 +109,7 @@ export default class PointRenderingConfig extends WithContextLoader {
return undefined
}
const match = htmlSpec.match(/([a-zA-Z0-9_]*):([^;]*)/)
if (match !== null && Constants.defaultPinIcons.indexOf(match[1] ) >= 0) {
if (match !== null && Svg.All[match[1] + ".svg"] !== undefined) {
const svg = Svg.All[match[1] + ".svg"] as string
const targetColor = match[2]
const img = new Img(

View file

@ -15,7 +15,6 @@ import {FixedUiElement} from "../../UI/Base/FixedUiElement"
import {Paragraph} from "../../UI/Base/Paragraph"
import Svg from "../../Svg"
import Validators, {ValidatorType} from "../../UI/InputElement/Validators";
import Constants from "../Constants";
export interface Mapping {
readonly if: UploadableTag
@ -69,6 +68,7 @@ export default class TagRenderingConfig {
public readonly mappings?: Mapping[]
public readonly labels: string[]
public readonly classes: string[]
constructor(json: string | QuestionableTagRenderingConfigJson, context?: string) {
if (json === undefined) {
throw "Initing a TagRenderingConfig with undefined in " + context
@ -379,9 +379,7 @@ export default class TagRenderingConfig {
if (stripped.endsWith(".svg")) {
stripped = stripped.substring(0, stripped.length - 4)
}
if (
Constants.defaultPinIcons.indexOf(stripped)
) {
if (Svg.All[stripped + ".svg"] !== undefined) {
icon = "./assets/svg/" + mapping.icon
if (!icon.endsWith(".svg")) {
icon += ".svg"
@ -706,7 +704,12 @@ export default class TagRenderingConfig {
...(this.mappings[singleSelectedMapping].addExtraTags ?? []),
])
} else {
console.warn("TagRenderingConfig.ConstructSpecification has a weird fallback for", {freeformValue, singleSelectedMapping, multiSelectedMapping, currentProperties})
console.warn("TagRenderingConfig.ConstructSpecification has a weird fallback for", {
freeformValue,
singleSelectedMapping,
multiSelectedMapping,
currentProperties
})
return undefined
}
}