Skip to content

Commit

Permalink
Merge branch 'master' into DHIS2-13800
Browse files Browse the repository at this point in the history
  • Loading branch information
simonadomnisoru committed Mar 5, 2024
2 parents ce309b5 + 7948025 commit df73beb
Show file tree
Hide file tree
Showing 45 changed files with 950 additions and 55 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [100.59.0](https://github.com/dhis2/capture-app/compare/v100.58.0...v100.59.0) (2024-03-05)


### Features

* [DHIS2-16322] One Click Transfer ([#3519](https://github.com/dhis2/capture-app/issues/3519)) ([b115ee8](https://github.com/dhis2/capture-app/commit/b115ee87eec638f9a8a16d7cd22ebd0ec2516841))

# [100.58.0](https://github.com/dhis2/capture-app/compare/v100.57.6...v100.58.0) (2024-03-03)


Expand Down
2 changes: 2 additions & 0 deletions cypress/e2e/EnrollmentPage/BreakingTheGlass.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Feature: Breaking the glass page

# TODO - Flaky tests should be fixed by TECH-1662
@skip
Scenario: User with search scope access tries to access an enrollment in a protected program
Given the tei created by this test is cleared from the database
And the data store is clean
Expand Down
78 changes: 77 additions & 1 deletion cypress/e2e/WidgetsForEnrollmentPages/WidgetEnrollment/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { When, Then } from '@badeball/cypress-cucumber-preprocessor';
import { When, Then, After, Given } from '@badeball/cypress-cucumber-preprocessor';
import { getCurrentYear } from '../../../support/date';
import { hasVersionSupport } from '../../../support/tagUtils';

After({ tags: '@with-transfer-ownership-data-cleanup' }, () => {
const teiQueryKey = hasVersionSupport('@v>=41') ? 'trackedEntity' : 'trackedEntityInstance';
cy.buildApiUrl('tracker', `ownership/transfer?program=IpHINAT79UW&ou=DiszpKrYNg8&${teiQueryKey}=EaOyKGOIGRp`)
.then(url => cy.request('PUT', url));
});

const changeEnrollmentAndEventsStatus = () => (
cy.buildApiUrl('tracker', 'trackedEntities/osF4RF4EiqP?program=IpHINAT79UW&fields=enrollments')
Expand Down Expand Up @@ -126,6 +133,10 @@ When(/^the user clicks on the delete action/, () =>
cy.get('[data-test="widget-enrollment-actions-delete"]').click(),
);

When(/^the user clicks on the transfer action/, () => {
cy.get('[data-test="widget-enrollment-actions-transfer"]').click();
});

Then(/^the user sees the delete enrollment modal/, () =>
cy.get('[data-test="widget-enrollment-actions-modal"]').within(() => {
cy.contains('Delete enrollment').should('exist');
Expand Down Expand Up @@ -168,3 +179,68 @@ When('the user completes the enrollment and the active events', () => {
});
cy.get('[data-test="widget-enrollment-actions-complete-button"]').click();
});

Then(/^the user sees the transfer modal/, () =>
cy.get('[data-test="widget-enrollment-transfer-modal"]').within(() => {
cy.contains('Transfer Ownership').should('exist');
cy.contains(
'Choose the organisation unit to which enrollment ownership should be transferred.',
).should('exist');
cy.contains('Cancel').should('exist');
cy.contains('Transfer').should('exist');
}),
);

Then(/^the user sees the organisation unit tree/, () =>
cy.get('[data-test="widget-enrollment-transfer-modal"]').within(() => {
cy.get('[data-test="widget-enrollment-transfer-orgunit-tree"]').should(
'exist',
);
}),
);

Then(/^the user clicks on the organisation unit with text: (.*)/, orgunit =>
cy.get('[data-test="widget-enrollment-transfer-modal"]').within(() => {
cy.get('[data-test="widget-enrollment-transfer-orgunit-tree"]').within(
() => {
cy.contains(orgunit).click();
},
);
}),
);

Then(/^the user sees the organisation unit with text: (.*) is selected/, orgunit =>
cy.get('[data-test="widget-enrollment-transfer-modal"]').within(() => {
cy.get('[data-test="widget-enrollment-transfer-orgunit-tree"]').within(
() => {
cy.contains(orgunit).should('have.class', 'checked');
},
);
}),
);

Then(/^the user successfully transfers the enrollment/, () => {
cy.intercept(
{ method: 'PUT', url: '**/tracker/ownership/transfer**' },
).as('transferOwnership');

cy.get('[data-test="widget-enrollment-transfer-modal"]').within(() => {
cy.get('[data-test="widget-enrollment-transfer-button"]').click();
});

cy.wait('@transferOwnership');

cy.get('[data-test="widget-enrollment"]').within(() => {
cy.get('[data-test="widget-enrollment-owner-orgunit"]')
.contains('Owned by Sierra Leone')
.should('exist');
});
});

Given(/^the enrollment owner organisation unit is (.*)/, (orgunit) => {
cy.get('[data-test="widget-enrollment"]').within(() => {
cy.get('[data-test="widget-enrollment-owner-orgunit"]')
.contains(`Owned by ${orgunit}`)
.should('exist');
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
Feature: The user interacts with the widgets on the enrollment dashboard

Scenario: User can open the transfer modal
Given you land on the enrollment dashboard page by having typed #/enrollment?enrollmentId=wBU0RAsYjKE
Then the enrollment widget should be opened
When the user opens the enrollment actions menu
And the user clicks on the transfer action
Then the user sees the transfer modal

Scenario: User can select an organisation unit in the transfer modal
Given you land on the enrollment dashboard page by having typed #/enrollment?enrollmentId=wBU0RAsYjKE
Then the enrollment widget should be opened
When the user opens the enrollment actions menu
And the user clicks on the transfer action
And the user sees the transfer modal
And the user sees the organisation unit tree
When the user clicks on the organisation unit with text: Sierra Leone
Then the user sees the organisation unit with text: Sierra Leone is selected

@with-transfer-ownership-data-cleanup
Scenario: User can transfer the enrollment to another organisation unit
Given you land on the enrollment dashboard page by having typed #/enrollment?enrollmentId=wBU0RAsYjKE
Then the enrollment widget should be opened
And the enrollment owner organisation unit is Ngelehun CHC
When the user opens the enrollment actions menu
And the user clicks on the transfer action
And the user sees the transfer modal
And the user sees the organisation unit tree
When the user clicks on the organisation unit with text: Sierra Leone
Then the user successfully transfers the enrollment

# Scenarios linked to the enrollment dashboard
Scenario: The profile widget can be closed on the enrollment dashboard
Given you land on the enrollment dashboard page by having typed #/enrollment?enrollmentId=wBU0RAsYjKE
Expand Down Expand Up @@ -124,6 +153,7 @@ Feature: The user interacts with the widgets on the enrollment dashboard
And the user clicks on the delete action
Then the user sees the delete enrollment modal


Scenario: User can add note on enrollment dashboard page
Given you land on the enrollment dashboard page by having typed #/enrollment?enrollmentId=wBU0RAsYjKE
Then the stages and events should be loaded
Expand Down
31 changes: 23 additions & 8 deletions cypress/support/tagUtils/filterInstanceVersion.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@

const operation = {
'>=': (instanceVersion, testVersion) => instanceVersion >= testVersion,
'<=': (instanceVersion, testVersion) => instanceVersion <= testVersion,
'>': (instanceVersion, testVersion) => instanceVersion > testVersion,
'<': (instanceVersion, testVersion) => instanceVersion < testVersion,
'=': (instanceVersion, testVersion) => instanceVersion === testVersion,
};

export const filterInstanceVersion = (skip) => {
const { tags } = window.testState.pickle;
if (!tags || !tags.length) {
Expand All @@ -14,14 +23,6 @@ export const filterInstanceVersion = (skip) => {

const currentInstanceVersion = Number(/[.](\d+)/.exec(Cypress.env('dhis2InstanceVersion'))[1]);

const operation = {
'>=': (instanceVersion, testVersion) => instanceVersion >= testVersion,
'<=': (instanceVersion, testVersion) => instanceVersion <= testVersion,
'>': (instanceVersion, testVersion) => instanceVersion > testVersion,
'<': (instanceVersion, testVersion) => instanceVersion < testVersion,
'=': (instanceVersion, testVersion) => instanceVersion === testVersion,
};

const shouldRun = versionTags
.some((versionTag) => {
const version = Number(versionTag[2]);
Expand All @@ -38,3 +39,17 @@ export const filterInstanceVersion = (skip) => {
skip();
}
};

export const hasVersionSupport = (inputVersion) => {
const supportedVersion = /^@v([><=]*)(\d+)$/.exec(inputVersion);
const currentInstanceVersion = Number(/[.](\d+)/.exec(Cypress.env('dhis2InstanceVersion'))[1]);

const version = Number(supportedVersion[2]);
const operator = supportedVersion[1] || '=';

if (!operation[operator] || !currentInstanceVersion) {
return false;
}

return operation[operator](currentInstanceVersion, version);
};
2 changes: 1 addition & 1 deletion cypress/support/tagUtils/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { filterInstanceVersion } from './filterInstanceVersion';
export { filterInstanceVersion, hasVersionSupport } from './filterInstanceVersion';
export { shouldClearCookies } from './shouldClearCookies';
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions docs/user/using-the-capture-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,10 @@ If the program only allows one enrollment per tracked entity instance, the **Add

![](resources/images/enrollment-dash-enrollment-widget-add-new.png)

In the enrollment actions, you could also choose to transfer the enrollment to another organisation unit. Click the transfer button and select the organisation unit you want to transfer the enrollment to.

![](resources/images/enrollment-dash-enrollment-widget-transfer.png)

#### Delete the enrollment

You can delete the enrollment by clicking the delete button and confirming the action in the modal.
Expand Down
54 changes: 32 additions & 22 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-02-16T12:15:15.668Z\n"
"PO-Revision-Date: 2024-02-16T12:15:15.668Z\n"
"POT-Creation-Date: 2024-03-05T07:44:33.812Z\n"
"PO-Revision-Date: 2024-03-05T07:44:33.812Z\n"

msgid "Choose one or more dates..."
msgstr "Choose one or more dates..."
Expand Down Expand Up @@ -320,11 +320,6 @@ msgstr "{{programStageName}} completed"
msgid "Would you like to complete the enrollment and all active events as well?"
msgstr "Would you like to complete the enrollment and all active events as well?"

msgid "{{count}} event in {{programStageName}}"
msgid_plural "{{count}} event in {{programStageName}}"
msgstr[0] "{{count}} event in {{programStageName}}"
msgstr[1] "{{count}} events in {{programStageName}}"

msgid "Yes, complete enrollment and events"
msgstr "Yes, complete enrollment and events"

Expand Down Expand Up @@ -958,11 +953,6 @@ msgstr "Search {{uniqueAttrName}}"
msgid "Search by attributes"
msgstr "Search by attributes"

msgid "Fill in at least {{count}} attribute to search"
msgid_plural "Fill in at least {{count}} attribute to search"
msgstr[0] "Fill in at least {{count}} attribute to search"
msgstr[1] "Fill in at least {{count}} attributes to search"

msgid "Could not retrieve metadata. Please try again later."
msgstr "Could not retrieve metadata. Please try again later."

Expand Down Expand Up @@ -1192,6 +1182,12 @@ msgstr "Remove mark for follow-up"
msgid "Mark for follow-up"
msgstr "Mark for follow-up"

msgid "Transfer"
msgstr "Transfer"

msgid "An error occurred while transferring ownership"
msgstr "An error occurred while transferring ownership"

msgid "Existing dates for auto-generated events will not be updated."
msgstr "Existing dates for auto-generated events will not be updated."

Expand Down Expand Up @@ -1219,6 +1215,30 @@ msgstr "Finish drawing before saving"
msgid "Set area"
msgstr "Set area"

msgid ""
"Transferring enrollment ownership from {{ownerOrgUnit}} to "
"{{newOrgUnit}}{{escape}}"
msgstr ""
"Transferring enrollment ownership from {{ownerOrgUnit}} to "
"{{newOrgUnit}}{{escape}}"

msgid ""
"You will lose access to the enrollment when transferring ownership to "
"{{organisationUnit}}."
msgstr ""
"You will lose access to the enrollment when transferring ownership to "
"{{organisationUnit}}."

msgid "Transfer Ownership"
msgstr "Transfer Ownership"

msgid ""
"Choose the organisation unit to which enrollment ownership should be "
"transferred."
msgstr ""
"Choose the organisation unit to which enrollment ownership should be "
"transferred."

msgid "Enrollment date"
msgstr "Enrollment date"

Expand Down Expand Up @@ -1312,22 +1332,12 @@ msgstr "Scheduled automatically for {{suggestedScheduleDate}}"
msgid "The scheduled date matches the suggested date, but can be changed if needed."
msgstr "The scheduled date matches the suggested date, but can be changed if needed."

msgid "The scheduled date is {{count}} days {{position}} the suggested date."
msgid_plural "The scheduled date is {{count}} days {{position}} the suggested date."
msgstr[0] "The scheduled date is {{count}} day {{position}} the suggested date."
msgstr[1] "The scheduled date is {{count}} days {{position}} the suggested date."

msgid "after"
msgstr "after"

msgid "before"
msgstr "before"

msgid "There are {{count}} scheduled event in {{orgUnitName}} on this day."
msgid_plural "There are {{count}} scheduled event in {{orgUnitName}} on this day."
msgstr[0] "There are {{count}} scheduled event in {{orgUnitName}} on this day."
msgstr[1] "There are {{count}} scheduled events in {{orgUnitName}} on this day."

msgid "Scheduling an event in {{stageName}} for {{programName}} in {{orgUnitName}}"
msgstr "Scheduling an event in {{stageName}} for {{programName}} in {{orgUnitName}}"

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": "100.58.0",
"version": "100.59.0",
"cacheVersion": "7",
"serverVersion": "38",
"license": "BSD-3-Clause",
Expand All @@ -10,7 +10,7 @@
"packages/rules-engine"
],
"dependencies": {
"@dhis2/rules-engine-javascript": "100.58.0",
"@dhis2/rules-engine-javascript": "100.59.0",
"@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": "100.58.0",
"version": "100.59.0",
"license": "BSD-3-Clause",
"main": "./build/cjs/index.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const FEATURES = Object.freeze({
storeProgramStageWorkingList: 'storeProgramStageWorkingList',
multiText: 'multiText',
customIcons: 'customIcons',
newTransferQueryParam: 'newTransferQueryParam',
exportablePayload: 'exportablePayload',
});

Expand All @@ -14,6 +15,7 @@ const MINOR_VERSION_SUPPORT = Object.freeze({
[FEATURES.multiText]: 41,
[FEATURES.customIcons]: 41,
[FEATURES.exportablePayload]: 41,
[FEATURES.newTransferQueryParam]: 41,
});

export const hasAPISupportForFeature = (minorVersion: string | number, featureName: string) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ const OrgUnitFieldPlain = (props: Props) => {
onBlur && onBlur(null);
};


const styles = maxTreeHeight ? { maxHeight: maxTreeHeight, overflowY: 'auto' } : null;
return (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ export const EnrollmentPageDefault = () => {
history.push(`/new?${buildUrlQueryString({ orgUnitId, programId, teiId })}`);
};

const onAccessLostFromTransfer = () => {
history.push(`/?${buildUrlQueryString({ orgUnitId, programId })}`);
};

const onEnrollmentError = message => dispatch(showEnrollmentError({ message }));
const onUpdateEnrollmentStatus = useCallback(
(enrollmentToUpdate: Object) => dispatch(updateEnrollmentAndEvents(enrollmentToUpdate)),
Expand Down Expand Up @@ -180,6 +184,7 @@ export const EnrollmentPageDefault = () => {
onUpdateEnrollmentStatusError={onUpdateEnrollmentStatusError}
ruleEffects={ruleEffects}
widgetEnrollmentStatus={widgetEnrollmentStatus}
onAccessLostFromTransfer={onAccessLostFromTransfer}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type Props = {|
onLinkedRecordClick: LinkedRecordClick,
onUpdateEnrollmentDate: (enrollmentDate: string) => void,
onUpdateIncidentDate: (incidentDate: string) => void,
onAccessLostFromTransfer: () => void,
onEnrollmentError: (message: string) => void,
onUpdateEnrollmentStatus: (enrollment: Object) => void,
onUpdateEnrollmentStatusSuccess: ({ redirect?: boolean }) => void,
Expand Down
Loading

0 comments on commit df73beb

Please sign in to comment.