forked from MapComplete/MapComplete
WIP
This commit is contained in:
parent
3ab1a0a3f2
commit
617b4854fa
48 changed files with 662 additions and 491 deletions
|
|
@ -33,6 +33,7 @@ import LineRenderingConfigJson from "../Json/LineRenderingConfigJson"
|
|||
import { ConversionContext } from "./ConversionContext"
|
||||
import { ExpandRewrite } from "./ExpandRewrite"
|
||||
import { TagUtils } from "../../../Logic/Tags/TagUtils"
|
||||
import { Translatable } from "../Json/Translatable"
|
||||
|
||||
class ExpandFilter extends DesugaringStep<LayerConfigJson> {
|
||||
private static readonly predefinedFilters = ExpandFilter.load_filters()
|
||||
|
|
@ -40,7 +41,7 @@ class ExpandFilter extends DesugaringStep<LayerConfigJson> {
|
|||
|
||||
constructor(state: DesugaringContext) {
|
||||
super(
|
||||
"Expands filters: replaces a shorthand by the value found in 'filters.json'. If the string is formatted 'layername.filtername, it will be looked up into that layer instead",
|
||||
"Expands filters: replaces a shorthand by the value found in 'filters.json'. If the string is formatted 'layername.filtername, it will be looked up into that layer instead. If a tagRendering sets 'filter', this filter will also be included",
|
||||
["filter"],
|
||||
"ExpandFilter",
|
||||
)
|
||||
|
|
@ -67,6 +68,9 @@ class ExpandFilter extends DesugaringStep<LayerConfigJson> {
|
|||
const newFilters: FilterConfigJson[] = []
|
||||
const filters = <(FilterConfigJson | string)[]>json.filter
|
||||
|
||||
/**
|
||||
* Checks all tagRendering. If a tagrendering has 'filter' set, add this filter to the layer config
|
||||
*/
|
||||
for (let i = 0; i < json.tagRenderings?.length; i++) {
|
||||
const tagRendering = <TagRenderingConfigJson>json.tagRenderings[i]
|
||||
if (!tagRendering?.filter) {
|
||||
|
|
@ -94,6 +98,9 @@ class ExpandFilter extends DesugaringStep<LayerConfigJson> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create filters based on builtin filters
|
||||
*/
|
||||
for (let i = 0; i < filters.length; i++) {
|
||||
const filter = filters[i]
|
||||
if (filter === undefined) {
|
||||
|
|
@ -115,15 +122,16 @@ class ExpandFilter extends DesugaringStep<LayerConfigJson> {
|
|||
"Found a matching tagRendering to base a filter on, but this tagRendering does not contain any mappings",
|
||||
)
|
||||
}
|
||||
const options = matchingTr.mappings.map((mapping) => ({
|
||||
const options = (<QuestionableTagRenderingConfigJson> matchingTr).mappings.map((mapping) => ({
|
||||
question: mapping.then,
|
||||
osmTags: mapping.if,
|
||||
searchTerms: mapping.searchTerms
|
||||
|
||||
}))
|
||||
options.unshift({
|
||||
question: matchingTr["question"] ?? {
|
||||
en: "All types",
|
||||
},
|
||||
question: matchingTr["question"] ?? Translations.t.general.filterPanel.allTypes,
|
||||
osmTags: undefined,
|
||||
searchTerms: undefined
|
||||
})
|
||||
newFilters.push({
|
||||
id: filter,
|
||||
|
|
|
|||
|
|
@ -103,6 +103,10 @@ export class DoesImageExist extends DesugaringStep<string> {
|
|||
return image
|
||||
}
|
||||
|
||||
if(Utils.isEmoji(image)){
|
||||
return image
|
||||
}
|
||||
|
||||
if (!this._knownImagePaths.has(image)) {
|
||||
if (this.doesPathExist === undefined) {
|
||||
context.err(
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ import { UIEventSource } from "../../Logic/UIEventSource"
|
|||
import { QueryParameters } from "../../Logic/Web/QueryParameters"
|
||||
import { Utils } from "../../Utils"
|
||||
import { RegexTag } from "../../Logic/Tags/RegexTag"
|
||||
import BaseUIElement from "../../UI/BaseUIElement"
|
||||
import Table from "../../UI/Base/Table"
|
||||
import Combine from "../../UI/Base/Combine"
|
||||
import MarkdownUtils from "../../Utils/MarkdownUtils"
|
||||
|
||||
export type FilterConfigOption = {
|
||||
question: Translation
|
||||
searchTerms: Record<string, string[]>
|
||||
icon?: string
|
||||
osmTags: TagsFilter | undefined
|
||||
/* Only set if fields are present. Used to create `osmTags` (which are used to _actually_ filter) when the field is written*/
|
||||
readonly originalTagsSpec: TagConfigJson
|
||||
|
|
@ -105,8 +105,10 @@ export default class FilterConfig {
|
|||
return {
|
||||
question: question,
|
||||
osmTags: osmTags,
|
||||
searchTerms: option.searchTerms,
|
||||
fields,
|
||||
originalTagsSpec: option.osmTags,
|
||||
icon: option.icon
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -151,7 +153,7 @@ export default class FilterConfig {
|
|||
}
|
||||
|
||||
public initState(layerId: string): UIEventSource<undefined | number | string> {
|
||||
let defaultValue = ""
|
||||
let defaultValue: string
|
||||
if (this.options.length > 1) {
|
||||
defaultValue = "" + (this.defaultSelection ?? 0)
|
||||
} else if (this.options[0].fields?.length > 0) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { TagConfigJson } from "./TagConfigJson"
|
||||
import { Translatable } from "./Translatable"
|
||||
|
||||
export default interface FilterConfigJson {
|
||||
/**
|
||||
|
|
@ -34,7 +35,9 @@ export default interface FilterConfigJson {
|
|||
* ```
|
||||
*/
|
||||
options: {
|
||||
question: string | any
|
||||
question: Translatable
|
||||
searchTerms?: Record<string, string[]>
|
||||
icon?: string
|
||||
osmTags?: TagConfigJson
|
||||
default?: boolean
|
||||
fields?: {
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ import { RecentSearch } from "../Logic/Geocoding/RecentSearch"
|
|||
import PhotonSearch from "../Logic/Geocoding/PhotonSearch"
|
||||
import ThemeSearch from "../Logic/Geocoding/ThemeSearch"
|
||||
import OpenStreetMapIdSearch from "../Logic/Geocoding/OpenStreetMapIdSearch"
|
||||
import FilterSearch from "../Logic/Geocoding/FilterSearch"
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -385,9 +386,10 @@ export default class ThemeViewState implements SpecialVisualizationState {
|
|||
|
||||
this.geosearch = new CombinedSearcher(
|
||||
new CoordinateSearch(),
|
||||
new LocalElementSearch(this, 5),
|
||||
new OpenStreetMapIdSearch(this),
|
||||
new PhotonSearch(), // new NominatimGeocoding(),
|
||||
new FilterSearch(this),
|
||||
//new LocalElementSearch(this, 5),
|
||||
//new OpenStreetMapIdSearch(this),
|
||||
// new PhotonSearch(), // new NominatimGeocoding(),
|
||||
this.featureSwitches.featureSwitchBackToThemeOverview.data ? new ThemeSearch(this) : undefined
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue