Skip to content

Commit

Permalink
Merge branch 'master' into DHIS2-17854
Browse files Browse the repository at this point in the history
  • Loading branch information
simonadomnisoru committed Nov 6, 2024
2 parents 44990c1 + bc2b962 commit 3b0a8fb
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 72 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [101.14.8](https://github.com/dhis2/capture-app/compare/v101.14.7...v101.14.8) (2024-11-05)


### Bug Fixes

* [DHIS2-18278] remove completedAt and completedBy from the payload send to the API ([#3873](https://github.com/dhis2/capture-app/issues/3873)) ([156369a](https://github.com/dhis2/capture-app/commit/156369abe3dced63c773900acbc3f11f82d57723))

## [101.14.7](https://github.com/dhis2/capture-app/compare/v101.14.6...v101.14.7) (2024-11-04)


### Bug Fixes

* [DHIS2-17135][DHIS2-17018] Adjust strings for error messages ([#3858](https://github.com/dhis2/capture-app/issues/3858)) ([1d9ae57](https://github.com/dhis2/capture-app/commit/1d9ae5731331d3f19a0980cf09ebdd9cc46e4583))

## [101.14.6](https://github.com/dhis2/capture-app/compare/v101.14.5...v101.14.6) (2024-11-03)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const changeEnrollmentAndEventsStatus = () => (
const enrollment = body.enrollments && body.enrollments.find(e => e.enrollment === 'FZAa7j0muDj');
const eventToDelete = enrollment.events.find(e => e.programStage === 'eHvTba5ijAh');
const { events, ...rest } = enrollment;
const enrollmentToUpdate = { ...rest, status: 'ACTIVE' };
const enrollmentToUpdate = { ...rest, status: 'ACTIVE', completedAt: null, completedBy: null };

return cy
.buildApiUrl('tracker?async=false&importStrategy=UPDATE')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const changeEnrollmentAndEventsStatus = () => (
const enrollmentToUpdate = {
...enrollment,
status: 'ACTIVE',
events: [{ ...eventToUpdate, status: 'ACTIVE' }],
completedAt: null,
completedBy: null,
events: [{ ...eventToUpdate, status: 'ACTIVE', completedAt: null, completedBy: null }],
};

return cy
Expand Down
15 changes: 13 additions & 2 deletions cypress/e2e/WidgetsForEnrollmentPages/WidgetEnrollment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,19 @@ const changeEnrollmentAndEventsStatus = () => (
.then(url => cy.request(url))
.then(({ body }) => {
const enrollment = body.enrollments && body.enrollments.find(e => e.enrollment === 'qyx7tscVpVB');
const eventsToUpdate = enrollment.events.map(e => ({ ...e, status: 'ACTIVE' }));
const enrollmentToUpdate = { ...enrollment, status: 'ACTIVE', events: eventsToUpdate };
const eventsToUpdate = enrollment.events.map(e => ({
...e,
status: 'ACTIVE',
completedAt: null,
completedBy: null,
}));
const enrollmentToUpdate = {
...enrollment,
status: 'ACTIVE',
completedAt: null,
completedBy: null,
events: eventsToUpdate,
};

return cy
.buildApiUrl('tracker?async=false&importStrategy=UPDATE')
Expand Down
16 changes: 10 additions & 6 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,12 @@ msgstr "There are no active enrollments."
msgid "Add new enrollment for {{teiDisplayName}} in this program."
msgstr "Add new enrollment for {{teiDisplayName}} in this program."

msgid "No access to program owner."
msgstr "No access to program owner."
msgid ""
"You do not have permissions to access to this program, registering unit or "
"record, contact your administrator for more information."
msgstr ""
"You do not have permissions to access to this program, registering unit or "
"record, contact your administrator for more information."

msgid "{{teiDisplayName}} is not enrolled in this program."
msgstr "{{teiDisplayName}} is not enrolled in this program."
Expand Down Expand Up @@ -1020,17 +1024,17 @@ msgstr "No tracked entity types available"
msgid "Assigned to"
msgstr "Assigned to"

msgid "You don't have access to edit this assignee"
msgstr "You don't have access to edit this assignee"
msgid "You don't have access to edit the assigned user"
msgstr "You don't have access to edit the assigned user"

msgid "Edit"
msgstr "Edit"

msgid "No one is assigned to this event"
msgstr "No one is assigned to this event"

msgid "You don't have access to assign an assignee"
msgstr "You don't have access to assign an assignee"
msgid "You don't have access to assign a user to this event"
msgstr "You don't have access to assign a user to this event"

msgid "Assign"
msgstr "Assign"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "capture-app",
"homepage": ".",
"version": "101.14.6",
"version": "101.14.8",
"cacheVersion": "7",
"serverVersion": "38",
"license": "BSD-3-Clause",
Expand All @@ -10,7 +10,7 @@
"packages/rules-engine"
],
"dependencies": {
"@dhis2/rules-engine-javascript": "101.14.6",
"@dhis2/rules-engine-javascript": "101.14.8",
"@dhis2/app-runtime": "^3.9.3",
"@dhis2/d2-i18n": "^1.1.0",
"@dhis2/d2-icons": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion 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": "101.14.6",
"version": "101.14.8",
"license": "BSD-3-Clause",
"main": "./build/cjs/index.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// @flow
import moment from 'moment';
import { getFormattedStringFromMomentUsingEuropeanGlyphs } from 'capture-core-utils/date';
import { convertDataEntryToClientValues } from '../../../../../DataEntry/common/convertDataEntryToClientValues';
import { convertValue as convertToServerValue } from '../../../../../../converters/clientToServer';
import { convertMainEventClientToServer } from '../../../../../../events/mainConverters';
Expand All @@ -27,10 +25,6 @@ export const getNewEventServerData = (state: ReduxState, formFoundation: RenderF
const formServerValues = formFoundation.convertValues(formClientValues, convertToServerValue);
const mainDataServerValues: Object = convertMainEventClientToServer(mainDataClientValues, serverMinorVersion);

if (mainDataServerValues.status === 'COMPLETED') {
mainDataServerValues.completedAt = getFormattedStringFromMomentUsingEuropeanGlyphs(moment());
}

return {
events: [{
...mainDataServerValues,
Expand Down Expand Up @@ -64,9 +58,6 @@ export const getAddEventEnrollmentServerData = (state: ReduxState,
if (!mainDataServerValues.status) {
mainDataServerValues.status = completed ? 'ACTIVE' : 'COMPLETED';
}
if (mainDataServerValues.status === 'COMPLETED') {
mainDataServerValues.completedAt = getFormattedStringFromMomentUsingEuropeanGlyphs(moment());
}

return {
events: [
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export const MissingMessage = withStyles(getStyles)(({
{
missingStatus === missingStatuses.RESTRICTED_PROGRAM_NO_ACCESS &&
<IncompleteSelectionsMessage>
{i18n.t('No access to program owner.')}
{i18n.t('You do not have permissions to access to this program, registering unit or record, contact your administrator for more information.')}
</IncompleteSelectionsMessage>
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const DisplayModePlain = ({ assignee, onEdit, writeAccess, avatarId, classes }:
{assignee.name}
</div>
<ConditionalTooltip
content={i18n.t("You don't have access to edit this assignee")}
content={i18n.t("You don't have access to edit the assigned user")}
enabled={!writeAccess}
>
<Button
Expand All @@ -63,7 +63,7 @@ const DisplayModePlain = ({ assignee, onEdit, writeAccess, avatarId, classes }:
<div className={classes.wrapper}>
{i18n.t('No one is assigned to this event')}
<ConditionalTooltip
content={i18n.t("You don't have access to assign an assignee")}
content={i18n.t("You don't have access to assign a user to this event")}
enabled={!writeAccess}
>
<Button
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @flow
import moment from 'moment';
import { getFormattedStringFromMomentUsingEuropeanGlyphs } from 'capture-core-utils/date';
import { convertDataEntryToClientValues } from '../../DataEntry/common/convertDataEntryToClientValues';
import { convertValue as convertToServerValue } from '../../../converters/clientToServer';
import { convertMainEventClientToServer } from '../../../events/mainConverters';
Expand Down Expand Up @@ -44,9 +43,6 @@ export const getAddEventEnrollmentServerData = ({
if (!mainDataServerValues.status) {
mainDataServerValues.status = completed ? 'COMPLETED' : 'ACTIVE';
}
if (mainDataServerValues.status === 'COMPLETED') {
mainDataServerValues.completedAt = getFormattedStringFromMomentUsingEuropeanGlyphs(moment());
}

return {
...mainDataServerValues,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { ofType } from 'redux-observable';
import { map, filter, flatMap, switchMap } from 'rxjs/operators';
import { batchActions } from 'redux-batched-actions';
import { dataEntryKeys, dataEntryIds } from 'capture-core/constants';
import moment from 'moment';
import { EMPTY, of } from 'rxjs';
import { getFormattedStringFromMomentUsingEuropeanGlyphs } from 'capture-core-utils/date';
import { convertCategoryOptionsToServer, convertValue as convertToServerValue } from '../../../converters/clientToServer';
import { getProgramAndStageFromEvent, scopeTypes, getScopeInfo } from '../../../metaData';
import { openEventForEditInDataEntry } from '../DataEntry/editEventDataEntry.actions';
Expand Down Expand Up @@ -104,9 +102,6 @@ export const saveEditedEventEpic = (action$: InputObservable, store: ReduxStore,
const formServerValues = formFoundation.convertValues(formClientValues, convertToServerValue);
const mainDataServerValues: Object = convertMainEventClientToServer(mainDataClientValues, minor);

if (mainDataServerValues.status === 'COMPLETED' && !prevEventMainData.completedAt) {
mainDataServerValues.completedAt = getFormattedStringFromMomentUsingEuropeanGlyphs(moment());
}

const { eventContainer: prevEventContainer } = state.viewEventPage.loadedValues;

Expand Down Expand Up @@ -268,10 +263,6 @@ export const saveEventAndCompleteEnrollmentEpic = (action$: InputObservable, sto
const formServerValues = formFoundation.convertValues(formClientValues, convertToServerValue);
const mainDataServerValues: Object = convertMainEventClientToServer(mainDataClientValues, minor);

if (!prevEventMainData.completedAt) {
mainDataServerValues.completedAt = getFormattedStringFromMomentUsingEuropeanGlyphs(moment());
}

const editEvent = {
...mainDataServerValues,
attributeOptionCombo: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import { convertMainEvent } from './mainEventConverter';
import { dataElementTypes } from '../../metaData';
import { convertEventAttributeOptions } from '../convertEventAttributeOptions';

const keysToSkip = {
completedAt: 'completedAt',
completedBy: 'completedBy',
};

export function convertMainEventClientToServer(event: Object, serverMinorVersion: number) {
const mapClientKeyToServerKey = {
eventId: 'event',
Expand All @@ -22,7 +27,6 @@ export function convertMainEventClientToServer(event: Object, serverMinorVersion
switch (key) {
case 'occurredAt':
case 'scheduledAt':
case 'completedAt':
convertedValue = convertClientToServer(value, dataElementTypes.DATE);
break;
case 'assignee':
Expand All @@ -34,5 +38,5 @@ export function convertMainEventClientToServer(event: Object, serverMinorVersion
}

return convertedValue;
});
}, keysToSkip);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ export function convertMainEvent(
event: Object,
keyMap: Object = {},
onConvert: (key: string, value: any) => any,
keysToSkip?: {[keyId: string]: string},
) {
return Object
.keys(event)
.reduce((accConvertedEvent, key) => {
if (keysToSkip && keysToSkip[key]) {
return accConvertedEvent;
}
const convertedValue = onConvert(key, event[key]);
const outputKey = keyMap[key] || key;
accConvertedEvent[outputKey] = convertedValue;
Expand Down

0 comments on commit 3b0a8fb

Please sign in to comment.