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 { Feature } from "geojson"
|
||||||
import MarkdownUtils from "../../Utils/MarkdownUtils"
|
import MarkdownUtils from "../../Utils/MarkdownUtils"
|
||||||
import { UploadableTag } from "../../Logic/Tags/TagTypes"
|
import { UploadableTag } from "../../Logic/Tags/TagTypes"
|
||||||
|
import LayerConfig from "./LayerConfig"
|
||||||
|
|
||||||
export interface Mapping {
|
export interface Mapping {
|
||||||
readonly if: UploadableTag
|
readonly if: UploadableTag
|
||||||
|
@ -924,7 +925,7 @@ export default class TagRenderingConfig {
|
||||||
* The keys that should be erased if one has to revert to 'unknown'.
|
* The keys that should be erased if one has to revert to 'unknown'.
|
||||||
* Might give undefined if setting to unknown is not possible
|
* 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>()
|
const toDelete = new Set<string>()
|
||||||
if (this.freeform) {
|
if (this.freeform) {
|
||||||
toDelete.add(this.freeform.key)
|
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)
|
return Array.from(toDelete)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@
|
||||||
/**
|
/**
|
||||||
* IF set: we can remove the current answer by deleting all those keys
|
* 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 unknownModal = new UIEventSource(false)
|
||||||
|
|
||||||
let searchTerm: UIEventSource<string> = new UIEventSource("")
|
let searchTerm: UIEventSource<string> = new UIEventSource("")
|
||||||
|
@ -325,7 +325,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearAnswer() {
|
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, {
|
const change = new ChangeTagAction(tags.data.id, new And(tagsToSet), tags.data, {
|
||||||
theme: tags.data["_orig_theme"] ?? state.layout.id,
|
theme: tags.data["_orig_theme"] ?? state.layout.id,
|
||||||
changeType: "answer",
|
changeType: "answer",
|
||||||
|
@ -526,7 +526,7 @@
|
||||||
<If condition={state.userRelatedState.showTags.map(v => v === "yes" || v === "full" || v === "always")}>
|
<If condition={state.userRelatedState.showTags.map(v => v === "yes" || v === "full" || v === "always")}>
|
||||||
<div class="subtle">
|
<div class="subtle">
|
||||||
<Tr t={Translations.t.unknown.removedKeys}/>
|
<Tr t={Translations.t.unknown.removedKeys}/>
|
||||||
{#each settableKeys as key}
|
{#each $settableKeys as key}
|
||||||
<code>
|
<code>
|
||||||
<del>
|
<del>
|
||||||
{key}
|
{key}
|
||||||
|
@ -550,7 +550,7 @@
|
||||||
style="z-index: 11"
|
style="z-index: 11"
|
||||||
>
|
>
|
||||||
|
|
||||||
{#if settableKeys && $isKnown && !matchesEmpty }
|
{#if $settableKeys && $isKnown && !matchesEmpty }
|
||||||
<button class="as-link small text-sm" on:click={() => unknownModal.set(true)}>
|
<button class="as-link small text-sm" on:click={() => unknownModal.set(true)}>
|
||||||
<Tr t={Translations.t.unknown.markUnknown} />
|
<Tr t={Translations.t.unknown.markUnknown} />
|
||||||
</button>
|
</button>
|
||||||
|
|
Loading…
Reference in a new issue