diff --git a/library/src/components/List/Filter/ContentFilterSelector/ContentFilterRow.tsx b/library/src/components/List/Filter/ContentFilterSelector/ContentFilterRow.tsx index 4fafcf4..fb24418 100644 --- a/library/src/components/List/Filter/ContentFilterSelector/ContentFilterRow.tsx +++ b/library/src/components/List/Filter/ContentFilterSelector/ContentFilterRow.tsx @@ -10,6 +10,7 @@ import { NullablePropertyFkChoices } from '../../../../entities'; import { PropertyList, isPropertyFk, + isPropertyScalar, } from '../../../../services/api/ParsedApiSpecInterface'; import { DropdownChoices, @@ -80,6 +81,7 @@ export default function ContentFilterRow( }, [row]); const column = columns[name]; + let enumValue: DropdownChoices | null = null; if (isPropertyFk(column)) { enumValue = fkChoices[name] || {}; @@ -92,6 +94,17 @@ export default function ContentFilterRow( }; } + const columnFormat = isPropertyScalar(column) && column.format; + let textFieldInputType = 'text'; + const inputProps: Record = {}; + + switch (columnFormat) { + case 'date-time': + textFieldInputType = 'datetime-local'; + inputProps.step = 1; + break; + } + const updateCriteria = () => { setRow(idx, name, type, value); }; @@ -149,14 +162,19 @@ export default function ContentFilterRow( { - setValue(target.value); + let { value } = target; + if (textFieldInputType === 'datetime-local') { + value = value.replace('T', ' '); + } + + setValue(value); }} /> )} diff --git a/library/src/components/List/Filter/ContentFilterSelector/ContentFilterSelector.styles.tsx b/library/src/components/List/Filter/ContentFilterSelector/ContentFilterSelector.styles.tsx index feaae3d..72bfc4e 100644 --- a/library/src/components/List/Filter/ContentFilterSelector/ContentFilterSelector.styles.tsx +++ b/library/src/components/List/Filter/ContentFilterSelector/ContentFilterSelector.styles.tsx @@ -8,7 +8,7 @@ export const StyledContentFilterSelector = styled(ContentFilterSelector)( flexDirection: 'column', gap: 'var(--spacing-xl)', padding: 'var(--spacing-lg)', - width: '700px', + width: '735px', maxWidth: '100%', [theme.breakpoints.down('md')]: { width: '320px', diff --git a/library/src/entities/DefaultEntityBehavior/ListDecorator.tsx b/library/src/entities/DefaultEntityBehavior/ListDecorator.tsx index da6cabe..787dd90 100644 --- a/library/src/entities/DefaultEntityBehavior/ListDecorator.tsx +++ b/library/src/entities/DefaultEntityBehavior/ListDecorator.tsx @@ -58,6 +58,10 @@ const ListDecorator: ListDecoratorType = (props) => { return value?.substring(0, 10) || ''; } + if (isPropertyScalar(property) && property.format === 'date-time') { + return value ? new Date(value).toLocaleString() : ''; + } + if (!value && property.null) { value = property.null; }