diff --git a/web/client/components/data/featuregrid/filterRenderers/DateTimeFilter.jsx b/web/client/components/data/featuregrid/filterRenderers/DateTimeFilter.jsx index 1da95d6a54..591245f0f7 100644 --- a/web/client/components/data/featuregrid/filterRenderers/DateTimeFilter.jsx +++ b/web/client/components/data/featuregrid/filterRenderers/DateTimeFilter.jsx @@ -33,7 +33,7 @@ export default compose( type: props.type, attribute }); - } else { + } else if (value && typeof value === 'object') { props.onValueChange(value); props.onChange({ value: { startDate: value?.startDate, endDate: value?.endDate, operator: inputOperator }, @@ -41,6 +41,14 @@ export default compose( type: props.type, attribute }); + } else if (!value) { + props.onValueChange(value); + props.onChange({ + value: { startDate: value, operator: inputOperator }, + operator: inputOperator, + type: props.type, + attribute + }); } } }), diff --git a/web/client/components/misc/datetimepicker/DateTimePicker.js b/web/client/components/misc/datetimepicker/DateTimePicker.js index 301b0c2add..d3db4eae61 100644 --- a/web/client/components/misc/datetimepicker/DateTimePicker.js +++ b/web/client/components/misc/datetimepicker/DateTimePicker.js @@ -17,6 +17,7 @@ import { isDate, isNil, omit } from 'lodash'; import OverlayTrigger from '../OverlayTrigger'; import Hours from './Hours'; import Popover from '../../styleeditor/Popover'; +import {getMessageById} from '../../../utils/LocaleUtils'; localizer(moment); @@ -70,7 +71,10 @@ class DateTimePicker extends Component { options: PropTypes.object, isWithinAttrTbl: PropTypes.bool } - + static contextTypes = { + messages: PropTypes.object, + locale: PropTypes.string + }; static defaultProps = { placeholder: 'Type date...', calendar: true, @@ -98,7 +102,7 @@ class DateTimePicker extends Component { if (prevProps.value !== this.props.value || prevProps.operator !== this.props.operator) { const { value, operator } = this.props; this.setDateFromValueProp(value, operator); - if (this.props.operator === 'isNull') this.setState({ inputValue: '' }); + if (this.props.operator === 'isNull') this.setState({ inputValue: '', date: null }); } } @@ -109,14 +113,15 @@ class DateTimePicker extends Component { } renderCustomDateTimePopup = () => { const { inputValue, operator, open } = this.state; - const { placeholder, tabIndex, type } = this.props; + const { tabIndex, type } = this.props; const timeVisible = open === 'time'; const props = omit(this.props, ['placeholder', 'calendar', 'time', 'onChange', 'value']); - let calendarVal; + let calendarVal = null; if ( this.props.value && typeof this.props.value === 'object') { - calendarVal = this.props.value?.startDate || this.props.value; + calendarVal = this.props.value?.startDate; } else if (this.props.value && typeof this.props.value === 'string') calendarVal = this.props.value; + let timePlaceholderMsgId = getMessageById(this.context.messages, "featuregrid.attributeFilter.placeholders.time"); return (