Studio: usability tests

This commit is contained in:
Pieter Vander Vennet 2023-10-20 19:04:55 +02:00
parent 0f60977b6d
commit 2041a9245d
37 changed files with 524 additions and 446 deletions

View file

@ -247,6 +247,11 @@ export default class SpecialVisualizations {
* // Return empty list on empty input
* SpecialVisualizations.constructSpecification("") // => []
*
* // Simple case
* const oh = SpecialVisualizations.constructSpecification("The opening hours with value {opening_hours} can be seen in the following table: <br/> {opening_hours_table()}")
* oh[0] // => "The opening hours with value {opening_hours} can be seen in the following table: <br/> "
* oh[1].func.funcName // => "opening_hours_table"
*
* // Advanced cases with commas, braces and newlines should be handled without problem
* const templates = SpecialVisualizations.constructSpecification("{send_email(&LBRACEemail&RBRACE,Broken bicycle pump,Hello&COMMA\n\nWith this email&COMMA I'd like to inform you that the bicycle pump located at https://mapcomplete.org/cyclofix?lat=&LBRACE_lat&RBRACE&lon=&LBRACE_lon&RBRACE&z=18#&LBRACEid&RBRACE is broken.\n\n Kind regards,Report this bicycle pump as broken)}")
* const templ = <Exclude<RenderingSpecification, string>> templates[0]
@ -308,20 +313,6 @@ export default class SpecialVisualizations {
}
}
// Let's to a small sanity check to help the theme designers:
if (template.search(/{[^}]+\([^}]*\)}/) >= 0) {
// Hmm, we might have found an invalid rendering name
let suggestion = ""
if (SpecialVisualizations.specialVisualizations?.length > 0) {
suggestion =
"did you mean one of: " +
SpecialVisualizations.specialVisualizations
.map((sp) => sp.funcName + "()")
.join(", ")
}
}
// IF we end up here, no changes have to be made - except to remove any resting {}
return [template]
}
@ -1388,6 +1379,27 @@ export default class SpecialVisualizations {
)
},
},
{
funcName: "braced",
docs: "Show a literal text within braces",
needsUrls: [],
args: [
{
name: "text",
required: true,
doc: "The value to show",
},
],
constr(
state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>,
args: string[],
feature: Feature,
layer: LayerConfig
): BaseUIElement {
return new FixedUiElement("{" + args[0] + "}")
},
},
]
specialVisualizations.push(new AutoApplyButton(specialVisualizations))