2019-09-12 08:11:25 +00:00
|
|
|
import React from "react";
|
2019-09-13 10:45:49 +00:00
|
|
|
import BaseWidget, { WidgetProps, WidgetState } from "./BaseWidget";
|
2019-09-12 08:11:25 +00:00
|
|
|
import { WidgetType } from "../constants/WidgetConstants";
|
2019-09-13 11:59:45 +00:00
|
|
|
import { ActionPayload } from "../constants/ActionConstants";
|
2019-11-06 12:12:41 +00:00
|
|
|
import DatePickerComponent from "../components/designSystems/blueprint/DatePickerComponent";
|
2019-09-12 08:11:25 +00:00
|
|
|
|
2019-09-13 10:45:49 +00:00
|
|
|
class DatePickerWidget extends BaseWidget<DatePickerWidgetProps, WidgetState> {
|
2019-09-12 08:11:25 +00:00
|
|
|
getPageView() {
|
2019-11-06 12:12:41 +00:00
|
|
|
return (
|
|
|
|
|
<DatePickerComponent
|
|
|
|
|
label={this.props.label}
|
|
|
|
|
dateFormat={this.props.dateFormat}
|
|
|
|
|
widgetId={this.props.widgetId}
|
2019-11-12 07:57:12 +00:00
|
|
|
timezone={this.props.timezone}
|
2019-11-06 12:12:41 +00:00
|
|
|
enableTimePicker={this.props.enableTimePicker}
|
|
|
|
|
defaultDate={this.props.defaultDate}
|
|
|
|
|
datePickerType={"DATE_PICKER"}
|
|
|
|
|
onDateSelected={this.onDateSelected}
|
|
|
|
|
selectedDate={this.props.selectedDate}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2019-09-12 08:11:25 +00:00
|
|
|
}
|
|
|
|
|
|
2019-11-06 12:12:41 +00:00
|
|
|
onDateSelected = (selectedDate: Date) => {
|
|
|
|
|
this.context.updateWidgetProperty(
|
|
|
|
|
this.props.widgetId,
|
|
|
|
|
"selectedDate",
|
|
|
|
|
selectedDate,
|
|
|
|
|
);
|
|
|
|
|
super.executeAction(this.props.onDateSelected);
|
|
|
|
|
};
|
|
|
|
|
|
2019-09-12 08:11:25 +00:00
|
|
|
getWidgetType(): WidgetType {
|
|
|
|
|
return "DATE_PICKER_WIDGET";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-13 10:45:49 +00:00
|
|
|
export type DatePickerType = "DATE_PICKER" | "DATE_RANGE_PICKER";
|
2019-09-12 08:11:25 +00:00
|
|
|
|
2019-09-13 10:45:49 +00:00
|
|
|
export interface DatePickerWidgetProps extends WidgetProps {
|
|
|
|
|
defaultDate?: Date;
|
2019-11-06 12:12:41 +00:00
|
|
|
selectedDate: Date;
|
2019-11-12 07:57:12 +00:00
|
|
|
timezone?: string;
|
2019-11-06 12:12:41 +00:00
|
|
|
enableTimePicker: boolean;
|
|
|
|
|
dateFormat: string;
|
2019-09-13 10:45:49 +00:00
|
|
|
label: string;
|
|
|
|
|
datePickerType: DatePickerType;
|
2019-09-13 11:59:45 +00:00
|
|
|
onDateSelected: ActionPayload[];
|
|
|
|
|
onDateRangeSelected: ActionPayload[];
|
2019-11-06 12:12:41 +00:00
|
|
|
maxDate: Date;
|
|
|
|
|
minDate: Date;
|
2019-09-12 08:11:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default DatePickerWidget;
|