Clear tags from old presets

This commit is contained in:
Robin van der Linde 2024-04-29 00:54:32 +02:00
parent 572d85a6b5
commit 8332650ea3
Signed by untrusted user: Robin-van-der-Linde
GPG key ID: 53956B3252478F0D
2 changed files with 16 additions and 1 deletions

View file

@ -117,6 +117,22 @@
}
return acc
}, {} as Record<string, string>)
// Also check if the object currently matches a different item, based on the key
const otherItem = items.find((item) => item.tags[tag] === feature.properties[key])
// If the other item is not the same as the selected item, we need to make sure we clear any old keys we don't need anymore by setting them to an empty string
if (otherItem && otherItem !== item) {
Object.keys(otherItem.tags).forEach((key) => {
// If we have a different value for the key, we don't need to clear it
if (!tags[key] && key !== tag && key !== maintag.split("=")[0]) {
console.log(`Clearing key ${key}`)
tags[key] = ""
}
})
}
// Finally, set the extra tags
extraTags.setData(tags)
}
</script>

View file

@ -188,7 +188,6 @@
}
function onSave(_ = undefined) {
console.log("Extra tags to save", extraTags.data)
if (selectedTags === undefined) {
return
}