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-17655] Two event workspace #3726

Merged
merged 22 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e03ea54
feat: add plugin functionality
eirikhaugstulen Jun 17, 2024
1b23658
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-17591…
eirikhaugstulen Jun 18, 2024
5b5497b
chore: flow
eirikhaugstulen Jun 18, 2024
2504789
feat: support plugins in program stages
eirikhaugstulen Jun 18, 2024
e599d05
chore: flow
eirikhaugstulen Jun 18, 2024
5e96878
fix: option set logic
eirikhaugstulen Jun 19, 2024
1cb4612
fix: review
eirikhaugstulen Jun 30, 2024
c9aab55
fix: pass in cached element definitions
eirikhaugstulen Jul 1, 2024
5dd3ac6
Merge remote-tracking branch 'refs/remotes/origin/master' into eh/fea…
eirikhaugstulen Jul 1, 2024
0c446d1
chore: temp
eirikhaugstulen Jul 3, 2024
ff6e800
Merge remote-tracking branch 'refs/remotes/origin/master' into eh/fea…
eirikhaugstulen Jul 3, 2024
0ed89ce
Merge remote-tracking branch 'refs/remotes/origin/master' into eh/fea…
eirikhaugstulen Jul 9, 2024
b44e501
fix: temp
eirikhaugstulen Jul 10, 2024
4e41c05
Merge remote-tracking branch 'refs/remotes/origin/master' into eh/fea…
eirikhaugstulen Jul 15, 2024
a0e58b8
feat: add two event workspace functionality
eirikhaugstulen Jul 23, 2024
6a8e097
Merge remote-tracking branch 'refs/remotes/origin/master' into eh/fea…
eirikhaugstulen Jul 23, 2024
b25455b
feat: lint
eirikhaugstulen Jul 23, 2024
5561bd5
Merge remote-tracking branch 'refs/remotes/origin/master' into eh/fea…
eirikhaugstulen Jul 31, 2024
aea077f
feat: add subvalues
eirikhaugstulen Aug 8, 2024
ffcf09d
Merge remote-tracking branch 'refs/remotes/origin/master' into eh/fea…
eirikhaugstulen Aug 8, 2024
97d11ba
chore: remove attribute
eirikhaugstulen Aug 8, 2024
656b471
fix: add fallback for v39 and v40
eirikhaugstulen Aug 13, 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
18 changes: 15 additions & 3 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ msgstr ""
"(in the same domain). Please refresh this page if you would like to use "
"this version again, but be aware that this will close other versions."

msgid "More"
msgstr "More"

msgid "View {{programName}} dashboard"
msgstr "View {{programName}} dashboard"

Expand Down Expand Up @@ -985,6 +988,9 @@ msgstr "The enrollment event data could not be found"
msgid "Loading"
msgstr "Loading"

msgid "An error occurred while loading the form"
msgstr "An error occurred while loading the form"

msgid "Possible duplicates found"
msgstr "Possible duplicates found"

Expand Down Expand Up @@ -1527,6 +1533,15 @@ msgstr "{{ scheduledEvents }} scheduled"
msgid "Stages and Events"
msgstr "Stages and Events"

msgid "An error occurred while loading the widget."
msgstr "An error occurred while loading the widget."

msgid "View linked event"
msgstr "View linked event"

msgid "Scheduled"
msgstr "Scheduled"

msgid "Changelog"
msgstr "Changelog"

Expand Down Expand Up @@ -1693,9 +1708,6 @@ msgstr "An error has occured. See log for details"
msgid "Scheduled{{ escape }} due {{ time }}"
msgstr "Scheduled{{ escape }} due {{ time }}"

msgid "Scheduled"
msgstr "Scheduled"

msgid "Overdue{{ escape }} due {{ time }}"
msgstr "Overdue{{ escape }} due {{ time }}"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import * as React from 'react';
import i18n from '@dhis2/d2-i18n';
import { useRef, useState } from 'react';
import { Button, Layer, Popper } from '@dhis2/ui';

Expand Down Expand Up @@ -42,6 +43,7 @@ export const OverflowButton = ({
return (
<div ref={anchorRef}>
<Button
aria-label={label ?? i18n.t('More')}
primary={primary}
secondary={secondary}
dataTest={dataTest}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,23 @@ import {
EventNote,
AssigneeWidget,
WidgetTypes,
TwoEventWorkspace,
} from '../../common/EnrollmentOverviewDomain/EnrollmentPageLayout';

export const WidgetsForEnrollmentEventEdit: $ReadOnly<{ [key: string]: WidgetConfig }> = Object.freeze({
EditEventWorkspace,
TwoEventWorkspace,
EventNote,
AssigneeWidget,
...DefaultWidgetsForEnrollmentOverview,
});

export const DefaultPageLayout: PageLayoutConfig = {
leftColumn: [
{
type: WidgetTypes.COMPONENT,
name: 'TwoEventWorkspace',
},
{
type: WidgetTypes.COMPONENT,
name: 'EditEventWorkspace',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type DefaultComponents = 'QuickActions'
| 'AssigneeWidget'
| 'NewEventWorkspace'
| 'EditEventWorkspace'
| 'TwoEventWorkspace'
| 'EnrollmentNote'
| 'EventNote'
| 'TrackedEntityRelationship'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ const EnrollmentPageLayoutPlain = ({

const allProps = useMemo(() => ({
...passOnProps,
currentPage,
toggleVisibility,
addRelationShipContainerElement,
}), [addRelationShipContainerElement, passOnProps, toggleVisibility]);
}), [addRelationShipContainerElement, currentPage, passOnProps, toggleVisibility]);

const {
leftColumnWidgets,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import type {
InputFeedbackProps,
InputIndicatorProps,
} from '../../../../../WidgetFeedback/WidgetFeedback.types';
import { WidgetTwoEventWorkspace } from '../../../../../WidgetTwoEventWorkspace';

export const QuickActions: WidgetConfig = {
Component: EnrollmentQuickActions,
Expand Down Expand Up @@ -242,6 +243,17 @@ export const EditEventWorkspace: WidgetConfig = {
}),
};

export const TwoEventWorkspace: WidgetConfig = {
Component: WidgetTwoEventWorkspace,
getProps: ({ currentPage, eventId, program, stageId, orgUnitId }) => ({
currentPage,
eventId,
programId: program.id,
orgUnitId,
stageId,
}),
};

export const AssigneeWidget: WidgetConfig = {
Component: WidgetAssignee,
getProps: ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ type WidgetProps = {|
...Props,
|}

export const WidgetEventEditWrapper = ({ pageStatus, programId, stageId, ...passOnProps }: WidgetProps) => {
export const WidgetEventEditWrapper = ({ pageStatus, ...passOnProps }: WidgetProps) => {
const {
programId,
stageId,
} = passOnProps;

const {
formFoundation,
stage,
Expand All @@ -34,14 +39,22 @@ export const WidgetEventEditWrapper = ({ pageStatus, programId, stageId, ...pass
);
}

if (isLoading || !formFoundation || !stage || isError) {
if (isLoading) {
return (
<div>
{i18n.t('Loading')}
</div>
);
}

if (!formFoundation || !stage || isError) {
return (
<div>
{i18n.t('An error occurred while loading the form')}
</div>
);
}

return (
<WidgetEventEdit
{...passOnProps}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// @flow
import React from 'react';
import { useOrgUnitName } from '../../../metadataRetrieval/orgUnitName';

type Props = {
orgUnitId: string,
}

export const FlatListOrgUnitField = ({
orgUnitId,
}: Props) => {
const { displayName } = useOrgUnitName(orgUnitId);

return (
<span>
{displayName}
</span>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @flow

export { FlatListOrgUnitField } from './FlatListOrgUnitField';
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// @flow
import React, { useMemo } from 'react';
import { spacers } from '@dhis2/ui';
import { FlatList } from 'capture-ui';
import withStyles from '@material-ui/core/styles/withStyles';
import type { RenderFoundation } from '../../metaData';
import { getDataEntryDetails, Placements } from './utils/getDataEntryDetails';

type Props = {
linkedEvent: any,
dataValues: any,
formFoundation: RenderFoundation,
classes: {
container: string,
},
}

const styles = {
container: {
padding: `${spacers.dp8} ${spacers.dp16}`,
display: 'flex',
flexDirection: 'column',
gap: spacers.dp8,
},
};

const WidgetTwoEventWorkspacePlain = ({ linkedEvent, dataValues, formFoundation, classes }: Props) => {
const dataEntryValues = useMemo(() => getDataEntryDetails(
linkedEvent,
formFoundation,
), [linkedEvent, formFoundation]);

const listValues = useMemo(() => {
const elements = formFoundation.getElements();

return elements.map((dataElement) => {
const value = dataValues[dataElement.id];
return {
key: dataElement.formName,
value: value ?? '',
reactKey: dataElement.id,
};
}).filter(Boolean);
}, [dataValues, formFoundation]);

return (
<div className={classes.container}>
<FlatList
list={[
...dataEntryValues[Placements.TOP],
...listValues,
...dataEntryValues[Placements.BOTTOM],
]}
/>
</div>
);
};

export const WidgetTwoEventWorkspaceComponent = withStyles(styles)(WidgetTwoEventWorkspacePlain);
Loading
Loading