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-18018] show related stages widget in view event page #3916

Open
wants to merge 6 commits into
base: DHIS2-17192
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 11 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-12-05T11:39:04.447Z\n"
"PO-Revision-Date: 2024-12-05T11:39:04.447Z\n"
"POT-Creation-Date: 2024-12-11T08:18:31.184Z\n"
"PO-Revision-Date: 2024-12-11T08:18:31.184Z\n"

msgid "Choose one or more dates..."
msgstr "Choose one or more dates..."
Expand Down Expand Up @@ -1397,12 +1397,21 @@ msgstr "Actions - {{relationshipName}}"
msgid "Ambiguous relationships, contact system administrator"
msgstr "Ambiguous relationships, contact system administrator"

msgid "Enter details"
msgstr "Enter details"

msgid "Linked event"
msgstr "Linked event"

msgid "Enter details now"
msgstr "Enter details now"

msgid "Link to an existing event"
msgstr "Link to an existing event"

msgid "An error occurred while linking the event"
msgstr "An error occurred while linking the event"

msgid "Scheduled date"
msgstr "Scheduled date"

Expand Down Expand Up @@ -1513,9 +1522,6 @@ msgstr "You do not have access to remove the link and delete the linked event"
msgid "An error occurred while loading the widget."
msgstr "An error occurred while loading the widget."

msgid "Linked event"
msgstr "Linked event"

msgid ""
"This {{stageName}} event is linked to a {{linkedStageName}} event. Review "
"the linked event details before entering data below"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Props } from './EnrollmentWithFirstStageDataEntry.types';
import { FirstStageDataEntry } from './EnrollmentWithFirstStageDataEntry.component';
import { useDataEntrySections } from './hooks';
import { Section } from '../../../../metaData';
import { WidgetRelatedStages } from '../../../WidgetRelatedStages';
import { RelatedStagesActions } from '../../../WidgetRelatedStages';

const getSectionId = sectionId =>
(sectionId === Section.MAIN_SECTION_ID ? `${Section.MAIN_SECTION_ID}-stage` : sectionId);
Expand All @@ -26,7 +26,7 @@ export const EnrollmentWithFirstStageDataEntry = (props: Props) => {
firstStageMetaData={firstStageMetaData}
dataEntrySections={dataEntrySections}
/>
<WidgetRelatedStages
<RelatedStagesActions
ref={relatedStageRef}
programId={passOnProps.programId}
programStageId={firstStageMetaData.stage?.id}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// @flow
import type { Node } from 'react';
import type { OrgUnit } from '@dhis2/rules-engine-javascript';
import type { RegistrationFormMetadata } from '../common/TEIAndEnrollment/useMetadataForRegistrationForm/types';
import type { RenderCustomCardActions } from '../../CardList';
import type { SaveForDuplicateCheck } from '../common/TEIAndEnrollment/DuplicateCheckOnSave';
import type { ExistingUniqueValueDialogActionsComponent } from '../withErrorMessagePostProcessor';
import type { InputAttribute } from './hooks/useFormValues';
import { RenderFoundation, ProgramStage } from '../../../metaData';
import { RenderFoundation, ProgramStage, Enrollment } from '../../../metaData';
import type { RelatedStageRefPayload } from '../../WidgetRelatedStages';
import { relatedStageActions } from '../../WidgetRelatedStages';

Expand Down Expand Up @@ -67,7 +66,7 @@ export type OwnProps = $ReadOnly<{|
skipDuplicateCheck?: ?boolean,
trackedEntityInstanceAttributes?: Array<InputAttribute>,
saveButtonText: (trackedEntityName: string) => string,
firstStageMetaData?: ?{ stage: ?ProgramStage },
firstStageMetaData?: ?{ stage: ProgramStage },
relatedStageRef?: { current: ?RelatedStageRefPayload },
relatedStageActionsOptions?: {
[key: $Keys<typeof relatedStageActions>]: {
Expand All @@ -85,8 +84,8 @@ type ContainerProps = {|
onCancel: () => void,
isUserInteractionInProgress: boolean,
isSavingInProgress: boolean,
enrollmentMetadata: RegistrationFormMetadata,
formFoundation: ?RenderFoundation,
enrollmentMetadata: Enrollment,
formFoundation: RenderFoundation,
formId: ?string,
saveButtonText: string,
|};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,18 @@ type CommonEventDetails = {
enrollment?: string,
scheduledAt: string,
dataValues: Array<{ dataElement: string, value: any }>,
status?: string,
status: 'ACTIVE' | 'VISITED' | 'COMPLETED' | 'SCHEDULE' | 'OVERDUE' | 'SKIPPED',
}

export type RequestEvent = {
...CommonEventDetails,
occurredAt: string,
notes?: Array<{ value: string }>,
completedAt?: string,
}

export type LinkedRequestEvent = {
...CommonEventDetails,
occurredAt?: string,
completedAt?: string,
}

export type ConvertedRelatedStageEventProps = {|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const EnrollmentEditEventPageComponent = ({
onSaveAssigneeError,
onDeleteTrackedEntitySuccess,
onAccessLostFromTransfer,
onNavigateToEvent,
}: PlainProps) => (
<OrgUnitFetcher orgUnitId={orgUnitId}>
<TopBar
Expand Down Expand Up @@ -121,6 +122,7 @@ export const EnrollmentEditEventPageComponent = ({
onAccessLostFromTransfer={onAccessLostFromTransfer}
feedbackEmptyText={i18n.t('No feedback for this event yet')}
indicatorEmptyText={i18n.t('No indicator output for this event yet')}
onNavigateToEvent={onNavigateToEvent}
/>
<NoticeBox formId={`${dataEntryIds.ENROLLMENT_EVENT}-${mode}`} />
</OrgUnitFetcher>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,17 @@ const EnrollmentEditEventPageWithContextPlain = ({
const onGoBack = () =>
history.push(`/enrollment?${buildUrlQueryString({ enrollmentId })}`);

const onNavigateToEvent = (eventIdToRedirectTo: string) => {
history.push(
`/enrollmentEventEdit?${buildUrlQueryString({
eventId: eventIdToRedirectTo,
orgUnitId,
programId,
enrollmentId,
})}`,
);
};

const onHandleScheduleSave = (eventData: Object) => {
dispatch(updateEnrollmentEvent(eventId, eventData));
history.push(`enrollment?${buildUrlQueryString({ enrollmentId })}`);
Expand Down Expand Up @@ -291,6 +302,7 @@ const EnrollmentEditEventPageWithContextPlain = ({
onSaveAssigneeError={onSaveAssigneeError}
events={enrollmentSite?.events}
onAccessLostFromTransfer={onAccessLostFromTransfer}
onNavigateToEvent={onNavigateToEvent}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export type PlainProps = {|
onDelete: () => void,
onAddNew: () => void,
onGoBack: () => void,
onNavigateToEvent: (eventId: string) => void,
onBackToMainPage: () => void,
onBackToDashboard: () => void,
onBackToViewEvent: () => void,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import {
AssigneeWidget,
WidgetTypes,
TwoEventWorkspace,
WidgetRelatedStagesWorkspace,
} from '../../common/EnrollmentOverviewDomain/EnrollmentPageLayout';

export const WidgetsForEnrollmentEventEdit: $ReadOnly<{ [key: string]: WidgetConfig }> = Object.freeze({
EditEventWorkspace,
TwoEventWorkspace,
WidgetRelatedStagesWorkspace,
EventNote,
AssigneeWidget,
...DefaultWidgetsForEnrollmentOverview,
Expand All @@ -26,6 +28,10 @@ export const DefaultPageLayout: PageLayoutConfig = {
type: WidgetTypes.COMPONENT,
name: 'EditEventWorkspace',
},
{
type: WidgetTypes.COMPONENT,
name: 'WidgetRelatedStagesWorkspace',
},
],
rightColumn: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type DefaultComponents = 'QuickActions'
| 'AssigneeWidget'
| 'NewEventWorkspace'
| 'EditEventWorkspace'
| 'WidgetRelatedStagesWorkspace'
| 'EnrollmentNote'
| 'EventNote'
| 'TrackedEntityRelationship'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ import type {
InputIndicatorProps,
} from '../../../../../WidgetFeedback/WidgetFeedback.types';
import { WidgetTwoEventWorkspace } from '../../../../../WidgetTwoEventWorkspace';
import { WidgetRelatedStages } from '../../../../../WidgetRelatedStages';
import {
EnrollmentPageKeys,
} from '../DefaultEnrollmentLayout.constants';

export const QuickActions: WidgetConfig = {
Component: EnrollmentQuickActions,
Expand Down Expand Up @@ -286,3 +290,29 @@ export const EventNote: WidgetConfig = {
dataEntryId,
}),
};

export const WidgetRelatedStagesWorkspace: WidgetConfig = {
Component: WidgetRelatedStages,
shouldHideWidget: ({ currentPage }) => currentPage === EnrollmentPageKeys.EDIT_EVENT,
getProps: ({
program,
stageId,
enrollmentId,
eventId,
teiId,
onUpdateEnrollmentStatus,
onUpdateEnrollmentStatusSuccess,
onUpdateEnrollmentStatusError,
onNavigateToEvent,
}) => ({
programId: program.id,
programStageId: stageId,
enrollmentId,
eventId,
teiId,
onUpdateEnrollment: onUpdateEnrollmentStatus,
onUpdateEnrollmentSuccess: onUpdateEnrollmentStatusSuccess,
onUpdateEnrollmentError: onUpdateEnrollmentStatusError,
onNavigateToEvent,
}),
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Widget } from '../../Widget';
import { DataEntry } from '../DataEntry';
import { FinishButtons } from '../FinishButtons';
import { SavingText } from '../SavingText';
import { WidgetRelatedStages } from '../../WidgetRelatedStages';
import { RelatedStagesActions } from '../../WidgetRelatedStages';
import type { Props } from './validated.types';

const styles = () => ({
Expand Down Expand Up @@ -47,7 +47,7 @@ const ValidatedPlain = ({
id={id}
orgUnit={orgUnit}
/>
<WidgetRelatedStages
<RelatedStagesActions
ref={relatedStageRef}
enrollmentId={enrollmentId}
programId={programId}
Expand Down
Loading
Loading