diff --git a/src/components/Dashboard/common/SimpleDateTimePropertyFilter.jsx b/src/components/Dashboard/common/SimpleDateTimePropertyFilter.jsx index 397971de..c3489007 100644 --- a/src/components/Dashboard/common/SimpleDateTimePropertyFilter.jsx +++ b/src/components/Dashboard/common/SimpleDateTimePropertyFilter.jsx @@ -4,6 +4,7 @@ import PropTypes from 'prop-types' import dayjs from 'dayjs' import { ApiServerContext } from '../context/ApiServerContext' import { LoadingOutlined, CaretDownOutlined } from '@ant-design/icons' +import MissingPlaceholder from './MissingPlaceholder' import { matchesFilterExpression, valuesToExpression @@ -414,6 +415,13 @@ const expandKeysForChecked = (keys, nodeByKey) => { const EMPTY_OBJECT = {} +const omitUndefinedValues = (obj) => + Object.fromEntries( + Object.entries(obj || {}).filter( + ([, value]) => value !== undefined && value !== '' + ) + ) + const stableStringify = (value) => { if (Array.isArray(value)) { return `[${value.map(stableStringify).join(',')}]` @@ -445,16 +453,19 @@ const SimpleDateTimePropertyFilter = ({ getModelPropertyValuesRef.current = getModelPropertyValues const [dates, setDates] = useState([]) - const [loading, setLoading] = useState(false) + const [loading, setLoading] = useState(() => visible) const [localChecked, setLocalChecked] = useState(null) const filterForValues = useMemo(() => { - const next = { ...(filter || {}) } + const next = omitUndefinedValues(filter) if (propertyName) delete next[propertyName] return next }, [filter, propertyName]) - const masterFilterForValues = masterFilter || EMPTY_OBJECT + const masterFilterForValues = useMemo( + () => omitUndefinedValues(masterFilter), + [masterFilter] + ) const filterHash = useMemo( () => getFilterHash(filterForValues, masterFilterForValues), @@ -648,6 +659,17 @@ const SimpleDateTimePropertyFilter = ({ ) } + if (!loading && treeData.length === 0) { + return ( + + ) + } + return ( }> {treeData.length > 0 ? (