Merge branch 'master' into develop
This commit is contained in:
commit
29ee4ae155
20 changed files with 106 additions and 40 deletions
|
@ -114,7 +114,7 @@ export class SummaryTileSource extends DynamicTileSource {
|
|||
): Store<Feature<Point>[]> {
|
||||
const [z, x, y] = Tiles.tile_from_index(tileIndex)
|
||||
let coordinates = Tiles.centerPointOf(z, x, y)
|
||||
const url = `${cacheserver}/${layersSummed}/${z}/${x}/${y}.json`
|
||||
const url = `${cacheserver}/summary/${layersSummed}/${z}/${x}/${y}.json`
|
||||
const count = UIEventSource.FromPromiseWithErr(Utils.downloadJson(url))
|
||||
return count.mapD((count) => {
|
||||
if (count["error"] !== undefined) {
|
||||
|
|
|
@ -62,8 +62,37 @@ class ExpandFilter extends DesugaringStep<LayerConfigJson> {
|
|||
|
||||
const newFilters: FilterConfigJson[] = []
|
||||
const filters = <(FilterConfigJson | string)[]>json.filter
|
||||
|
||||
for (let i = 0; i < json.tagRenderings?.length; i++){
|
||||
const tagRendering = <TagRenderingConfigJson> json.tagRenderings[i]
|
||||
if(!tagRendering.filter){
|
||||
continue
|
||||
}
|
||||
for (const filterName of tagRendering.filter ?? []) {
|
||||
if(typeof filterName !== "string"){
|
||||
context.enters("tagRenderings",i,"filter").err("Not a string: "+ filterName)
|
||||
}
|
||||
const exists = filters.some(existing => {
|
||||
const id : string = existing["id"] ?? existing
|
||||
return filterName === id || (filterName.startsWith("filters.") && filterName.endsWith("."+id))
|
||||
})
|
||||
if(exists){
|
||||
continue
|
||||
}
|
||||
if(!filterName){
|
||||
context.err("Got undefined as filter expansion in "+tagRendering["id"])
|
||||
continue
|
||||
}
|
||||
console.log("Adding filter",filterName," due to", tagRendering["id"])
|
||||
filters.push(filterName)
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < filters.length; i++) {
|
||||
const filter = filters[i]
|
||||
if(filter === undefined){
|
||||
continue
|
||||
}
|
||||
if (typeof filter !== "string") {
|
||||
newFilters.push(filter)
|
||||
continue
|
||||
|
@ -85,7 +114,7 @@ class ExpandFilter extends DesugaringStep<LayerConfigJson> {
|
|||
osmTags: mapping.if,
|
||||
}))
|
||||
options.unshift({
|
||||
question: {
|
||||
question: matchingTr["question"] ?? {
|
||||
en: "All types",
|
||||
},
|
||||
osmTags: undefined,
|
||||
|
@ -113,7 +142,11 @@ class ExpandFilter extends DesugaringStep<LayerConfigJson> {
|
|||
const expandedFilter = (<(FilterConfigJson | string)[]>layer.filter).find(
|
||||
(f) => typeof f !== "string" && f.id === expectedId
|
||||
)
|
||||
newFilters.push(<FilterConfigJson>expandedFilter)
|
||||
if(expandedFilter === undefined){
|
||||
context.err("Did not find filter with name "+filter)
|
||||
}else{
|
||||
newFilters.push(<FilterConfigJson>expandedFilter)
|
||||
}
|
||||
} else {
|
||||
// This is a bootstrapping-run, we can safely ignore this
|
||||
}
|
||||
|
|
|
@ -1761,6 +1761,10 @@ export class ValidateFilter extends DesugaringStep<FilterConfigJson> {
|
|||
// Calling another filter, we skip
|
||||
return filter
|
||||
}
|
||||
if(filter === undefined){
|
||||
context.err("Trying to validate a filter, but this filter is undefined")
|
||||
return undefined
|
||||
}
|
||||
for (const option of filter.options) {
|
||||
for (let i = 0; i < option.fields?.length ?? 0; i++) {
|
||||
const field = option.fields[i]
|
||||
|
|
|
@ -222,4 +222,9 @@ export interface TagRenderingConfigJson {
|
|||
* Values are split on ` ` (space)
|
||||
*/
|
||||
classes?: string
|
||||
|
||||
/**
|
||||
* This tagRendering can introduce this builtin filter
|
||||
*/
|
||||
filter?: string[]
|
||||
}
|
||||
|
|
|
@ -43,16 +43,12 @@
|
|||
{#if filteredLayer.layerDef.name}
|
||||
<div class:focus={$highlightedLayer === filteredLayer.layerDef.id} class="mb-1.5">
|
||||
<Checkbox selected={isDisplayed}>
|
||||
<If condition={filteredLayer.isDisplayed}>
|
||||
<div class="block h-6 w-6 no-image-background" class:opacity-50={!$isDisplayed}>
|
||||
<ToSvelte
|
||||
construct={() => layer.defaultIcon()?.SetClass("block h-6 w-6 no-image-background")}
|
||||
construct={() => layer.defaultIcon()}
|
||||
/>
|
||||
<ToSvelte
|
||||
slot="else"
|
||||
construct={() =>
|
||||
layer.defaultIcon()?.SetClass("block h-6 w-6 no-image-background opacity-50")}
|
||||
/>
|
||||
</If>
|
||||
</div>
|
||||
|
||||
|
||||
<Tr t={filteredLayer.layerDef.name} />
|
||||
|
||||
|
|
|
@ -1,7 +1,24 @@
|
|||
import { Validator } from "../Validator"
|
||||
import { Translation } from "../../i18n/Translation"
|
||||
import Translations from "../../i18n/Translations"
|
||||
|
||||
export default class StringValidator extends Validator {
|
||||
constructor() {
|
||||
super("string", "A simple piece of text")
|
||||
|
||||
constructor(type?: string, doc?: string, inputmode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search", textArea?: boolean) {
|
||||
super(type ?? "string",
|
||||
doc ?? "A simple piece of text which is at most 255 characters long",
|
||||
inputmode,
|
||||
textArea)
|
||||
}
|
||||
|
||||
isValid(s: string): boolean {
|
||||
return s.length <= 255
|
||||
}
|
||||
|
||||
getFeedback(s: string, getCountry?: () => string): Translation | undefined {
|
||||
if (s.length > 255) {
|
||||
return Translations.t.validation.tooLong.Subs({ count: s.length })
|
||||
}
|
||||
return super.getFeedback(s, getCountry)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Validator } from "../Validator"
|
||||
import StringValidator from "./StringValidator"
|
||||
|
||||
export default class TextValidator extends Validator {
|
||||
export default class TextValidator extends StringValidator {
|
||||
constructor() {
|
||||
super(
|
||||
"text",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue