MapComplete/src/UI/InputElement/Validators/OpeningHoursValidator.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
1.6 KiB
TypeScript
Raw Normal View History

import { Validator } from "../Validator"
import MarkdownUtils from "../../../Utils/MarkdownUtils"
2023-03-29 17:21:20 +02:00
export default class OpeningHoursValidator extends Validator {
constructor() {
super(
"opening_hours",
[
2023-03-29 17:21:20 +02:00
"Has extra elements to easily input when a POI is opened.",
("### Helper arguments"),
"Only one helper argument named `options` can be provided. It is a JSON-object of type `{ prefix: string, postfix: string }`:",
MarkdownUtils.table(
["subarg", "doc"],
2023-03-29 17:21:20 +02:00
[
[
"prefix",
"Piece of text that will always be added to the front of the generated opening hours. If the OSM-data does not start with this, it will fail to parse."
2023-03-29 17:21:20 +02:00
],
[
"postfix",
"Piece of text that will always be added to the end of the generated opening hours"
]
]),
("### Example usage"),
2023-03-29 17:21:20 +02:00
"To add a conditional (based on time) access restriction:\n\n```\n" +
`
2023-03-29 17:21:20 +02:00
"freeform": {
"key": "access:conditional",
"type": "opening_hours",
"helperArgs": [
{
"prefix":"no @ (",
"postfix":")"
}
]
}` +
"\n```\n\n*Don't forget to pass the prefix and postfix in the rendering as well*: `{opening_hours_table(opening_hours,yes @ &LPARENS, &RPARENS )`"
].join("\n")
2023-03-29 17:21:20 +02:00
)
}
}