Merge branch 'develop' into Robin-patch-1

This commit is contained in:
Robin van der Linde 2025-03-16 14:58:46 +01:00
commit 6f59c95792
Signed by untrusted user: Robin-van-der-Linde
GPG key ID: 53956B3252478F0D
17 changed files with 329 additions and 71 deletions

View file

@ -686,7 +686,8 @@ export default class TagRenderingConfig {
}
/**
* Given a value for the freeform key and an overview of the selected mappings, construct the correct tagsFilter to apply
* Given a value for the freeform key and an overview of the selected mappings, construct the correct tagsFilter to apply.
* Result should be interpreted as "and"
*
* const config = new TagRenderingConfig({"id":"bookcase-booktypes","render":{"en":"This place mostly serves {books}" },
* "question":{"en":"What kind of books can be found in this public bookcase?"},
@ -696,17 +697,17 @@ export default class TagRenderingConfig {
* "mappings":[{"if":"books=children","then":"Mostly children books"},
* {"if":"books=adults","then": "Mostly books for adults"}]}
* , "testcase")
* config.constructChangeSpecification(undefined, undefined, [false, true, false], {amenity: "public_bookcase"}) // => new And([new Tag("books","adults")])
* config.constructChangeSpecification(undefined, undefined, [false, true, false], {amenity: "public_bookcase"}) // => [new Tag("books","adults")]
*
* const config = new TagRenderingConfig({"id":"capacity", "render": "Fits {capcity} books",freeform: {"key":"capacity",type:"pnat"} })
* config.constructChangeSpecification("", undefined, undefined, {}) // => undefined
* config.constructChangeSpecification("5", undefined, undefined, {}).optimize() // => new Tag("capacity", "5")
* config.constructChangeSpecification("5", undefined, undefined, {}).optimize() // => [new Tag("capacity", "5")]
*
* // Should pick a mapping, even if freeform is used
* // Should pick a mapping, even if freeform is usedconstructChange
* const config = new TagRenderingConfig({"id": "shop-types", render: "Shop type is {shop}", freeform: {key: "shop", addExtraTags:["fixme=freeform shop type used"]}, mappings:[{if: "shop=second_hand", then: "Second hand shop"}]})
* config.constructChangeSpecification("freeform", 1, undefined, {}).asHumanString(false, false, {}) // => "shop=freeform & fixme=freeform shop type used"
* config.constructChangeSpecification("freeform", undefined, undefined, {}).asHumanString(false, false, {}) // => "shop=freeform & fixme=freeform shop type used"
* config.constructChangeSpecification("second_hand", 1, undefined, {}).asHumanString(false, false, {}) // => "shop=second_hand"
* config.constructChangeSpecification("freeform", 1, undefined, {}).asHumanString(false, false, {}) // => [new Tag("shop","freeform",new Tag("fixme","freeform shop type used")]
* config.constructChangeSpecification("freeform", undefined, undefined, {}) // => [new Tag("shop","freeform), new Tag("fixme","freeform shop type used")]
* config.constructChangeSpecification("second_hand", 1, undefined, {}) // => [new Tag("shop","second_hand")]
*
*
* const config = new TagRenderingConfig({id: "oh", render: "{opening_hours}", question: {"en":"When open?"}, freeform: {key: "opening_hours"},
@ -716,11 +717,11 @@ export default class TagRenderingConfig {
* },
* "hideInAnswer": true}] }
* const tags = config.constructChangeSpecification("Tu-Fr 05:30-09:30", undefined, undefined, { }}
* tags // =>new And([ new Tag("opening_hours", "Tu-Fr 05:30-09:30")])
* tags // => [ new Tag("opening_hours", "Tu-Fr 05:30-09:30")]
*
* const config = new TagRenderingConfig({"id": "charge", render: "One tube costs {charge}", freeform: {key: "charge", postfixDistinguished: "bicycle_tube"]}, })
* const tags = config.constructChangeSpecification("€5", undefined, undefined, {vending: "books;bicycle_tubes" charge: "€42/book"})
* tags // =>new And([ new Tag("charge", "€5/bicycle_tube; €42/book")])
* tags // => [ new Tag("charge", "€5/bicycle_tube; €42/book")]
*
*
* @param freeformValue The freeform value which will be applied as 'freeform.key'. Ignored if 'freeform.key' is not set