UX: add unlink button, simplify unlink code

This commit is contained in:
Pieter Vander Vennet 2025-06-07 02:52:06 +02:00
parent 45c0f1a8d6
commit 1192434b45
13 changed files with 117 additions and 69 deletions

View file

@ -16,9 +16,7 @@
import SubtleButton from "../../Base/SubtleButton.svelte"
import TagRenderingMappingInput from "./TagRenderingMappingInput.svelte"
import { Translation } from "../../i18n/Translation"
import Constants from "../../../Models/Constants"
import { Unit } from "../../../Models/Unit"
import UserRelatedState from "../../../Logic/State/UserRelatedState"
import { twJoin } from "tailwind-merge"
import { TagUtils } from "../../../Logic/Tags/TagUtils"
@ -31,8 +29,8 @@
import { get } from "svelte/store"
import Markdown from "../../Base/Markdown.svelte"
import { Utils } from "../../../Utils"
import { TagTypes } from "../../../Logic/Tags/TagTypes"
import type { UploadableTag } from "../../../Logic/Tags/TagTypes"
import { TagTypes } from "../../../Logic/Tags/TagTypes"
import Popup from "../../Base/Popup.svelte"
import If from "../../Base/If.svelte"
@ -315,8 +313,7 @@
let featureSwitchIsTesting = state?.featureSwitchIsTesting ?? new ImmutableStore(false)
let featureSwitchIsDebugging =
state?.featureSwitches?.featureSwitchIsDebugging ?? new ImmutableStore(false)
let showTags = state?.userRelatedState?.showTags ?? new ImmutableStore(undefined)
let numberOfCs = state?.osmConnection?.userDetails?.data?.csCount ?? 0
let showTags : Store<boolean> = state?.userRelatedState?.showTagsB ?? new ImmutableStore(false)
let question = config.question
let hideMappingsUnlessSearchedFor =
config.mappings.length > 8 && config.mappings.some((m) => m.priorityIf !== undefined)
@ -324,14 +321,6 @@
$: hideMappingsUnlessSearchedFor =
config.mappings.length > 8 && config.mappings.some((m) => m.priorityIf !== undefined)
if (state?.osmConnection) {
onDestroy(
state.osmConnection?.userDetails?.addCallbackAndRun((ud) => {
numberOfCs = ud?.csCount
})
)
}
function clearAnswer() {
const tagsToSet: UploadableTag[] = onMarkUnknown.data
const change = new ChangeTagAction(tags.data.id, new And(tagsToSet), tags.data, {
@ -577,9 +566,7 @@
</h2>
<Tr t={Translations.t.unknown.explanation} />
<If
condition={state.userRelatedState?.showTags?.map(
(v) => v === "yes" || v === "full" || v === "always"
)}
condition={state.userRelatedState?.showTagsB}
>
<div class="subtle">
<Tr t={Translations.t.unknown.removedKeys} />
@ -639,7 +626,7 @@
</div>
</div>
<!-- Taghint + debug info -->
{#if UserRelatedState.SHOW_TAGS_VALUES.indexOf($showTags) >= 0 || ($showTags === "" && numberOfCs >= Constants.userJourney.tagsVisibleAt) || $featureSwitchIsTesting || $featureSwitchIsDebugging}
{#if $showTags || $featureSwitchIsTesting || $featureSwitchIsDebugging}
<span class="flex flex-wrap justify-between">
<TagHint tags={selectedTags} currentProperties={$tags} />
<span class="flex flex-wrap">