From e39ad211a1c59299f1690784223b8b3c11c608b9 Mon Sep 17 00:00:00 2001 From: asvarcas Date: Sun, 5 Jan 2020 17:26:18 -0300 Subject: [PATCH 1/3] Added missing DateTimeInput parse and format props. --- packages/ra-ui-materialui/src/input/DateTimeInput.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/ra-ui-materialui/src/input/DateTimeInput.tsx b/packages/ra-ui-materialui/src/input/DateTimeInput.tsx index 884acf46ad0..9d703fcf59c 100644 --- a/packages/ra-ui-materialui/src/input/DateTimeInput.tsx +++ b/packages/ra-ui-materialui/src/input/DateTimeInput.tsx @@ -66,6 +66,7 @@ const parse = (value: string) => new Date(value); export const DateTimeInput: FunctionComponent< InputProps & Omit > = ({ + format = format, label, helperText, margin = 'dense', @@ -75,6 +76,7 @@ export const DateTimeInput: FunctionComponent< options, source, resource, + parse = parse, validate, variant = 'filled', ...rest From 5983807013bfdd70a3feb9c6ba22b04712639b1c Mon Sep 17 00:00:00 2001 From: asvarcas Date: Sun, 5 Jan 2020 17:31:48 -0300 Subject: [PATCH 2/3] Renamed default parse and format functions. --- packages/ra-ui-materialui/src/input/DateTimeInput.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/ra-ui-materialui/src/input/DateTimeInput.tsx b/packages/ra-ui-materialui/src/input/DateTimeInput.tsx index 9d703fcf59c..049f28ca8f5 100644 --- a/packages/ra-ui-materialui/src/input/DateTimeInput.tsx +++ b/packages/ra-ui-materialui/src/input/DateTimeInput.tsx @@ -33,7 +33,7 @@ const dateTimeRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/; * * @param {Date | String} value date string or object */ -const format = (value: string | Date) => { +const dateTimeFormatter = (value: string | Date) => { // null, undefined and empty string values should not go through convertDateToString // otherwise, it returns undefined and will make the input an uncontrolled one. if (value == null || value === '') { @@ -58,7 +58,7 @@ const format = (value: string | Date) => { * @param {String} value Date string, formatted as yyyy-MM-ddThh:mm * @return {Date} */ -const parse = (value: string) => new Date(value); +const dateTimeParser = (value: string) => new Date(value); /** * Input component for entering a date and a time with timezone, using the browser locale @@ -66,7 +66,7 @@ const parse = (value: string) => new Date(value); export const DateTimeInput: FunctionComponent< InputProps & Omit > = ({ - format = format, + format = dateTimeFormatter, label, helperText, margin = 'dense', @@ -76,7 +76,7 @@ export const DateTimeInput: FunctionComponent< options, source, resource, - parse = parse, + parse = dateTimeParser, validate, variant = 'filled', ...rest From 1daba3b52a14d91b6e78600c35a65f36103be825 Mon Sep 17 00:00:00 2001 From: asvarcas Date: Mon, 6 Jan 2020 11:17:29 -0300 Subject: [PATCH 3/3] Improve functions naming. --- packages/ra-ui-materialui/src/input/DateTimeInput.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/ra-ui-materialui/src/input/DateTimeInput.tsx b/packages/ra-ui-materialui/src/input/DateTimeInput.tsx index 049f28ca8f5..bd4c17b782c 100644 --- a/packages/ra-ui-materialui/src/input/DateTimeInput.tsx +++ b/packages/ra-ui-materialui/src/input/DateTimeInput.tsx @@ -33,7 +33,7 @@ const dateTimeRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/; * * @param {Date | String} value date string or object */ -const dateTimeFormatter = (value: string | Date) => { +const formatDateTime = (value: string | Date) => { // null, undefined and empty string values should not go through convertDateToString // otherwise, it returns undefined and will make the input an uncontrolled one. if (value == null || value === '') { @@ -58,7 +58,7 @@ const dateTimeFormatter = (value: string | Date) => { * @param {String} value Date string, formatted as yyyy-MM-ddThh:mm * @return {Date} */ -const dateTimeParser = (value: string) => new Date(value); +const parseDateTime = (value: string) => new Date(value); /** * Input component for entering a date and a time with timezone, using the browser locale @@ -66,7 +66,7 @@ const dateTimeParser = (value: string) => new Date(value); export const DateTimeInput: FunctionComponent< InputProps & Omit > = ({ - format = dateTimeFormatter, + format = formatDateTime, label, helperText, margin = 'dense', @@ -76,7 +76,7 @@ export const DateTimeInput: FunctionComponent< options, source, resource, - parse = dateTimeParser, + parse = parseDateTime, validate, variant = 'filled', ...rest