mapcomplete/UI/SpecialVisualizations.ts

29 lines
1.1 KiB
TypeScript
Raw Normal View History

import {UIElement} from "./UIElement";
import OpeningHoursVisualization from "./OhVisualization";
import {UIEventSource} from "../Logic/UIEventSource";
export default class SpecialVisualizations {
2020-10-11 22:37:55 +02:00
public static specialVisualizations: {
funcName: string,
constr: ((tagSource: UIEventSource<any>, argument: string[]) => UIElement),
docs: string,
args: {name: string, defaultValue: string, doc: string}[]
}[] =
[{
funcName: "opening_hours_table",
2020-10-11 22:37:55 +02:00
docs: "Creates an opening-hours table. Usage: {opening_hours_table(opening_hours)} to create a table of the tag 'opening_hours'.",
args:[{name:"key", defaultValue: "opening_hours", doc: "The tag from which the table is constructed"}],
constr: (tagSource: UIEventSource<any>, args) => {
let keyname = args[0];
if (keyname === undefined || keyname === "") {
keyname = keyname ?? "opening_hours"
}
return new OpeningHoursVisualization(tagSource, keyname)
}
2020-10-11 22:37:55 +02:00
},
]
}