Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions frontend/taipy-gui/src/components/Taipy/DateRange.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,16 @@ describe("DateRange with time Component", () => {
expect(elts).toHaveLength(2);
expect(elts[0].parentElement?.tagName).toBe("BUTTON");
});
it("renders time dropdown with minutes steps", async () => {
const { getAllByTestId } = render(
<LocalizationProvider dateAdapter={AdapterDateFns}>
<DateRange dates={curDates} withTime={true} minuteJump={15}/>
</LocalizationProvider>
);
const elts = getAllByTestId("CalendarIcon");
expect(elts).toHaveLength(2);
expect(elts[0].parentElement?.tagName).toBe("BUTTON");
});
it("displays the right info for string", async () => {
const { getAllByTestId } = render(
<LocalizationProvider dateAdapter={AdapterDateFns}>
Expand Down
5 changes: 4 additions & 1 deletion frontend/taipy-gui/src/components/Taipy/DateRange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ interface DateRangeProps extends TaipyActiveProps, TaipyChangeProps {
separator?: string;
width?: string | number;
analogic?: boolean;
minuteJump?: number;
}

const textFieldProps = { textField: { margin: "dense" } } as BaseDateTimePickerSlotProps<Date>;
Expand Down Expand Up @@ -74,7 +75,7 @@ const analogicRenderers = {
}

const DateRange = (props: DateRangeProps) => {
const { updateVarName, withTime = false, id, propagate = true, separator = "-", analogic = false } = props;
const { updateVarName, withTime = false, id, propagate = true, separator = "-", analogic = false, minuteJump = 15 } = props;
const dispatch = useDispatch();
const formatConfig = useFormatConfig();
const tz = formatConfig.timeZone;
Expand Down Expand Up @@ -166,6 +167,7 @@ const DateRange = (props: DateRangeProps) => {
format={props.format}
sx={dateSx}
viewRenderers={ analogic ? analogicRenderers : undefined }
timeSteps={{minutes:minuteJump}}
/>
<Typography>{separator}</Typography>
<DateTimePicker
Expand All @@ -183,6 +185,7 @@ const DateRange = (props: DateRangeProps) => {
format={props.format}
sx={dateSx}
viewRenderers={ analogic ? analogicRenderers : undefined }
timeSteps={{minutes:minuteJump}}
/>
</>
) : (
Expand Down
9 changes: 9 additions & 0 deletions frontend/taipy-gui/src/components/Taipy/DateSelector.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,15 @@ describe("DateSelector with time Component", () => {
const elt = getByTestId("CalendarIcon");
expect(elt.parentElement?.tagName).toBe("BUTTON");
});
it("renders time dropdown with minutes steps", async () => {
const { getByTestId } = render(
<LocalizationProvider dateAdapter={AdapterDateFns}>
<DateSelector date={curDateStr} withTime={true} minuteJump={15}/>
</LocalizationProvider>
);
const elt = getByTestId("CalendarIcon");
expect(elt.parentElement?.tagName).toBe("BUTTON");
});
it("displays the right info for string", async () => {
const { getByTestId } = render(
<LocalizationProvider dateAdapter={AdapterDateFns}>
Expand Down
4 changes: 3 additions & 1 deletion frontend/taipy-gui/src/components/Taipy/DateSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ interface DateSelectorProps extends TaipyActiveProps, TaipyChangeProps {
label?: string;
width?: string | number;
analogic? :boolean;
minuteJump? :number;
}

const boxSx = { display: "inline-block" };
Expand All @@ -59,7 +60,7 @@ const analogicRenderers = {
}

const DateSelector = (props: DateSelectorProps) => {
const { updateVarName, withTime = false, id, propagate = true, analogic = false } = props;
const { updateVarName, withTime = false, id, propagate = true, analogic = false, minuteJump = 15 } = props;
const dispatch = useDispatch();
const formatConfig = useFormatConfig();
const tz = formatConfig.timeZone;
Expand Down Expand Up @@ -133,6 +134,7 @@ const DateSelector = (props: DateSelectorProps) => {
format={props.format}
sx={dateSx}
viewRenderers={ analogic ? analogicRenderers : undefined }
timeSteps={{minutes: minuteJump}}
/>
) : (
<DatePicker
Expand Down
10 changes: 9 additions & 1 deletion frontend/taipy-gui/src/components/Taipy/TimeSelector.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,15 @@ describe("TimeSelector component with digital time picker", () => {
const elt = getByTestId("ClockIcon");
expect(elt.parentElement?.tagName).toBe("BUTTON");
});

it("renders time dropdown with minutes steps", async () => {
const { getByTestId } = render(
<LocalizationProvider dateAdapter={AdapterDateFns}>
<TimeSelector time={curDateStr} minuteJump={15}/>
</LocalizationProvider>
);
const elt = getByTestId("ClockIcon");
expect(elt.parentElement?.tagName).toBe("BUTTON");
});
it("displays the right info for string", async () => {
const { getByTestId } = render(
<LocalizationProvider dateAdapter={AdapterDateFns}>
Expand Down
4 changes: 3 additions & 1 deletion frontend/taipy-gui/src/components/Taipy/TimeSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ interface TimeSelectorProps extends TaipyActiveProps, TaipyChangeProps {
label?: string;
time: string;
width?: string | number;
minuteJump?: number;
}

const boxSx = { display: "inline-block" };
const TimeSelector = (props: TimeSelectorProps) => {
const { analogic = false, id, updateVarName, propagate = true } = props;
const { analogic = false, id, updateVarName, propagate = true, minuteJump =15 } = props;
const [value, setValue] = useState(() => getTime(props.defaultTime));
const dispatch = useDispatch();
const module = useModule();
Expand Down Expand Up @@ -102,6 +103,7 @@ const TimeSelector = (props: TimeSelectorProps) => {
label={props.label}
format={props.format}
sx={timeSx}
timeSteps={{minutes:minuteJump}}
/>
)
):(
Expand Down
5 changes: 4 additions & 1 deletion taipy/gui/_renderers/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class _Factory:
("active", PropertyType.dynamic_boolean, True),
("analogic", PropertyType.boolean),
("min", PropertyType.dynamic_date),
("minute_jump", PropertyType.number),
("max", PropertyType.dynamic_date),
("editable", PropertyType.dynamic_boolean, True),
("hover_text", PropertyType.dynamic_string),
Expand All @@ -188,6 +189,7 @@ class _Factory:
("hover_text", PropertyType.dynamic_string),
("label_start",),
("label_end",),
("minute_jump", PropertyType.number),
("on_change", PropertyType.function),
("format",),
("width", PropertyType.string_or_number),
Expand Down Expand Up @@ -607,9 +609,10 @@ class _Factory:
("active", PropertyType.dynamic_boolean, True),
("analogic", PropertyType.boolean),
("editable", PropertyType.dynamic_boolean, True),
("format",),
("hover_text", PropertyType.dynamic_string),
("label",),
("format",),
("minute_jump", PropertyType.number),
("width", PropertyType.string_or_number),
]
)
Expand Down
15 changes: 15 additions & 0 deletions taipy/gui/viselements.json
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@
"default_value": "False",
"doc": "Whether or not to show the time part of the date."
},
{
"name": "minute_jump",
"type": "dynamic(int)",
"doc": "The time steps between two time unit options"
},
{
"name": "format",
"type": "str",
Expand Down Expand Up @@ -380,6 +385,11 @@
"type": "str",
"doc": "The format to apply to the value. See below."
},
{
"name": "minute_jump",
"type": "dynamic(int)",
"doc": "The time steps between two time unit options"
},
{
"name": "editable",
"type": "dynamic(bool)",
Expand Down Expand Up @@ -426,6 +436,11 @@
"default_value": "False",
"doc": "Whether or not to show the time part of the date."
},
{
"name": "minute_jump",
"type": "dynamic(int)",
"doc": "The time steps between two time unit options"
},
{
"name": "format",
"type": "str",
Expand Down