Fix: search fields in a filter are now wrapped into parentheses, allowing for OR as regex

This commit is contained in:
Pieter Vander Vennet 2024-09-17 02:33:05 +02:00
parent de699b6ea3
commit fb250fb928
2 changed files with 14 additions and 7 deletions

View file

@ -131,6 +131,13 @@ export default class FilteredLayer {
return values
}
/**
* import Translations from "../UI/i18n/Translations"
* import { RegexTag } from "../Logic/Tags/RegexTag"
*
* const option: FilterConfigOption = {question: Translations.T("question"), osmTags: undefined, originalTagsSpec: "key~.*{search}.*", fields: [{name: "search", type: "string"}] }
* FilteredLayer.fieldsToTags(option, {search: "value_regex"}) // => new RegexTag("key", /^(.*(value_regex).*)$/)
*/
private static fieldsToTags(
option: FilterConfigOption,
fieldstate: string | Record<string, string>
@ -153,7 +160,7 @@ export default class FilteredLayer {
}
for (const key in properties) {
v = (<string>v).replace("{" + key + "}", properties[key])
v = (<string>v).replace("{" + key + "}", "(" + properties[key] + ")")
}
return v