feat: [DHIS2-19940] Implement the "No value" filtering component for all filter types in the working list#4468
Conversation
Add EmptyValueFilterCheckboxes to DateTime, Time, Boolean, TrueOnly, OptionSet, Assignee, OrgUnit, and Username filters following the existing Text filter pattern. Each filter type now: - Renders isEmpty/isNotEmpty checkboxes at the top - Handles isEmpty string values in data getters - Converts isEmpty flags back to string values in managers - Supports isEmpty display in button text converters Also removes console.log from numericConverter and adds centralized isEmpty handling in buildButtonText. Co-Authored-By: henrik.vadet@dhis2.org <henrik@devOtta.no>
|
There was a problem hiding this comment.
🟡 DateTimeFilter.getDateLogicError() shows spurious error when empty value filter is selected after a failed submit
When value is a string (an empty value filter like 'EMPTY_VALUE_FILTER'), getDateLogicError() at DateTimeFilter.component.tsx:155-169 accesses value?.from and value?.to, which return undefined on a string primitive. If submitAttempted was set to true by a prior failed validation (e.g., the user entered an invalid date range where from > to, clicked Update, then selected the "Is empty" checkbox), the condition !from?.date && !to?.date evaluates to true and the method returns i18n.t('Please specify a date'), showing an incorrect error message alongside the empty value filter selection.
Other filters handle this correctly: TimeFilter.getTimeLogicError() has typeof values === 'string' guard (TimeFilter.component.tsx:163), NumericFilter.getErrors() has typeof committed === 'string' guard (NumericFilter.component.tsx:194-196), and DateFilter.getErrors() is safe because mainValue resolves to undefined which doesn't match any range option.
(Refers to lines 155-169)
Was this helpful? React with 👍 or 👎 to provide feedback.




DHIS2-19940
Summary
Extends the existing "No value" (isEmpty) filtering — previously only available for Text and Numeric filters — to all remaining filter types in the working list:
Each filter type follows the same pattern established by the Text filter:
EmptyValueFilterCheckboxesrendered at the top of the filter UImakeCheckboxHandlerfrom the sharedEmptyValuemoduleisEmptyflag and display labelcalculateDefaultStateconvertsisEmpty: true/falseback to the corresponding string constants when restoring filter stateisEmptypropertyAdditionally:
buildButtonTextso all filter types are coveredconsole.logfromnumericConverternumericConverterimplementationReview & Testing Checklist for Human
orgUnitConverterchange: non-isEmpty path changed fromreturn filter.valuetoreturn filter.name ?? filter.value— verify this doesn't break existing org unit filter button textnumericConverterrewrite: the function was refactored beyond the console.log removal — verify edge cases (e.g.,ge === 0,le === 0) still display correctlybooleanConvertertype change: type annotation changed fromBooleanFilterDatatoany— consider whether a union type would be more appropriateSuggested Test Plan
Notes
@emotion/csslint error inTimeFilter.component.tsxis pre-existing and unrelated to this PR