Feat(filters): show tags that are filtered on, deal with multi-answer tags to allow having this option with auto-filters
This commit is contained in:
parent
d77bb7e225
commit
69a6ec6b02
2 changed files with 20 additions and 3 deletions
|
@ -33,6 +33,8 @@ import LineRenderingConfigJson from "../Json/LineRenderingConfigJson"
|
||||||
import { ConversionContext } from "./ConversionContext"
|
import { ConversionContext } from "./ConversionContext"
|
||||||
import { ExpandRewrite } from "./ExpandRewrite"
|
import { ExpandRewrite } from "./ExpandRewrite"
|
||||||
import { TagUtils } from "../../../Logic/Tags/TagUtils"
|
import { TagUtils } from "../../../Logic/Tags/TagUtils"
|
||||||
|
import { Tag } from "../../../Logic/Tags/Tag"
|
||||||
|
import { RegexTag } from "../../../Logic/Tags/RegexTag"
|
||||||
|
|
||||||
class AddFiltersFromTagRenderings extends DesugaringStep<LayerConfigJson> {
|
class AddFiltersFromTagRenderings extends DesugaringStep<LayerConfigJson> {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -138,16 +140,22 @@ class ExpandFilter extends DesugaringStep<LayerConfigJson> {
|
||||||
"Found a matching tagRendering to base a filter on, but this tagRendering does not contain any mappings"
|
"Found a matching tagRendering to base a filter on, but this tagRendering does not contain any mappings"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const options = (<QuestionableTagRenderingConfigJson>tr).mappings.map((mapping) => {
|
const qtr = (<QuestionableTagRenderingConfigJson>tr)
|
||||||
|
const options = qtr.mappings.map((mapping) => {
|
||||||
let icon: string = mapping.icon?.["path"] ?? mapping.icon
|
let icon: string = mapping.icon?.["path"] ?? mapping.icon
|
||||||
let emoji: string = undefined
|
let emoji: string = undefined
|
||||||
if (Utils.isEmoji(icon)) {
|
if (Utils.isEmoji(icon)) {
|
||||||
emoji = icon
|
emoji = icon
|
||||||
icon = undefined
|
icon = undefined
|
||||||
}
|
}
|
||||||
|
let osmTags = TagUtils.Tag( mapping.if)
|
||||||
|
if(qtr.multiAnswer && osmTags instanceof Tag){
|
||||||
|
osmTags = new RegexTag(osmTags.key, new RegExp("^(.+;)?"+osmTags.value+"(;.+)$","is"))
|
||||||
|
}
|
||||||
|
|
||||||
return <FilterConfigOptionJson>{
|
return <FilterConfigOptionJson>{
|
||||||
question: mapping.then,
|
question: mapping.then,
|
||||||
osmTags: mapping.if,
|
osmTags: osmTags.asJson(),
|
||||||
searchTerms: mapping.searchTerms,
|
searchTerms: mapping.searchTerms,
|
||||||
icon,
|
icon,
|
||||||
emoji,
|
emoji,
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
import Tr from "../Base/Tr.svelte"
|
import Tr from "../Base/Tr.svelte"
|
||||||
import Translations from "../i18n/Translations"
|
import Translations from "../i18n/Translations"
|
||||||
import type { SpecialVisualizationState } from "../SpecialVisualization"
|
import type { SpecialVisualizationState } from "../SpecialVisualization"
|
||||||
|
import Constants from "../../Models/Constants"
|
||||||
|
|
||||||
export let state: SpecialVisualizationState
|
export let state: SpecialVisualizationState
|
||||||
export let filteredLayer: FilteredLayer
|
export let filteredLayer: FilteredLayer
|
||||||
|
@ -22,6 +23,7 @@
|
||||||
let isDisplayed: UIEventSource<boolean> = filteredLayer.isDisplayed
|
let isDisplayed: UIEventSource<boolean> = filteredLayer.isDisplayed
|
||||||
|
|
||||||
let isDebugging = state?.featureSwitches?.featureSwitchIsDebugging ?? new ImmutableStore(false)
|
let isDebugging = state?.featureSwitches?.featureSwitchIsDebugging ?? new ImmutableStore(false)
|
||||||
|
let showTags = state?.userRelatedState?.showTags?.map(s => (s === "yes" && state?.userRelatedState?.osmConnection?.userDetails?.data?.csCount >= Constants.userJourney.tagsVisibleAt) || s === "always" || s === "full")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a UIEventSource as boolean for the given option, to be used with a checkbox
|
* Gets a UIEventSource as boolean for the given option, to be used with a checkbox
|
||||||
|
@ -31,7 +33,7 @@
|
||||||
return state.sync(
|
return state.sync(
|
||||||
(f) => f === 0,
|
(f) => f === 0,
|
||||||
[],
|
[],
|
||||||
(b) => (b ? 0 : undefined)
|
(b) => (b ? 0 : undefined),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +69,10 @@
|
||||||
{#if filter.options.length === 1 && filter.options[0].fields.length === 0}
|
{#if filter.options.length === 1 && filter.options[0].fields.length === 0}
|
||||||
<Checkbox selected={getBooleanStateFor(filter)}>
|
<Checkbox selected={getBooleanStateFor(filter)}>
|
||||||
<Tr t={filter.options[0].question} />
|
<Tr t={filter.options[0].question} />
|
||||||
|
<span class="subtle">
|
||||||
|
{filter.options[0].osmTags.asHumanString()}
|
||||||
|
</span>
|
||||||
|
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
@ -82,6 +88,9 @@
|
||||||
{option.emoji}
|
{option.emoji}
|
||||||
{/if}
|
{/if}
|
||||||
<Tr t={option.question} />
|
<Tr t={option.question} />
|
||||||
|
{#if $showTags && option.osmTags !== undefined}
|
||||||
|
({option.osmTags.asHumanString()})
|
||||||
|
{/if}
|
||||||
</option>
|
</option>
|
||||||
{/each}
|
{/each}
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
|
|
Loading…
Reference in a new issue