mapcomplete/UI/OpeningHours/OpeningHoursPicker.ts

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

40 lines
1.2 KiB
TypeScript
Raw Normal View History

import { UIEventSource } from "../../Logic/UIEventSource"
import OpeningHoursPickerTable from "./OpeningHoursPickerTable"
import { OH, OpeningHour } from "./OpeningHours"
import { InputElement } from "../Input/InputElement"
2021-06-10 01:36:20 +02:00
import BaseUIElement from "../BaseUIElement"
2020-10-04 01:04:46 +02:00
export default class OpeningHoursPicker extends InputElement<OpeningHour[]> {
public readonly IsSelected: UIEventSource<boolean> = new UIEventSource<boolean>(false)
2021-06-16 14:23:53 +02:00
private readonly _ohs: UIEventSource<OpeningHour[]>
2020-10-04 01:04:46 +02:00
private readonly _backgroundTable: OpeningHoursPickerTable
2020-09-30 22:22:58 +02:00
2020-10-04 12:55:44 +02:00
constructor(ohs: UIEventSource<OpeningHour[]> = new UIEventSource<OpeningHour[]>([])) {
2020-09-30 22:22:58 +02:00
super()
2020-10-04 01:04:46 +02:00
this._ohs = ohs
2020-09-30 22:22:58 +02:00
2021-06-16 14:23:53 +02:00
ohs.addCallback((oh) => {
ohs.setData(OH.MergeTimes(oh))
})
2020-09-30 22:22:58 +02:00
2021-06-16 14:23:53 +02:00
this._backgroundTable = new OpeningHoursPickerTable(this._ohs)
this._backgroundTable.ConstructElement()
2020-09-30 22:22:58 +02:00
}
2021-06-10 01:36:20 +02:00
InnerRender(): BaseUIElement {
return this._backgroundTable
}
2020-10-04 01:04:46 +02:00
GetValue(): UIEventSource<OpeningHour[]> {
return this._ohs
2020-09-30 22:22:58 +02:00
}
2020-10-04 01:04:46 +02:00
IsValid(t: OpeningHour[]): boolean {
return true
2020-09-30 22:22:58 +02:00
}
2021-06-16 14:23:53 +02:00
protected InnerConstructElement(): HTMLElement {
return this._backgroundTable.ConstructElement()
}
2020-09-30 22:22:58 +02:00
}