Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [DHIS2-16322] One Click Transfer #3519

Merged
merged 28 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6d5c11b
feat: temp
eirikhaugstulen Jan 5, 2024
0a15438
feat: temp
eirikhaugstulen Jan 5, 2024
d1cfe52
chore: temp
eirikhaugstulen Jan 11, 2024
45dd867
chore: temp
eirikhaugstulen Jan 25, 2024
83b06f8
feat: temp
eirikhaugstulen Jan 28, 2024
95be4b0
Merge remote-tracking branch 'origin/master' into eh/feat/EnrollmentT…
eirikhaugstulen Jan 28, 2024
a36ba4b
feat: implement transfers
eirikhaugstulen Jan 28, 2024
ed705ad
fix: change icon
eirikhaugstulen Jan 30, 2024
f0b7ad3
fix: pr-review
eirikhaugstulen Jan 31, 2024
e5dfd0f
fix: errorHandling
eirikhaugstulen Feb 4, 2024
576f5b2
fix: change useEffect to callback handler
eirikhaugstulen Feb 4, 2024
a58e77f
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-16322…
eirikhaugstulen Feb 4, 2024
89df8aa
chore: add prop to enrollment widget config
eirikhaugstulen Feb 4, 2024
0d65fde
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-16322…
eirikhaugstulen Feb 6, 2024
d25160e
chore: add live tests
eirikhaugstulen Feb 6, 2024
7404cb4
chore: add live tests
eirikhaugstulen Feb 7, 2024
3757800
chore: add live tests
eirikhaugstulen Feb 7, 2024
f541748
chore: pr-review
eirikhaugstulen Feb 8, 2024
eea194c
fix: keep focus on search
eirikhaugstulen Feb 18, 2024
f7785aa
fix: remove comment
eirikhaugstulen Feb 19, 2024
f88b394
feat: add gcTime in case of large amount of searches
eirikhaugstulen Feb 19, 2024
7d3c384
chore: change state labels
eirikhaugstulen Feb 19, 2024
13e5d5c
chore: remove comment
eirikhaugstulen Feb 27, 2024
a16b2a7
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-16322…
eirikhaugstulen Feb 27, 2024
e0fb367
chore: commit to retrigger cypress
eirikhaugstulen Feb 29, 2024
21db76f
fix: update naming and program access
eirikhaugstulen Mar 1, 2024
8e2a3f5
docs: [DHIS2-16322] One click transfer docs (#3547)
eirikhaugstulen Mar 4, 2024
32f7028
chore: comment out flaky test
eirikhaugstulen Mar 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 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-01-25T12:12:47.253Z\n"
"PO-Revision-Date: 2024-01-25T12:12:47.253Z\n"
"POT-Creation-Date: 2024-01-29T10:42:09.557Z\n"
"PO-Revision-Date: 2024-01-29T10:42:09.557Z\n"

msgid "Choose one or more dates..."
msgstr "Choose one or more dates..."
Expand Down Expand Up @@ -1173,6 +1173,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 @@ -1200,6 +1206,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 @@ -1377,9 +1407,6 @@ msgstr "This stage can only have one event"
msgid "Events could not be retrieved. Please try again later."
msgstr "Events could not be retrieved. Please try again later."

msgid "Assigned to"
msgstr "Assigned to"

msgid "{{ totalEvents }} events"
msgstr "{{ totalEvents }} events"

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 @@ -72,6 +72,7 @@ export const EnrollmentPageDefaultPlain = ({
onUpdateIncidentDate,
onEnrollmentError,
ruleEffects,
onTransferOutsideCaptureScope,
}: PlainProps) => {
const [mainContentVisible, setMainContentVisibility] = useState(true);
const [addRelationShipContainerElement, setAddRelationshipContainerElement] =
Expand Down Expand Up @@ -149,6 +150,7 @@ export const EnrollmentPageDefaultPlain = ({
onUpdateEnrollmentDate={onUpdateEnrollmentDate}
onUpdateIncidentDate={onUpdateIncidentDate}
onError={onEnrollmentError}
onTransferOutsideCaptureScope={onTransferOutsideCaptureScope}
/>}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ export const EnrollmentPageDefault = () => {
history.push(`/new?${buildUrlQueryString({ orgUnitId, programId, teiId })}`);
};

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

const onEnrollmentError = message => dispatch(showEnrollmentError({ message }));

if (error) {
Expand Down Expand Up @@ -131,6 +135,7 @@ export const EnrollmentPageDefault = () => {
onUpdateIncidentDate={onUpdateIncidentDate}
onEnrollmentError={onEnrollmentError}
ruleEffects={ruleEffects}
onTransferOutsideCaptureScope={onTransferOutsideCaptureScope}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type Props = {|
onLinkedRecordClick: LinkedRecordClick,
onUpdateEnrollmentDate: (enrollmentDate: string) => void,
onUpdateIncidentDate: (incidentDate: string) => void,
onTransferOutsideCaptureScope: () => void,
onEnrollmentError: (message: string) => void,
ruleEffects?: Array<{id: string, type: $Values<effectActions>}>;
|};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const EnrollmentAddEventPagePain = ({
onEnrollmentSuccess,
pageFailure,
ready,
onTransferOutsideCaptureScope,
classes,
...passOnProps
}: Props) => (
Expand Down Expand Up @@ -132,6 +133,7 @@ const EnrollmentAddEventPagePain = ({
onAddNew={onAddNew}
onError={onEnrollmentError}
onSuccess={onEnrollmentSuccess}
onTransferOutsideCaptureScope={onTransferOutsideCaptureScope}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export const EnrollmentAddEventPageDefault = ({
const onEnrollmentError = message => dispatch(showEnrollmentError({ message }));
const onEnrollmentSuccess = () => dispatch(fetchEnrollments());

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

const widgetReducerName = 'enrollmentEvent-newEvent';

const dataEntryHasChanges = useSelector(state => getDataEntryHasChanges(state, widgetReducerName));
Expand Down Expand Up @@ -151,6 +155,7 @@ export const EnrollmentAddEventPageDefault = ({
dataEntryHasChanges={dataEntryHasChanges}
onEnrollmentError={onEnrollmentError}
onEnrollmentSuccess={onEnrollmentSuccess}
onTransferOutsideCaptureScope={onTransferOutsideCaptureScope}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type Props = {|
onDelete: () => void,
onAddNew: () => void,
onEnrollmentError: (message: string) => void,
onTransferOutsideCaptureScope?: () => void,
onEnrollmentSuccess: () => void,
widgetEffects: ?WidgetEffects,
hideWidgets: HideWidgets,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const EnrollmentEditEventPageRight = ({
getAssignedUserSaveContext,
onSaveAssignee,
onSaveAssigneeError,
onTransferOutsideCaptureScope,
addRelationShipContainerElement,
toggleVisibility,
}) => (
Expand Down Expand Up @@ -152,7 +153,8 @@ const EnrollmentEditEventPageRight = ({
addRelationshipRenderElement={addRelationShipContainerElement}
onOpenAddRelationship={toggleVisibility}
onCloseAddRelationship={toggleVisibility}
onAddRelationship={() => {}}
onAddRelationship={() => {
}}
onLinkedRecordClick={onLinkedRecordClick}
/>
)}
Expand All @@ -166,6 +168,7 @@ const EnrollmentEditEventPageRight = ({
onAddNew={onAddNew}
onError={onEnrollmentError}
onSuccess={onEnrollmentSuccess}
onTransferOutsideCaptureScope={onTransferOutsideCaptureScope}
/>
</>
);
Expand Down Expand Up @@ -201,6 +204,7 @@ const EnrollmentEditEventPagePain = ({
getAssignedUserSaveContext,
onSaveAssignee,
onSaveAssigneeError,
onTransferOutsideCaptureScope,
}: PlainProps) => {
const [mainContentVisible, setMainContentVisible] = useState(true);
const [addRelationShipContainerElement, setAddRelationShipContainerElement] = useState<?HTMLDivElement>(undefined);
Expand Down Expand Up @@ -272,6 +276,7 @@ const EnrollmentEditEventPagePain = ({
onSaveAssigneeError={onSaveAssigneeError}
addRelationShipContainerElement={addRelationShipContainerElement}
toggleVisibility={toggleVisibility}
onTransferOutsideCaptureScope={onTransferOutsideCaptureScope}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ const EnrollmentEditEventPageWithContextPlain = ({
const assignedUser: ApiAssignedUser = convertClientToServer(newAssignee, dataElementTypes.ASSIGNEE);
dispatch(setAssignee(assignedUser, newAssignee, eventId));
};
const onTransferOutsideCaptureScope = () => {
history.push(`/?${buildUrlQueryString({ orgUnitId, programId })}`);
};
const onSaveAssigneeError = (prevAssignee) => {
const assignedUser: ApiAssignedUser | typeof undefined = prevAssignee
// $FlowFixMe dataElementTypes flow error
Expand Down Expand Up @@ -200,6 +203,7 @@ const EnrollmentEditEventPageWithContextPlain = ({
getAssignedUserSaveContext={getAssignedUserSaveContext}
onSaveAssignee={onSaveAssignee}
onSaveAssigneeError={onSaveAssigneeError}
onTransferOutsideCaptureScope={onTransferOutsideCaptureScope}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export type PlainProps = {|
onEnrollmentSuccess: () => void,
onCancelEditEvent: (isScheduled: boolean) => void,
onHandleScheduleSave: (eventData: Object) => void,
onTransferOutsideCaptureScope?: () => void,
pageStatus: string,
eventStatus?: string,
eventAccess: {|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { AddLocation } from './AddLocation';
import type { PlainProps } from './actions.types';
import { LoadingMaskForButton } from '../../LoadingMasks';
import { MapModal } from '../MapModal';
import { Transfer } from './Transfer';
import { TransferModal } from '../TransferModal';

const styles = {
actions: {
Expand All @@ -28,17 +30,20 @@ const styles = {

export const ActionsPlain = ({
enrollment = {},
ownerOrgUnitId,
tetName,
canAddNew,
onUpdate,
onDelete,
onUpdateOwnership,
onAddNew,
loading,
onlyEnrollOnce,
classes,
}: PlainProps) => {
const [isOpenActions, setOpenActions] = useState(false);
const [isOpenMap, setOpenMap] = useState(false);
const [isOpenTransfer, setOpenTransfer] = useState(false);
const handleOnUpdate = (arg) => {
setOpenActions(false);
onUpdate(arg);
Expand Down Expand Up @@ -75,6 +80,13 @@ export const ActionsPlain = ({
enrollment={enrollment}
onUpdate={handleOnUpdate}
/>
<Transfer
enrollment={enrollment}
setOpenTransfer={() => {
setOpenTransfer(true);
setOpenActions(false);
}}
/>
<AddLocation
enrollment={enrollment}
setOpenMap={() => {
Expand Down Expand Up @@ -110,6 +122,14 @@ export const ActionsPlain = ({
onUpdate={handleOnUpdate}
setOpenMap={setOpenMap}
/>}
{isOpenTransfer && (
<TransferModal
enrollment={enrollment}
ownerOrgUnitId={ownerOrgUnitId}
setOpenTransfer={setOpenTransfer}
onUpdateOwnership={onUpdateOwnership}
/>
)}
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import { ActionsComponent } from './Actions.component';
import type { Props } from './actions.types';
import { useUpdateEnrollment, useDeleteEnrollment } from '../dataMutation/dataMutation';
import { useUpdateOwnership } from './Transfer/hooks';

export const Actions = ({
enrollment = {},
Expand All @@ -11,16 +12,24 @@ export const Actions = ({
onDelete,
onError,
onSuccess,
onTransferOutsideCaptureScope,
...passOnProps
}: Props) => {
const { updateMutation, updateLoading } = useUpdateEnrollment(refetchEnrollment, refetchTEI, onError);
const { deleteMutation, deleteLoading } = useDeleteEnrollment(onDelete, onError);
const { updateEnrollmentOwnership } = useUpdateOwnership({
teiId: enrollment.trackedEntity,
programId: enrollment.program,
onTransferOutsideCaptureScope,
refetchTEI,
});

return (
<ActionsComponent
enrollment={enrollment}
onUpdate={updateMutation}
onDelete={deleteMutation}
onUpdateOwnership={updateEnrollmentOwnership}
loading={updateLoading || deleteLoading}
{...passOnProps}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// @flow
import React from 'react';
import i18n from '@dhis2/d2-i18n';
import { IconArrowRight16, MenuItem } from '@dhis2/ui';
import type { Props } from './transfer.types';

export const Transfer = ({ setOpenTransfer }: Props) => (
<MenuItem
dense
dataTest="widget-enrollment-actions-transfer"
onClick={() => setOpenTransfer(true)}
icon={<IconArrowRight16 />}
label={i18n.t('Transfer')}
/>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @flow

export { useUpdateOwnership } from './useUpdateOwnership';
Loading