Themes: don't show 'mark as unknown' if this would break the source-filter
This commit is contained in:
parent
6a9b985070
commit
76a9a2ee23
2 changed files with 16 additions and 5 deletions
|
@ -18,6 +18,7 @@ import { GeoOperations } from "../../Logic/GeoOperations"
|
|||
import { Feature } from "geojson"
|
||||
import MarkdownUtils from "../../Utils/MarkdownUtils"
|
||||
import { UploadableTag } from "../../Logic/Tags/TagTypes"
|
||||
import LayerConfig from "./LayerConfig"
|
||||
|
||||
export interface Mapping {
|
||||
readonly if: UploadableTag
|
||||
|
@ -924,7 +925,7 @@ export default class TagRenderingConfig {
|
|||
* The keys that should be erased if one has to revert to 'unknown'.
|
||||
* Might give undefined if setting to unknown is not possible
|
||||
*/
|
||||
public removeToSetUnknown(): string[] | undefined {
|
||||
public removeToSetUnknown(partOfLayer: LayerConfig, currentTags: Record<string, string>): string[] | undefined {
|
||||
const toDelete = new Set<string>()
|
||||
if (this.freeform) {
|
||||
toDelete.add(this.freeform.key)
|
||||
|
@ -949,6 +950,16 @@ export default class TagRenderingConfig {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
currentTags = { ...currentTags }
|
||||
for (const key of toDelete) {
|
||||
delete currentTags[key]
|
||||
}
|
||||
const required = partOfLayer.source.osmTags
|
||||
if (!required.matchesProperties(currentTags)) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return Array.from(toDelete)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
/**
|
||||
* IF set: we can remove the current answer by deleting all those keys
|
||||
*/
|
||||
let settableKeys = config.removeToSetUnknown()
|
||||
let settableKeys = tags.mapD(tags => config.removeToSetUnknown(layer, tags))
|
||||
let unknownModal = new UIEventSource(false)
|
||||
|
||||
let searchTerm: UIEventSource<string> = new UIEventSource("")
|
||||
|
@ -325,7 +325,7 @@
|
|||
}
|
||||
|
||||
function clearAnswer() {
|
||||
const tagsToSet = settableKeys.map(k => new Tag(k, ""))
|
||||
const tagsToSet = settableKeys.data.map(k => new Tag(k, ""))
|
||||
const change = new ChangeTagAction(tags.data.id, new And(tagsToSet), tags.data, {
|
||||
theme: tags.data["_orig_theme"] ?? state.layout.id,
|
||||
changeType: "answer",
|
||||
|
@ -526,7 +526,7 @@
|
|||
<If condition={state.userRelatedState.showTags.map(v => v === "yes" || v === "full" || v === "always")}>
|
||||
<div class="subtle">
|
||||
<Tr t={Translations.t.unknown.removedKeys}/>
|
||||
{#each settableKeys as key}
|
||||
{#each $settableKeys as key}
|
||||
<code>
|
||||
<del>
|
||||
{key}
|
||||
|
@ -550,7 +550,7 @@
|
|||
style="z-index: 11"
|
||||
>
|
||||
|
||||
{#if settableKeys && $isKnown && !matchesEmpty }
|
||||
{#if $settableKeys && $isKnown && !matchesEmpty }
|
||||
<button class="as-link small text-sm" on:click={() => unknownModal.set(true)}>
|
||||
<Tr t={Translations.t.unknown.markUnknown} />
|
||||
</button>
|
||||
|
|
Loading…
Reference in a new issue