diff --git a/Models/ThemeConfig/FilterConfig.ts b/Models/ThemeConfig/FilterConfig.ts index 5d7fe2e820..5e83577dfa 100644 --- a/Models/ThemeConfig/FilterConfig.ts +++ b/Models/ThemeConfig/FilterConfig.ts @@ -10,6 +10,9 @@ import { FilterState } from "../FilteredLayer" 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"; export default class FilterConfig { public readonly id: string @@ -242,4 +245,21 @@ export default class FilterConfig { reset ) } + + public GenerateDocs(): BaseUIElement { + const hasField = this.options.some(opt => opt.fields?.length > 0) + return new Table( + Utils.NoNull(["id","question","osmTags",hasField ? "fields" : undefined]), + this.options.map((opt, i) => { + const isDefault = this.options.length > 1 && ((this.defaultSelection ?? 0) == i) + return Utils.NoNull([ + this.id + "." + i, + isDefault ? new Combine([opt.question.SetClass("font-bold"), "(default)"]) : opt.question , + opt.osmTags?.asHumanString(false, false, {}) ?? "", + opt.fields?.length > 0 ? new Combine(opt.fields.map(f => f.name+" ("+f.type+")")) : undefined + + ]); + }) + ); + } } diff --git a/Models/ThemeConfig/LayerConfig.ts b/Models/ThemeConfig/LayerConfig.ts index b725ea4c21..172a614c8d 100644 --- a/Models/ThemeConfig/LayerConfig.ts +++ b/Models/ThemeConfig/LayerConfig.ts @@ -601,6 +601,11 @@ export default class LayerConfig extends WithContextLoader { } } + const filterDocs: (string | BaseUIElement)[] = [] + if(this.filters.length > 0){ + filterDocs.push(new Title("Filters", 4)) + filterDocs.push(...this.filters.map(filter => filter.GenerateDocs())) + } return new Combine([ new Combine([new Title(this.id, 1), iconImg, this.description, "\n"]).SetClass( "flex flex-col" @@ -615,6 +620,7 @@ export default class LayerConfig extends WithContextLoader { new Title("Supported attributes", 2), quickOverview, ...this.tagRenderings.map((tr) => tr.GenerateDocumentation()), + ...filterDocs ]) .SetClass("flex-col") .SetClass("link-underline")