Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
786eaf9
fix: add collapsed org unit selection components
henrikmv Jun 26, 2026
33fc96e
fix: remove CollapsedOrgUnitSelectField component
henrikmv Jun 26, 2026
0cffa0d
fix: (review) devin comment
henrikmv Jun 26, 2026
eaabf13
fix: (review) add collapsed property to organisation unit settings in…
henrikmv Jun 26, 2026
739fa65
fix: remove collapsed property from organisation unit settings in var…
henrikmv Jun 26, 2026
18cec80
fix: enhance SingleOrgUnitSelectField with debounced search input and…
henrikmv Jun 27, 2026
e4ce807
fix: update keyboard event handling to close menu only when open
henrikmv Jun 27, 2026
3a8162f
fix: sonar qube
henrikmv Jun 27, 2026
ac8918c
fix: sonar qube final
henrikmv Jun 27, 2026
06a03e9
fix: remove aria expanded attribute from organisation unit selector
henrikmv Jun 27, 2026
1711476
fix: update click handling to open menu on trigger click
henrikmv Jun 30, 2026
42b7747
fix: clean up styles
henrikmv Jun 30, 2026
02d0b42
fix: update cypress organisation unit filter interaction in event and…
henrikmv Jun 30, 2026
a5d1eab
fix: update cypress organisation unit selection process in scheduling…
henrikmv Jun 30, 2026
4b81008
Merge branch 'master' into hv/fix/DHIS2-21708_expanded-org-unit-selector
henrikmv Jul 1, 2026
b4e734c
Merge branch 'master' into hv/fix/DHIS2-21708_expanded-org-unit-selector
henrikmv Jul 2, 2026
5376619
feat: add auto select functionality for single organization unit fields
henrikmv Jul 3, 2026
18990d2
feat: add auto select option for single organisation unit fields
henrikmv Jul 3, 2026
6887c72
feat: add fieldOptions prop and handle preselection in OrgUnitFilterM…
henrikmv Jul 3, 2026
aedde44
feat: enhance organization unit selection logic and state management
henrikmv Jul 3, 2026
378e6b0
fix: revert pot
henrikmv Jul 3, 2026
ae103c3
fix. clean up
henrikmv Jul 3, 2026
618a740
Merge branch 'master' into hv/fix/DHIS2-21708_expanded-org-unit-selector
henrikmv Jul 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions cypress/e2e/RelatedStages/RelatedStages.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,19 @@ And('you open the Birth new event page and fill in the required data in the form

When('you fill in the required values for the Baby postnatal event when scheduling', () => {
cy.get('[data-test="related-stages-section"]')
.within(() => {
cy.get('input[type="text"]')
.eq(0)
.type(`${getCurrentYear()}-08-01`)
.blur();

cy.get('input[type="text"]')
.eq(1)
.type('Barmoi CH');
.find('input[type="text"]')
.eq(0)
.type(`${getCurrentYear()}-08-01`)
.blur();

cy.contains('Barmoi CHP')
.click();
});
cy.get('[data-test="related-stages-section"]')
.find('[data-test="org-unit-selector-trigger"]')
.click();
cy.get('input[placeholder="Search for an organisation unit"]').type('Barmoi CH', { force: true });
cy.get('[data-test="dhis2-uicore-popover"]').last().within(() => {
cy.get('[data-test="dhis2-uicore-circularloader"]').should('not.exist');
cy.contains('Barmoi CHP').click();
});
});

And('you click the Schedule action button', () => {
Expand All @@ -148,14 +148,13 @@ And('you click the Schedule action button', () => {

When('you fill in the required values for the Baby postnatal event when entering details', () => {
cy.get('[data-test="related-stages-section"]')
.within(() => {
cy.get('input[type="text"]')
.eq(0)
.type('Barmoi CH');

cy.contains('Barmoi CHP')
.click();
});
.find('[data-test="org-unit-selector-trigger"]')
.click();
cy.get('input[placeholder="Search for an organisation unit"]').type('Barmoi CH', { force: true });
cy.get('[data-test="dhis2-uicore-popover"]').last().within(() => {
cy.get('[data-test="dhis2-uicore-circularloader"]').should('not.exist');
cy.contains('Barmoi CHP').click();
});
});

And('you click the Enter details action button', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,9 @@ When('you set the date filter', () => {
When('you set the organisation unit filter', () => {
cy.get('[data-test="event-working-lists"]').within(() => cy.contains('More filters').click());
cy.get('[data-test="more-filters-menu"]').within(() => cy.contains('Place of Infection').click());
cy.get('[data-test="list-view-filter-contents"]').within(() => {
cy.get('input[placeholder="Search"]').type('Ngelehun');
cy.get('[data-test="org-unit-selector-trigger"]').click();
cy.get('input[placeholder="Search for an organisation unit"]').type('Ngelehun', { force: true });
cy.get('[data-test="dhis2-uicore-popover"]').last().within(() => {
cy.get('[data-test="dhis2-uicore-circularloader"]').should('not.exist');
cy.contains('Ngelehun').click();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,9 @@ When(/^you set the option filter "([^"]+)" to (Yes|No)$/, (filterName, value) =>
When(/^you set the program stage organisation unit filter "([^"]+)" to "([^"]+)"$/, (filterName, searchTerm) => {
cy.get('[data-test="tracker-working-lists"]').within(() => cy.get('[data-test="more-filters"]').eq(1).click());
cy.get('[data-test="more-filters-menu"]').within(() => cy.contains(filterName).click());
cy.get('[data-test="list-view-filter-contents"]').within(() => {
cy.get('input[placeholder="Search"]').type(searchTerm);
cy.get('[data-test="org-unit-selector-trigger"]').click();
cy.get('input[placeholder="Search for an organisation unit"]').type(searchTerm, { force: true });
cy.get('[data-test="dhis2-uicore-popover"]').last().within(() => {
cy.get('[data-test="dhis2-uicore-circularloader"]').should('not.exist');
cy.contains(searchTerm).click();
});
Expand Down
7 changes: 5 additions & 2 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2026-07-02T15:31:30.388Z\n"
"PO-Revision-Date: 2026-07-02T15:31:30.388Z\n"
"POT-Creation-Date: 2026-07-03T11:46:01.593Z\n"
"PO-Revision-Date: 2026-07-03T11:46:01.594Z\n"

msgid "The application could not be loaded."
msgstr "The application could not be loaded."
Expand Down Expand Up @@ -593,6 +593,9 @@ msgstr "Type to filter options"
msgid "No match found"
msgstr "No match found"

msgid "Search for an organisation unit"
msgstr "Search for an organisation unit"

msgid "Clear"
msgstr "Clear"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ export class FormBuilder extends React.Component<Props> {
.promise
.then((validationContainerArray) => {
const validationContainers = validationContainerArray
.filter(container => !this.commitUpdateTriggeredForFields[container.id])
.reduce((accFieldsUI, container) => {
accFieldsUI[container.id] = container.validationData;
return accFieldsUI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const getOrgUnitFieldConfig = (metaData: MetaDataElement, options: any, q
formHorizontal: options.formHorizontal,
fieldLabelMediaBasedClass: options.fieldLabelMediaBasedClass,
maxTreeHeight: 200,
autoSelectSingleOrgUnit: options.autoSelectSingleOrgUnit ?? !!metaData.compulsory,
}, options, metaData);

return createFieldConfig({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export type DataEntryOutputProps = {
orgUnitId?: string,
pluginContext?: PluginContext,
viewMode?: boolean,
fieldOptions?: Record<string, any>,
};

type OwnProps = DataEntryOutputProps & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class OrgUnitFilter extends Component<OrgUnitFilterProps> implements Upda
value={filteredValue != null && typeof filteredValue === 'object' ? filteredValue : undefined}
onBlur={this.handleOrgUnitChange}
maxTreeHeight={280}
autoSelectSingleOrgUnit={false}
/>
)}
</WithEmptyValueFilter>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,35 @@
import * as React from 'react';
import React, { useState } from 'react';
import { OrgUnitFilter as OrgUnitFilterInput } from './OrgUnitFilter.component';
import { getEmptyValueFilterValue, isEmptyFilterData } from '../EmptyValue';
import type { OrgUnitFilter, OrgUnitFilterManagerProps, Value } from './orgUnit.types';

type State = {
value: Value;
};

export class OrgUnitFilterManager extends React.Component<OrgUnitFilterManagerProps, State> {
static calculateDefaultState(filter: OrgUnitFilter | null | undefined): State {
if (!filter) return { value: undefined };
if (isEmptyFilterData(filter)) return { value: getEmptyValueFilterValue(filter) };
const calculateInitialValue = (filter: OrgUnitFilter | null | undefined): Value => {
if (!filter) return undefined;
if (isEmptyFilterData(filter)) return getEmptyValueFilterValue(filter);

const { value, name } = filter;
return { value: { id: value, name: name ?? value, path: '' } };
}
const { value, name } = filter;
return { id: value, name: name ?? value, path: '' };
};

constructor(props: OrgUnitFilterManagerProps) {
super(props);
this.state = OrgUnitFilterManager.calculateDefaultState(this.props.filter);
}
export const OrgUnitFilterManager = ({
filter,
filterTypeRef,
handleCommitValue,
...passOnProps
}: OrgUnitFilterManagerProps) => {
const [value, setValue] = useState<Value>(() => calculateInitialValue(filter));

handleCommitValue = (value: Value) => {
this.setState({ value });
this.props.handleCommitValue?.();
const onCommitValue = (newValue: Value) => {
setValue(newValue);
handleCommitValue?.();
};

render() {
const { filter, filterTypeRef, ...passOnProps } = this.props;
return (
<OrgUnitFilterInput
value={this.state.value}
ref={filterTypeRef}
onCommitValue={this.handleCommitValue}
{...passOnProps}
/>
);
}
}
return (
<OrgUnitFilterInput
value={value}
ref={filterTypeRef}
onCommitValue={onCommitValue}
{...passOnProps}
/>
);
};
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type OrgUnitFieldProps = {
disabled?: boolean;
previousOrgUnitId?: string;
dataTest?: string;
hideSearchField?: boolean;
searchText?: string;
};

type Props = OrgUnitFieldProps & WithStyles<typeof getStyles>;
Expand All @@ -60,8 +62,11 @@ const OrgUnitFieldPlain = (props: Props) => {
disabled,
previousOrgUnitId,
dataTest,
hideSearchField,
searchText: externalSearchText,
} = props;
const [searchText, setSearchText] = React.useState<string | undefined>(undefined);
const [internalSearchText, setInternalSearchText] = React.useState<string | undefined>(undefined);
const searchText = hideSearchField ? externalSearchText : internalSearchText;
const [key, setKey] = React.useState<string | undefined>(undefined);

const initialRoots = React.useMemo(() => CurrentUser.get().organisationUnits, []);
Expand Down Expand Up @@ -117,7 +122,7 @@ const OrgUnitFieldPlain = (props: Props) => {
};

const handleFilterChange = (event: React.SyntheticEvent<HTMLInputElement>) => {
setSearchText(event.currentTarget.value);
setInternalSearchText(event.currentTarget.value);
};

const handleBlur = () => {
Expand All @@ -131,6 +136,7 @@ const OrgUnitFieldPlain = (props: Props) => {
className={classes.container}
onBlur={handleBlur}
>
{!hideSearchField &&
<div className={classes.debounceFieldContainer}>
<DebounceField
onDebounced={handleFilterChange}
Expand All @@ -141,6 +147,7 @@ const OrgUnitFieldPlain = (props: Props) => {
dataTest={dataTest}
/>
</div>
}
{!disabled &&
<div className={classes.orgUnitTreeContainer} style={styles}>
{renderOrgUnitTree()}
Expand Down
Loading
Loading