forked from MapComplete/MapComplete
Clear tags from old presets
This commit is contained in:
parent
572d85a6b5
commit
8332650ea3
2 changed files with 16 additions and 1 deletions
|
@ -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>
|
||||
|
|
|
@ -188,7 +188,6 @@
|
|||
}
|
||||
|
||||
function onSave(_ = undefined) {
|
||||
console.log("Extra tags to save", extraTags.data)
|
||||
if (selectedTags === undefined) {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue