Merge develop

This commit is contained in:
Pieter Vander Vennet 2024-09-17 02:36:38 +02:00
commit 5a9f8f0a0a
62 changed files with 4448 additions and 710 deletions

View file

@ -722,7 +722,7 @@ export class ValidatePointRendering extends DesugaringStep<PointRenderingConfigJ
if (json.marker && !Array.isArray(json.marker)) {
context.enter("marker").err("The marker in a pointRendering should be an array")
}
if (json.location.length == 0) {
if (!(json.location?.length > 0)) {
context
.enter("location")
.err(

View file

@ -9,6 +9,7 @@ import { QueryParameters } from "../../Logic/Web/QueryParameters"
import { Utils } from "../../Utils"
import { RegexTag } from "../../Logic/Tags/RegexTag"
import MarkdownUtils from "../../Utils/MarkdownUtils"
import Validators, { ValidatorType } from "../../UI/InputElement/Validators"
export type FilterConfigOption = {
question: Translation
@ -18,7 +19,7 @@ export type FilterConfigOption = {
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
fields: { name: string; type: string }[]
fields: { name: string; type: ValidatorType }[]
}
export default class FilterConfig {
public readonly id: string
@ -58,8 +59,11 @@ export default class FilterConfig {
throw `Invalid filter: no question given at ${ctx}`
}
const fields: { name: string; type: string }[] = (option.fields ?? []).map((f, i) => {
const type = f.type ?? "string"
const fields: { name: string; type: ValidatorType }[] = (option.fields ?? []).map((f, i) => {
const type = <ValidatorType> f.type ?? "string"
if(Validators.availableTypes.indexOf(type) < 0){
throw `Invalid filter: type is not a valid validator. Did you mean one of ${Utils.sortedByLevenshteinDistance(type, <any>Validators.availableTypes, x => x).slice(0, 3)}`
}
// Type is validated against 'ValidatedTextField' in Validation.ts, in ValidateFilterConfig
if (f.name === undefined || f.name === "" || f.name.match(/[a-z0-9_-]+/) == null) {
throw `Invalid filter: a variable name should match [a-z0-9_-]+ at ${ctx}.fields[${i}]`

View file

@ -926,7 +926,7 @@ export default class TagRenderingConfig {
* Might give undefined if setting to unknown is not possible
*/
public removeToSetUnknown(partOfLayer: LayerConfig, currentTags: Record<string, string>): string[] | undefined {
if(!partOfLayer?.source || !currentTags){
if (!partOfLayer?.source || !currentTags) {
return
}
const toDelete = new Set<string>()
@ -1001,12 +1001,17 @@ export class TagRenderingConfigUtils {
// The original mappings get "priorityIf" set
const oldMappingsCloned =
clone.mappings?.map(
(m) =>
<Mapping>{
(m) => {
const mapping = {
...m,
addExtraTags: [new Tag("nobrand", "")],
priorityIf: m.priorityIf ?? TagUtils.Tag("id~*"),
},
}
if (m.if.usedKeys().indexOf("nobrand") < 0) {
// Erase 'nobrand=yes', unless this option explicitly sets it
mapping["addExtraTags"] = [new Tag("nobrand", "")]
}
return <Mapping>mapping
},
) ?? []
clone.mappings = [...oldMappingsCloned, ...extraMappings]
return clone