Skip to content

Commit

Permalink
Merge branch 'master' into DHIS2-16318
Browse files Browse the repository at this point in the history
  • Loading branch information
superskip authored Feb 20, 2024
2 parents 0c50e51 + 1e19acd commit 04d88ff
Show file tree
Hide file tree
Showing 15 changed files with 100 additions and 33 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# [100.57.0](https://github.com/dhis2/capture-app/compare/v100.56.0...v100.57.0) (2024-02-19)


### Features

* [DHIS2-16527] assign user on first stage registration ([#3530](https://github.com/dhis2/capture-app/issues/3530)) ([54eef90](https://github.com/dhis2/capture-app/commit/54eef906e5c86ab6d65813c337242ff738882c5b))

# [100.56.0](https://github.com/dhis2/capture-app/compare/v100.55.0...v100.56.0) (2024-02-16)


### Features

* [DHIS2-12007] Text String Improvements ([#3498](https://github.com/dhis2/capture-app/issues/3498)) ([836368a](https://github.com/dhis2/capture-app/commit/836368ae33d191abf209a2813a6a8cbd26107581))

# [100.55.0](https://github.com/dhis2/capture-app/compare/v100.54.0...v100.55.0) (2024-02-05)


Expand Down
6 changes: 3 additions & 3 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ msgstr "Complete event"
msgid "{{ stageName }} - Basic info"
msgstr "{{ stageName }} - Basic info"

msgid "{{ stageName }} - Assignee"
msgstr "{{ stageName }} - Assignee"

msgid "{{ stageName }} - Status"
msgstr "{{ stageName }} - Status"

Expand Down Expand Up @@ -896,9 +899,6 @@ msgstr ""
"Leaving this page will discard any selections you made for a new "
"relationship"

msgid "Feedbacks"
msgstr "Feedbacks"

msgid "Show all events"
msgstr "Show all events"

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "capture-app",
"homepage": ".",
"version": "100.55.0",
"version": "100.57.0",
"cacheVersion": "7",
"serverVersion": "38",
"license": "BSD-3-Clause",
Expand All @@ -10,7 +10,7 @@
"packages/rules-engine"
],
"dependencies": {
"@dhis2/rules-engine-javascript": "100.55.0",
"@dhis2/rules-engine-javascript": "100.57.0",
"@dhis2/app-runtime": "^3.9.3",
"@dhis2/d2-i18n": "^1.1.0",
"@dhis2/d2-icons": "^1.0.1",
Expand All @@ -34,7 +34,7 @@
"leaflet": "^1.7.1",
"leaflet-draw": "^1.0.4",
"lodash": "^4.17.21",
"loglevel": "^1.8.1",
"loglevel": "^1.9.1",
"moment": "^2.29.4",
"prop-types": "^15.8.1",
"query-string": "^7.1.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/rules-engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dhis2/rules-engine-javascript",
"version": "100.55.0",
"version": "100.57.0",
"license": "BSD-3-Clause",
"main": "./build/cjs/index.js",
"scripts": {
Expand All @@ -12,7 +12,7 @@
},
"dependencies": {
"d2-utilizr": "^0.2.15",
"loglevel": "^1.8.0"
"loglevel": "^1.9.1"
},
"module": "./build/es/index.js",
"exports": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow
import i18n from '@dhis2/d2-i18n';
import { DataEntry } from '../../../DataEntry';
import { Assignee } from '../../SingleEventRegistrationEntry/DataEntryWrapper/DataEntry/Assignee';
import {
withInternalChangeHandler,
withLabel,
Expand All @@ -23,6 +24,7 @@ import labelTypeClasses from './fieldLabels.module.css';
import { withCleanUp } from './withCleanUp';
import { getEventDateValidatorContainers } from './fieldValidators/eventDate.validatorContainersGetter';
import { stageMainDataIds } from './getDataEntryPropsToInclude';
import { withTransformPropName } from '../../../../HOC';

const overrideMessagePropNames = {
errorMessage: 'validationError',
Expand Down Expand Up @@ -226,6 +228,36 @@ const getReportDateSettingsFn = () => {
return reportDateSettings;
};

const getAssigneeSettingsFn = () => {
const assigneeComponent =
withTransformPropName(['onBlur', 'onSet'])(
withFocusSaver()(
withFilterProps((props: Object) => {
const defaultFiltred = defaultFilterProps(props);
const { validationAttempted, touched, ...passOnProps } = defaultFiltred;
return passOnProps;
})(Assignee),
),
);

return {
isApplicable: (props: Object) => {
const enableUserAssignment = props.firstStageMetaData && props.firstStageMetaData.stage.enableUserAssignment;
return !!enableUserAssignment;
},
getComponent: () => assigneeComponent,
getComponentProps: (props: Object) => createComponentProps({}, {
orientation: getOrientation(props.formHorizontal),
}),
getPropName: () => 'assignee',
getValidatorContainers: () => [],
getMeta: () => ({
section: sectionKeysForFirstStageDataEntry.ASSIGNEE,
}),
};
};

const StageLocationHOC = withDataEntryFieldIfApplicable(getStageGeometrySettings())(withCleanUp()(DataEntry));
const CompleteHOC = withDataEntryFieldIfApplicable(getCompleteFieldSettingsFn())(StageLocationHOC);
export const FirstStageDataEntry = withDataEntryFieldIfApplicable(getReportDateSettingsFn())(CompleteHOC);
const AssigneeHOC = withDataEntryFieldIfApplicable(getAssigneeSettingsFn())(CompleteHOC);
export const FirstStageDataEntry = withDataEntryFieldIfApplicable(getReportDateSettingsFn())(AssigneeHOC);
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export const sectionKeysForFirstStageDataEntry = {
ENROLLMENT: 'enrollment',
STATUS: 'status',
STAGE_BASIC_INFO: 'stageBasicInfo',
ASSIGNEE: 'assignee',
};
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// @flow
import type { RenderFoundation } from '../../../../metaData';
import type { ProgramStage } from '../../../../metaData';
import { getEventDateValidatorContainers } from './fieldValidators';
import { getConvertGeometryIn, convertGeometryOut, convertStatusIn, convertStatusOut } from '../../converters';

export const stageMainDataIds = {
OCCURRED_AT: 'stageOccurredAt',
COMPLETE: 'stageComplete',
GEOMETRY: 'stageGeometry',
ASSIGNEE: 'assignee',
};

const stageMainDataRulesEngineIds = {
Expand All @@ -17,7 +18,7 @@ const stageMainDataRulesEngineIds = {

export const convertToRulesEngineIds = (id: string) => stageMainDataRulesEngineIds[id];

export const getDataEntryPropsToInclude = (formFoundation: RenderFoundation) => [
export const getDataEntryPropsToInclude = (firstStage: ProgramStage) => [
{
id: stageMainDataIds.OCCURRED_AT,
type: 'DATE',
Expand All @@ -32,8 +33,12 @@ export const getDataEntryPropsToInclude = (formFoundation: RenderFoundation) =>
{
clientId: stageMainDataIds.GEOMETRY,
dataEntryId: stageMainDataIds.GEOMETRY,
onConvertIn: getConvertGeometryIn(formFoundation),
onConvertIn: getConvertGeometryIn(firstStage.stageForm),
onConvertOut: convertGeometryOut,
featureType: formFoundation.featureType,
featureType: firstStage.stageForm.featureType,
},
...(firstStage.enableUserAssignment ? [{
id: stageMainDataIds.ASSIGNEE,
type: 'ASSIGNEE',
}] : []),
];
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ export const useDataEntrySections = (stageName: string, beforeSectionId: string)
beforeSectionId,
placement: placements.BEFORE_METADATA_BASED_SECTION,
},
[sectionKeysForFirstStageDataEntry.ASSIGNEE]: {
placement: placements.BOTTOM,
name: i18n.t('{{ stageName }} - Assignee', {
stageName,
}),
},
[sectionKeysForFirstStageDataEntry.STATUS]: {
placement: placements.BOTTOM,
name: i18n.t('{{ stageName }} - Status', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const openDataEntryForNewEnrollmentBatchAsync = async ({
}) => {
const formId = getDataEntryKey(dataEntryId, itemId);
const addFormDataActions = addFormData(`${dataEntryId}-${itemId}`, formValues);
const firstStageDataEntryPropsToInclude = firstStage && getDataEntryPropsToInclude(firstStage.stageForm);
const firstStageDataEntryPropsToInclude = firstStage && getDataEntryPropsToInclude(firstStage);
const defaultDataEntryValues = { enrolledAt: convertDateObjectToDateFormatString(new Date()) };
const dataEntryPropsToInclude = [
...enrollmentDataEntryPropsToInclude,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const useBuildEnrollmentPayload = ({
dataEntryFieldsMeta,
formFoundation,
);
const { enrolledAt, occurredAt } = serverValuesForMainValues;
const { enrolledAt, occurredAt, assignee } = serverValuesForMainValues;

const { stages } = getTrackerProgramThrowIfNotFound(programId);

Expand All @@ -140,6 +140,7 @@ export const useBuildEnrollmentPayload = ({
currentEventValues,
fieldsValue: dataEntryFieldValues,
attributeCategoryOptions,
assignee,
});

const autoGenerateEvents = deriveAutoGenerateEvents({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const getStyles = () => ({
},
label: {
flexBasis: 200,
fontSize: 14,
paddingLeft: 5,
color: 'rgba(0, 0, 0, 0.87)',
},
field: {
flexBasis: 150,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// @flow
/* eslint-disable no-new-func */
import { convertValue } from '../../../converters/formToClient';
import type { RenderFoundation } from '../../../metaData';

// $FlowSuppress
// $FlowFixMe[prop-missing] automated comment
const getFunctionFromString = (functionAsString: string) => Function(`return ${functionAsString}`)();

Expand All @@ -17,20 +15,21 @@ export function convertDataEntryValuesToClientValues(
}
const eventValues = Object
.keys(dataEntryValues)
// eslint-disable-next-line complexity
.reduce((accEventValues, key) => {
const type = dataEntryValuesMeta[key] && dataEntryValuesMeta[key].type;
const onConvertOut = dataEntryValuesMeta[key] && dataEntryValuesMeta[key].onConvertOut;
const clientIgnore = dataEntryValuesMeta[key] && dataEntryValuesMeta[key].clientIgnore;
const customFeatureType = dataEntryValuesMeta[key] && dataEntryValuesMeta[key].featureType;
const {
type,
onConvertOut,
clientIgnore,
featureType: customFeatureType,
} = dataEntryValuesMeta[key] || {};
if (clientIgnore) {
return accEventValues;
}
if (type) {
const value = dataEntryValues[key];
accEventValues[key] = convertValue(value, type);
} else if (onConvertOut) {
const clientId = dataEntryValuesMeta[key] && dataEntryValuesMeta[key].clientId;
const clientId = dataEntryValuesMeta[key].clientId;
const dataEntryValue = dataEntryValues[key];
const onConvertOutFn = getFunctionFromString(onConvertOut);
accEventValues[clientId] = onConvertOutFn(dataEntryValue, foundation, customFeatureType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ export const deriveFirstStageDuringRegistrationEvent = ({
currentEventValues,
fieldsValue,
attributeCategoryOptions,
assignee,
}: {
firstStageMetadata: ?ProgramStage,
programId: string,
orgUnitId: string,
currentEventValues?: { [id: string]: any },
fieldsValue: { [id: string]: any },
attributeCategoryOptions: { [categoryId: string]: string } | string,
assignee?: ApiAssignedUser,
}) => {
if (!firstStageMetadata) {
return null;
Expand All @@ -32,7 +34,7 @@ export const deriveFirstStageDuringRegistrationEvent = ({
? { attributeCategoryOptions: convertCategoryOptionsToServer(attributeCategoryOptions) }
: {};

const event = {
const event: any = {
status: convertStatusOut(stageComplete),
geometry: standardGeoJson(stageGeometry),
occurredAt: convertFn(stageOccurredAt, dataElementTypes.DATE),
Expand All @@ -49,7 +51,11 @@ export const deriveFirstStageDuringRegistrationEvent = ({
}, []) : undefined;

if (dataValues) {
return { ...event, dataValues };
event.dataValues = dataValues;
}

if (assignee) {
event.assignedUser = assignee;
}
return event;
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Props = {
feedbacks: ?{ displayTexts: ?Array<string>, displayKeyValuePairs: ?Array<{ key: string, value: string }>},
}

const headerText = i18n.t('Feedbacks');
const headerText = i18n.t('Feedback');

const getStyles = (theme: Theme) => ({
badge: {
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13788,10 +13788,10 @@ log-update@^4.0.0:
slice-ansi "^4.0.0"
wrap-ansi "^6.2.0"

loglevel@^1.4.0, loglevel@^1.6.8, loglevel@^1.8.0, loglevel@^1.8.1:
version "1.8.1"
resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.8.1.tgz#5c621f83d5b48c54ae93b6156353f555963377b4"
integrity sha512-tCRIJM51SHjAayKwC+QAg8hT8vg6z7GSgLJKGvzuPb1Wc+hLzqtuVLxp6/HzSPOozuK+8ErAhy7U/sVzw8Dgfg==
loglevel@^1.4.0, loglevel@^1.6.8, loglevel@^1.9.1:
version "1.9.1"
resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.9.1.tgz#d63976ac9bcd03c7c873116d41c2a85bafff1be7"
integrity sha512-hP3I3kCrDIMuRwAwHltphhDM1r8i55H33GgqjXbrisuJhF4kRhW1dNuxsRklp4bXl8DSdLaNLuiL4A/LWRfxvg==

loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.2.0, loose-envify@^1.3.1, loose-envify@^1.4.0:
version "1.4.0"
Expand Down Expand Up @@ -19820,9 +19820,9 @@ undici-types@~5.26.4:
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==

undici@^5.25.4:
version "5.28.2"
resolved "https://registry.yarnpkg.com/undici/-/undici-5.28.2.tgz#fea200eac65fc7ecaff80a023d1a0543423b4c91"
integrity sha512-wh1pHJHnUeQV5Xa8/kyQhO7WFa8M34l026L5P/+2TYiakvGy5Rdc8jWZVyG7ieht/0WgJLEd3kcU5gKx+6GC8w==
version "5.28.3"
resolved "https://registry.yarnpkg.com/undici/-/undici-5.28.3.tgz#a731e0eff2c3fcfd41c1169a869062be222d1e5b"
integrity sha512-3ItfzbrhDlINjaP0duwnNsKpDQk3acHI3gVJ1z4fmwMK31k5G9OVIAMLSIaP6w4FaGkaAkN6zaQO9LUvZ1t7VA==
dependencies:
"@fastify/busboy" "^2.0.0"

Expand Down

0 comments on commit 04d88ff

Please sign in to comment.