Fix: fix postfixdistinguished-charge input

This commit is contained in:
Pieter Vander Vennet 2025-03-13 21:42:38 +01:00
parent c6d1ee64d8
commit 70ad2431d0
2 changed files with 10 additions and 5 deletions
src
Models/ThemeConfig
UI/Popup/TagRendering

View file

@ -746,12 +746,14 @@ export default class TagRenderingConfig {
if (freeformValue === "") {
freeformValue = undefined
}
if (this.freeform?.postfixDistinguished) {
const allValues = currentProperties[this.freeform.key].split(";").map((s) => s.trim())
const pf = this.freeform?.postfixDistinguished
if (pf) {
const v = currentProperties[this.freeform.key] ?? ""
const allValues = v.split(";").map((s) => s.trim())
const perPostfix: Record<string, string> = {}
for (const value of allValues) {
const [v, postfix] = value.split("/")
perPostfix[postfix.trim()] = v.trim()
const [v, postfix] = value.split("/").map(s => s.trim())
perPostfix[postfix ?? pf] = v.trim()
}
if (freeformValue === "" || freeformValue === undefined) {
delete perPostfix[this.freeform.postfixDistinguished]
@ -1042,7 +1044,8 @@ export default class TagRenderingConfig {
*/
public markUnknown(layer: LayerConfig, currentProperties: Record<string, string>): UploadableTag[] {
if (this.freeform?.postfixDistinguished) {
const allValues = currentProperties[this.freeform.key].split(";").filter(
const v = currentProperties[this.freeform.key] ?? ""
const allValues = v.split(";").filter(
part => part.split("/")[1]?.trim() !== this.freeform.postfixDistinguished
)
return [new Tag(this.freeform.key, allValues.join(";"))]

View file

@ -252,6 +252,8 @@
} else if (selectedTags instanceof And) {
// Add the extraTags to the existing And
selectedTags = [...TagTypes.uploadableAnd(selectedTags), ...extraTagsArray]
} else if (Array.isArray(selectedTags)) {
// pass
} else {
console.error(
"selectedTags is not of type Tag or And, it is a " + JSON.stringify(selectedTags)