Skip to content

Commit 20554e5

Browse files
feat: use configured TEA Search Operators in the Search page
1 parent d9525a9 commit 20554e5

File tree

28 files changed

+303
-46
lines changed

28 files changed

+303
-46
lines changed

i18n/en.pot

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ msgstr ""
55
"Content-Type: text/plain; charset=utf-8\n"
66
"Content-Transfer-Encoding: 8bit\n"
77
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
8-
"POT-Creation-Date: 2025-10-23T11:41:11.943Z\n"
9-
"PO-Revision-Date: 2025-10-23T11:41:11.943Z\n"
8+
"POT-Creation-Date: 2025-12-02T08:24:37.493Z\n"
9+
"PO-Revision-Date: 2025-12-02T08:24:37.493Z\n"
1010

1111
msgid "Choose one or more dates..."
1212
msgstr "Choose one or more dates..."
@@ -534,6 +534,15 @@ msgstr "Clear"
534534
msgid "No results"
535535
msgstr "No results"
536536

537+
msgid "Exact matches only"
538+
msgstr "Exact matches only"
539+
540+
msgid "Must match the start of the value"
541+
msgstr "Must match the start of the value"
542+
543+
msgid "Must match the end of the value"
544+
msgstr "Must match the end of the value"
545+
537546
msgid "Description"
538547
msgstr "Description"
539548

@@ -2138,7 +2147,7 @@ msgid ""
21382147
"The following attribute type is not supported for searching and has been "
21392148
"hidden"
21402149
msgid_plural ""
2141-
"The following attribute types is not supported for searching and has been "
2150+
"The following attribute type is not supported for searching and has been "
21422151
"hidden"
21432152
msgstr[0] ""
21442153
"The following attribute type is not supported for searching and has been "

src/core_modules/capture-core/components/D2Form/field/Components/AgeField/AgeFieldForForm.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
withDisplayMessages,
1111
withFilterProps,
1212
withInternalChangeHandler,
13+
withSearchHelpMessage,
1314
} from '../../../../FormFields/New';
1415
import {
1516
withRequiredFieldCalculation,
@@ -36,8 +37,10 @@ export const AgeFieldForForm = withGotoInterface()(
3637
`${props.fieldLabelMediaBasedClass} ${labelTypeClasses.ageLabel}`,
3738
})(
3839
withDisplayMessages()(
39-
withFilterProps(getFilteredProps)(
40-
withInternalChangeHandler()(AgeField),
40+
withSearchHelpMessage()(
41+
withFilterProps(getFilteredProps)(
42+
withInternalChangeHandler()(AgeField),
43+
),
4144
),
4245
),
4346
),

src/core_modules/capture-core/components/D2Form/field/Components/BooleanField/BooleanFieldForForm.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
withLabel,
1010
withDisplayMessages,
1111
withFilterProps,
12+
withSearchHelpMessage,
1213
} from '../../../../FormFields/New';
1314
import {
1415
withRequiredFieldCalculation,
@@ -35,7 +36,9 @@ export const BooleanFieldForForm = withGotoInterface()(
3536
`${props.fieldLabelMediaBasedClass} ${labelTypeClasses.booleanLabel}`,
3637
})(
3738
withFilterProps(getFilteredProps)(
38-
withDisplayMessages()(BooleanField),
39+
withDisplayMessages()(
40+
withSearchHelpMessage()(BooleanField),
41+
),
3942
),
4043
),
4144
),

src/core_modules/capture-core/components/D2Form/field/Components/OptionSetField/OptionSetSelectFieldForForm.component.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
withDisplayMessages,
1212
withFilterProps,
1313
withOptionsIconElement,
14+
withSearchHelpMessage,
1415
} from '../../../../FormFields/New';
1516
import {
1617
withRequiredFieldCalculation,
@@ -38,10 +39,12 @@ export const OptionSetSelectFieldForForm = withGotoInterface()(
3839
`${props.fieldLabelMediaBasedClass} ${labelTypeClasses.textLabel}`,
3940
})(
4041
withDisplayMessages()(
41-
withOptionsIconElement()(
42-
withRulesOptionVisibilityHandler()(
43-
withFilterProps(getFilteredProps)(
44-
withSelectTranslations()(VirtualizedSelectField),
42+
withSearchHelpMessage()(
43+
withOptionsIconElement()(
44+
withRulesOptionVisibilityHandler()(
45+
withFilterProps(getFilteredProps)(
46+
withSelectTranslations()(VirtualizedSelectField),
47+
),
4548
),
4649
),
4750
),

src/core_modules/capture-core/components/D2Form/field/Components/OrgUnitField/OrgUnitFieldForForm.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
withInternalChangeHandler,
1010
withFilterProps,
1111
SingleOrgUnitSelectField,
12+
withSearchHelpMessage,
1213
} from '../../../../FormFields/New';
1314
import {
1415
withRequiredFieldCalculation,
@@ -36,9 +37,11 @@ export const OrgUnitFieldForForm = withGotoInterface()(
3637
})(
3738
withFilterProps(getFilteredProps)(
3839
withDisplayMessages()(
39-
withInternalChangeHandler()(
40-
withFormFieldOrgUnitsHandler()(
41-
SingleOrgUnitSelectField,
40+
withSearchHelpMessage()(
41+
withInternalChangeHandler()(
42+
withFormFieldOrgUnitsHandler()(
43+
SingleOrgUnitSelectField,
44+
),
4245
),
4346
),
4447
),

src/core_modules/capture-core/components/D2Form/field/Components/TextField/TextFieldForForm.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
withDefaultFieldContainer,
99
withLabel,
1010
withDisplayMessages,
11+
withSearchHelpMessage,
1112
withInternalChangeHandler,
1213
withFilterProps,
1314
} from '../../../../FormFields/New';
@@ -37,7 +38,9 @@ export const TextFieldForForm = withGotoInterface()(
3738
})(
3839
withFilterProps(getFilteredProps)(
3940
withDisplayMessages()(
40-
withInternalChangeHandler()(TextField),
41+
withSearchHelpMessage()(
42+
withInternalChangeHandler()(TextField),
43+
),
4144
),
4245
),
4346
),

src/core_modules/capture-core/components/D2Form/field/Components/TrueOnlyField/TrueOnlyFieldForForm.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
withLabel,
1010
withDisplayMessages,
1111
withFilterProps,
12+
withSearchHelpMessage,
1213
} from '../../../../FormFields/New';
1314
import {
1415
withRequiredFieldCalculation,
@@ -35,7 +36,9 @@ export const TrueOnlyFieldForForm = withGotoInterface()(
3536
`${props.fieldLabelMediaBasedClass} ${labelTypeClasses.trueOnlyLabel}`,
3637
})(
3738
withFilterProps(getFilteredProps)(
38-
withDisplayMessages()(TrueOnlyField),
39+
withDisplayMessages()(
40+
withSearchHelpMessage()(TrueOnlyField),
41+
),
3942
),
4043
),
4144
),

src/core_modules/capture-core/components/D2Form/field/Components/UserNameField/UserNameFieldForForm.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
withDisplayMessages,
1111
withFilterProps,
1212
withInternalChangeHandler,
13+
withSearchHelpMessage,
1314
} from '../../../../FormFields/New';
1415
import {
1516
withRequiredFieldCalculation,
@@ -37,9 +38,11 @@ export const UserNameFieldForForm = withGotoInterface()(
3738
`${props.fieldLabelMediaBasedClass} ${labelTypeClasses.textLabel}`,
3839
})(
3940
withDisplayMessages()(
40-
withFilterProps(getFilteredProps)(
41-
withTransformPropName(['onBlur', 'onSet'])(
42-
withInternalChangeHandler()(UserField),
41+
withSearchHelpMessage()(
42+
withFilterProps(getFilteredProps)(
43+
withTransformPropName(['onBlur', 'onSet'])(
44+
withInternalChangeHandler()(UserField),
45+
),
4346
),
4447
),
4548
),

src/core_modules/capture-core/components/D2Form/field/configs/base/configBaseDefaultForm.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ const baseComponentStylesVertical = {
2424
},
2525
};
2626

27-
const getBaseProps = ({ formName, compulsory, disabled, unique, icon, description, url }: DataElement) => ({
27+
const getBaseProps = ({ formName, compulsory, disabled, unique, icon, description, url, searchOperator }: DataElement) => ({
2828
description,
2929
url,
3030
styles: baseComponentStyles,
3131
label: formName,
3232
metaCompulsory: compulsory,
3333
metaDisabled: disabled || (unique && unique.generatable),
34+
searchOperator,
3435
icon: icon ? {
3536
name: icon.name,
3637
color: icon.color,
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import * as React from 'react';
2+
import i18n from '@dhis2/d2-i18n';
3+
import { colors } from '@dhis2/ui';
4+
import { withStyles, WithStyles } from '@material-ui/core/styles';
5+
6+
const styles = (theme: any) => ({
7+
help: {
8+
marginLeft: 0,
9+
paddingLeft: 0,
10+
color: colors.grey700,
11+
fontSize: theme.typography.pxToRem(14),
12+
},
13+
});
14+
15+
type Props = {
16+
searchOperator?: string;
17+
};
18+
19+
const helpTexts = {
20+
EQ: i18n.t('Exact matches only'),
21+
SW: i18n.t('Must match the start of the value'),
22+
EW: i18n.t('Must match the end of the value'),
23+
};
24+
25+
const getSearchHelpMessageHOC = <P extends Record<string, any>>(InnerComponent: React.ComponentType<P>) =>
26+
class DisplayMessagesHOC extends React.Component<P & Props & WithStyles<typeof styles>> {
27+
render() {
28+
const { classes, searchOperator, ...passOnProps } = this.props;
29+
const helpText = searchOperator && helpTexts[searchOperator];
30+
31+
return (
32+
<>
33+
<InnerComponent {...passOnProps as unknown as P} />
34+
{helpText && <div className={classes.help}>
35+
{helpText} <br />
36+
</div>
37+
}
38+
</>
39+
);
40+
}
41+
};
42+
43+
export const withSearchHelpMessage = () => <P extends Record<string, any>>(InnerComponent: React.ComponentType<P>) =>
44+
withStyles(styles)(getSearchHelpMessageHOC(InnerComponent) as any);

0 commit comments

Comments
 (0)