Fix: fix broken delete button

This commit is contained in:
Pieter Vander Vennet 2025-03-18 02:53:12 +01:00
parent ad1470ecbc
commit b2a937f4d8
2 changed files with 8 additions and 5 deletions
src
Logic/Tags
UI/Popup/DeleteFlow

View file

@ -29,6 +29,9 @@ export class And extends TagsFilter {
and: ReadonlyArray<FlatTag | (Or & OptimizedTag)>
): TagsFilterClosed & OptimizedTag
public static construct(and: ReadonlyArray<TagsFilter>): TagsFilter {
if (and === undefined) {
return undefined
}
if (and.length === 1) {
return and[0]
}

View file

@ -11,7 +11,6 @@
import { UIEventSource } from "../../../Logic/UIEventSource"
import LayerConfig from "../../../Models/ThemeConfig/LayerConfig"
import { TagUtils } from "../../../Logic/Tags/TagUtils"
import type { UploadableTag } from "../../../Logic/Tags/TagUtils"
import OsmChangeAction from "../../../Logic/Osm/Actions/OsmChangeAction"
import DeleteAction from "../../../Logic/Osm/Actions/DeleteAction"
import ChangeTagAction from "../../../Logic/Osm/Actions/ChangeTagAction"
@ -22,6 +21,7 @@
import Trash from "@babeard/svelte-heroicons/mini/Trash"
import Invalid from "../../../assets/svg/Invalid.svelte"
import { And } from "../../../Logic/Tags/And"
import type { UploadableTag } from "../../../Logic/Tags/TagTypes"
export let state: SpecialVisualizationState
export let deleteConfig: DeleteConfig
@ -46,9 +46,9 @@
const t = Translations.t.delete
let selectedTags: UploadableTag
let selectedTags: UploadableTag[]
let changedProperties = undefined
$: changedProperties = TagUtils.changeAsProperties(selectedTags?.asChange(tags?.data ?? {}) ?? [])
$: changedProperties = TagUtils.changeAsProperties(And.construct(selectedTags)?.asChange(tags?.data ?? {}) ?? [])
let isHardDelete = undefined
$: isHardDelete = changedProperties[DeleteConfig.deleteReasonKey] !== undefined
@ -58,7 +58,7 @@
}
currentState = "applying"
let actionToTake: OsmChangeAction
const changedProperties = TagUtils.changeAsProperties(selectedTags.asChange(tags?.data ?? {}))
const changedProperties = TagUtils.changeAsProperties(And.construct(selectedTags)?.asChange(tags?.data ?? {}))
const deleteReason = changedProperties[DeleteConfig.deleteReasonKey]
if (deleteReason) {
let softDeletionTags: UploadableTag
@ -81,7 +81,7 @@
)
} else {
// no _delete_reason is given, which implies that this is _not_ a deletion but merely a retagging via a nonDeleteMapping
actionToTake = new ChangeTagAction(featureId, selectedTags, tags.data, {
actionToTake = new ChangeTagAction(featureId, new And(selectedTags), tags.data, {
theme: state?.theme?.id ?? "unkown",
changeType: "special-delete",
})