Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into hv/fix/DHIS2-15685_…
Browse files Browse the repository at this point in the history
…viewingEventShouldBePossibleWithoutSelectingOrgUnit
  • Loading branch information
henrikmv committed Jan 13, 2025
2 parents 9048ff5 + 33093e0 commit 617fdb7
Show file tree
Hide file tree
Showing 40 changed files with 361 additions and 128 deletions.
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
## [101.21.3](https://github.com/dhis2/capture-app/compare/v101.21.2...v101.21.3) (2025-01-12)


### Bug Fixes

* [DHIS2-17613] Use new note endpoint ([#3908](https://github.com/dhis2/capture-app/issues/3908)) ([a9fdea8](https://github.com/dhis2/capture-app/commit/a9fdea8ac8284b28ec3c0acf0551e9cd1a68a180))

## [101.21.2](https://github.com/dhis2/capture-app/compare/v101.21.1...v101.21.2) (2025-01-09)


### Bug Fixes

* [DHIS2-18569] Relationship widget limited to 50 entries ([#3927](https://github.com/dhis2/capture-app/issues/3927)) ([a1e493d](https://github.com/dhis2/capture-app/commit/a1e493d48179e7749d61f52504fdeb3c11dfa53e))

## [101.21.1](https://github.com/dhis2/capture-app/compare/v101.21.0...v101.21.1) (2025-01-08)


### Bug Fixes

* [DHIS2-18632] Sorting stage detail table on orgunit breaks the app ([#3917](https://github.com/dhis2/capture-app/issues/3917)) ([15414cc](https://github.com/dhis2/capture-app/commit/15414cc73f7ce74d4d057acad13bf4855d358426))

# [101.21.0](https://github.com/dhis2/capture-app/compare/v101.20.3...v101.21.0) (2025-01-07)


### Features

* [DHIS2-18328] Handle log entries for occurredAt, scheduledAt and geometry ([#3887](https://github.com/dhis2/capture-app/issues/3887)) ([f670971](https://github.com/dhis2/capture-app/commit/f670971808f49b75295c1d3c7ef25a747b4888df))

## [101.20.3](https://github.com/dhis2/capture-app/compare/v101.20.2...v101.20.3) (2024-12-29)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Feature: User interacts with Stages and Events Widget

@with-restore-deleted-event
Scenario: User can delete an event
Given you open the enrollment page by typing #/enrollment?enrollmentId=ikYMpSKXik1&orgUnitId=DiszpKrYNg8&programId=ur1Edk5Oe2n&teiId=Trc1H9T5C6f
Given you open the enrollment page by typing #/enrollment?enrollmentId=ITyaPVATEwc&orgUnitId=DiszpKrYNg8&programId=ur1Edk5Oe2n&teiId=wsk89u7zquT
And there is an Active event in the TB visit stage
When you click the Delete event overflow button on the Active event
And you confirm you want to delete the event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getCurrentYear } from '../../../support/date';
import '../sharedSteps';

After({ tags: '@with-restore-deleted-event' }, () => {
cy.visit('#/enrollment?enrollmentId=ikYMpSKXik1&orgUnitId=DiszpKrYNg8&programId=ur1Edk5Oe2n&teiId=Trc1H9T5C6f');
cy.visit('#/enrollment?enrollmentId=ITyaPVATEwc&orgUnitId=DiszpKrYNg8&programId=ur1Edk5Oe2n&teiId=wsk89u7zquT');

cy.get('[data-test="stages-and-events-widget"]')
.find('[data-test="widget-contents"]')
Expand Down Expand Up @@ -215,7 +215,7 @@ When(/you click the (.*) event overflow button on the (.*) event$/, (buttonName,

cy.get('[data-test="overflow-menu"]')
.contains(buttonName)
.click();
.click({ force: true });
});

Then('the event should be skipped', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ After({ tags: '@with-transfer-ownership-data-cleanup' }, () => {
});

const changeEnrollmentAndEventsStatus = () => (
cy.buildApiUrl('tracker', 'trackedEntities/osF4RF4EiqP?program=IpHINAT79UW&fields=enrollments')
cy.buildApiUrl('tracker', 'trackedEntities/mPLqCVS27AD?program=IpHINAT79UW&fields=enrollments')
.then(url => cy.request(url))
.then(({ body }) => {
const enrollment = body.enrollments && body.enrollments.find(e => e.enrollment === 'qyx7tscVpVB');
const enrollment = body.enrollments && body.enrollments.find(e => e.enrollment === 'YqNTNLKmX4z');
const eventsToUpdate = enrollment.events.map(e => ({
...e,
status: 'ACTIVE',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Feature: The user interacts with the widgets on the enrollment add event page
Then you can assign a user when scheduling the event

Scenario: User can complete the enrollment and the active events
Given you land on the enrollment edit event page by having typed #/enrollmentEventNew?enrollmentId=qyx7tscVpVB&orgUnitId=DiszpKrYNg8&programId=IpHINAT79UW&teiId=osF4RF4EiqP
Given you land on the enrollment edit event page by having typed #/enrollmentEventNew?enrollmentId=YqNTNLKmX4z&orgUnitId=RzgSFJ9E46G&programId=IpHINAT79UW&teiId=mPLqCVS27AD
And the enrollment widget should be opened
And the user sees the enrollment status and the Baby Postnatal event status is active
And the user opens the enrollment actions menu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Feature: The user interacts with the widgets on the enrollment dashboard
Then the user can see the program rules effect in the indicator widget

Scenario: User can complete the enrollment and the active events
Given you land on the enrollment dashboard page by having typed #/enrollment?enrollmentId=qyx7tscVpVB
Given you land on the enrollment dashboard page by having typed #/enrollment?enrollmentId=YqNTNLKmX4z
And the enrollment widget should be opened
And the user sees the enrollment status and the Baby Postnatal event status is active
And the user opens the enrollment actions menu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Feature: The user interacts with the widgets on the enrollment edit event
Then the table footer should display page 2

Scenario: User can complete the enrollment and the active events
Given you land on the enrollment edit event page by having typed #/enrollmentEventEdit?eventId=OWpIzQ4xabC&orgUnitId=DiszpKrYNg8
Given you land on the enrollment edit event page by having typed #/enrollmentEventEdit?eventId=PyXThVzWJzL&orgUnitId=RzgSFJ9E46G
And the enrollment widget should be opened
And the user sees the enrollment status and the Baby Postnatal event status is active
And the user opens the enrollment actions menu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Feature: User facing tests for bulk actions on Tracked Entity working lists
When you select the first 5 rows
Then the filters should be disabled

#DHIS2-18447
@skip
Scenario: The user should see an error message when trying to bulk complete enrollments with errors
Given you open the main page with Ngelehun and Malaria focus investigation context
And you select the first 3 rows
Expand Down
22 changes: 20 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: 2024-12-05T11:39:04.447Z\n"
"PO-Revision-Date: 2024-12-05T11:39:04.447Z\n"
"POT-Creation-Date: 2024-12-15T15:25:38.375Z\n"
"PO-Revision-Date: 2024-12-15T15:25:38.375Z\n"

msgid "Choose one or more dates..."
msgstr "Choose one or more dates..."
Expand Down Expand Up @@ -101,6 +101,24 @@ msgstr "Date of enrollment"
msgid "Last updated"
msgstr "Last updated"

msgid "Lat"
msgstr "Lat"

msgid "Long"
msgstr "Long"

msgid "lat"
msgstr "lat"

msgid "long"
msgstr "long"

msgid "Show less"
msgstr "Show less"

msgid "Show more"
msgstr "Show more"

msgid "error encountered during field validation"
msgstr "error encountered during field validation"

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": "101.20.3",
"version": "101.21.3",
"cacheVersion": "7",
"serverVersion": "38",
"license": "BSD-3-Clause",
Expand All @@ -10,7 +10,7 @@
"packages/rules-engine"
],
"dependencies": {
"@dhis2/rules-engine-javascript": "101.20.3",
"@dhis2/rules-engine-javascript": "101.21.3",
"@dhis2/app-runtime": "^3.9.3",
"@dhis2/d2-i18n": "^1.1.0",
"@dhis2/d2-icons": "^1.0.1",
Expand Down Expand Up @@ -130,7 +130,7 @@
"jsdoc-export-default-interop": "^0.3.1",
"node-fetch": "2",
"redux-devtools-extension": "^2.13.9",
"wait-on": "^7.2.0"
"wait-on": "^8.0.1"
},
"resolutions": {
"@dhis2/cli-app-scripts": "^10.4.0",
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.20.3",
"version": "101.21.3",
"license": "BSD-3-Clause",
"main": "./build/cjs/index.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export const FEATURES = Object.freeze({
trackedEntitiesCSV: 'trackedEntitiesCSV',
newAocApiSeparator: 'newAocApiSeparator',
newEntityFilterQueryParam: 'newEntityFilterQueryParam',
newNoteEndpoint: 'newNoteEndpoint',
newRelationshipQueryParam: 'newRelationshipQueryParam',
});

// The first minor version that supports the feature
Expand All @@ -26,6 +28,8 @@ const MINOR_VERSION_SUPPORT = Object.freeze({
[FEATURES.trackedEntitiesCSV]: 40,
[FEATURES.newAocApiSeparator]: 41,
[FEATURES.newEntityFilterQueryParam]: 41,
[FEATURES.newNoteEndpoint]: 42,
[FEATURES.newRelationshipQueryParam]: 41,
});

export const hasAPISupportForFeature = (minorVersion: string | number, featureName: string) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import React from 'react';
import i18n from '@dhis2/d2-i18n';

type Props = $ReadOnly<{|
latitude: number | string,
Expand All @@ -8,9 +9,10 @@ type Props = $ReadOnly<{|

const toSixDecimal = value => (parseFloat(value) ? parseFloat(value).toFixed(6) : null);

export const MinimalCoordinates = ({ latitude, longitude }: Props) =>
(<div>
lat: {toSixDecimal(latitude)} <br />
long: {toSixDecimal(longitude)}
</div>);
export const MinimalCoordinates = ({ latitude, longitude }: Props) => (
<div>
{i18n.t('Lat')}: {toSixDecimal(latitude)}<br />
{i18n.t('Long')}: {toSixDecimal(longitude)}
</div>
);

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// @flow
import React, { useState } from 'react';
import i18n from '@dhis2/d2-i18n';
import { withStyles } from '@material-ui/core/styles';
import { IconChevronUp16, IconChevronDown16, colors, spacers } from '@dhis2/ui';

type Props = $ReadOnly<{|
coordinates: Array<Array<number>>,
classes: {
buttonContainer: string,
viewButton: string,
},
|}>;

const styles = {
buttonContainer: {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
},
viewButton: {
background: 'none',
border: 'none',
cursor: 'pointer',
color: colors.grey800,
marginTop: spacers.dp8,
display: 'flex',
alignItems: 'center',
'&:hover': {
textDecoration: 'underline',
color: 'black',
},
},
};

const PolygonCoordinatesPlain = ({ coordinates, classes }: Props) => {
const [showMore, setShowMore] = useState(false);
return (
<>
<div>
{coordinates.slice(0, showMore ? coordinates.length : 1).map((coordinatePair, index) => (
// eslint-disable-next-line react/no-array-index-key
<div key={index}>
{`${i18n.t('lat')}: ${coordinatePair[1]}`}<br />
{`${i18n.t('long')}: ${coordinatePair[0]}`}
</div>
))}
</div>
<div className={classes.buttonContainer}>
<button className={classes.viewButton} onClick={() => setShowMore(!showMore)}>
{showMore ? i18n.t('Show less') : i18n.t('Show more')}
{showMore ? <IconChevronUp16 /> : <IconChevronDown16 />}
</button>
</div>
</>
);
};

export const PolygonCoordinates = withStyles(styles)(PolygonCoordinatesPlain);
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// @flow
export { PolygonCoordinates } from './PolygonCoordinates';
3 changes: 3 additions & 0 deletions src/core_modules/capture-core/components/Coordinates/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @flow
export { MinimalCoordinates } from './MinimalCoordinates';
export { PolygonCoordinates } from './PolygonCoordinates';
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function getTrackerProgram(suggestedProgramId: string) {
log.error(
errorCreator('tracker program for id not found')({ suggestedProgramId, error }),
);
throw Error(i18n('Metadata error. see log for details'));
throw Error(i18n.t('Metadata error. see log for details'));
}
return trackerProgram;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @flow
import { featureAvailable, FEATURES } from 'capture-core-utils';
import { actionCreator } from '../../../../actions/actions.utils';
import { effectMethods } from '../../../../trackerOffline';

Expand All @@ -25,11 +26,13 @@ export const updateEventNoteField = (value: string) =>
export const requestSaveEventNote = (note: string) =>
actionCreator(actionTypes.REQUEST_SAVE_EVENT_NOTE)({ note });

export const startSaveEventNote = (eventId: string, serverData: Object, selections: Object, clientId: string) =>
export const startSaveEventNote = (eventUid: string, serverData: Object, selections: Object, clientId: string) =>
actionCreator(actionTypes.START_SAVE_EVENT_NOTE)({ selections, clientId }, {
offline: {
effect: {
url: `events/${eventId}/note`,
url: (featureAvailable(FEATURES.newNoteEndpoint))
? `tracker/events/${eventUid}/note`
: `events/${eventUid}/note`,
method: effectMethods.POST,
data: serverData,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow
import { batchActions } from 'redux-batched-actions';
import { ofType } from 'redux-observable';
import { featureAvailable, FEATURES } from 'capture-core-utils';
import { map, switchMap } from 'rxjs/operators';
import uuid from 'd2-utilizr/lib/uuid';
import moment from 'moment';
Expand All @@ -21,9 +22,15 @@ import {
setNotes,
} from '../../../Notes/notes.actions';


const noteKey = 'viewEvent';

const createServerData = (eventId, note, useNewEndpoint) => {
if (useNewEndpoint) {
return { event: eventId, value: note };
}
return { event: eventId, notes: [{ value: note }] };
};

export const loadNotesForViewEventEpic = (action$: InputObservable) =>
action$.pipe(
ofType(
Expand Down Expand Up @@ -52,8 +59,9 @@ export const addNoteForViewEventEpic = (action$: InputObservable, store: ReduxSt
switchMap((action) => {
const state = store.value;
const payload = action.payload;

const eventId = state.viewEventPage.eventId;
const useNewEndpoint = featureAvailable(FEATURES.newNoteEndpoint);

return querySingleResource({
resource: 'me',
params: {
Expand All @@ -62,10 +70,7 @@ export const addNoteForViewEventEpic = (action$: InputObservable, store: ReduxSt
}).then((user) => {
const { userName, firstName, surname } = user;
const clientId = uuid();
const serverData = {
event: eventId,
notes: [{ value: payload.note }],
};
const serverData = createServerData(eventId, payload.note, useNewEndpoint);

const clientNote = {
value: payload.note,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function getTrackerProgram(suggestedProgramId: string) {
log.error(
errorCreator('tracker program for id not found')({ suggestedProgramId, error }),
);
throw Error(i18n('Metadata error. see log for details'));
throw Error(i18n.t('Metadata error. see log for details'));
}
return trackerProgram;
}
Expand Down
Loading

0 comments on commit 617fdb7

Please sign in to comment.