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

View file

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

View file

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