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-12615][DHIS2-12616][DHIS2-15906] Add new Relationship (Feature-parity) #3401

Merged
merged 133 commits into from
Oct 24, 2023
Merged
Changes from 1 commit
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
ac4b6fe
feat: [DHIS2-12362] add widget relationship component
jasminenguyennn Jan 21, 2022
7d9f3de
feat: first draft to New TEI relationship
eirikhaugstulen Jan 21, 2022
07b42fa
feat: [DHIS2-12362] add relationship widget
jasminenguyennn Jan 25, 2022
c85b9d0
feat: [DHIS2-12362] compute tei data
jasminenguyennn Jan 26, 2022
11a2bf7
feat: [DHIS2-12362] add relationship in redux
jasminenguyennn Jan 27, 2022
9362c1a
feat: [DHIS2-12362] minor change
jasminenguyennn Jan 27, 2022
f15bf33
Merge remote-tracking branch 'origin/master' into eh/feat/new-tei-rel…
eirikhaugstulen Jan 30, 2022
addbe06
feat: first draft to new TEI relationshiphandler
eirikhaugstulen Jan 31, 2022
98445b7
fix: add constraint to state
eirikhaugstulen Feb 3, 2022
e944f77
Merge branch 'master' into DHIS2-12362
jasminenguyennn Feb 4, 2022
748fecc
fix: [DHIS2-12362] minor update
jasminenguyennn Feb 4, 2022
56c568b
fix: [DHIS2-12362] minor update
jasminenguyennn Feb 4, 2022
6b6d0dd
fix: [DHIS2-12362] add event relationshio
jasminenguyennn Feb 4, 2022
2fb5620
fix: [DHIS2-12362] update tet
jasminenguyennn Feb 7, 2022
279f639
chore: [DHIS2-12362] cleanup fromconstraint
jasminenguyennn Feb 8, 2022
d8a1e89
fix: [DHIS2-12362] fix flow
jasminenguyennn Feb 8, 2022
6ff4edb
fix: [DHIS2-12362] fix flow
jasminenguyennn Feb 8, 2022
fd5c535
fix: [DHIS2-12362] fix flow
jasminenguyennn Feb 8, 2022
5faa3e1
fix: [DHIS2-12362] fix flow
jasminenguyennn Feb 8, 2022
65b9ecc
fix: [DHIS2-12362] minor fix
jasminenguyennn Feb 8, 2022
a9492bd
fix: [DHIS2-12362] minor fix
jasminenguyennn Feb 8, 2022
6650036
fix: [DHIS2-12362] minor fix
jasminenguyennn Feb 8, 2022
8f3a652
Merge branch 'master' into DHIS2-12362
jasminenguyennn Feb 14, 2022
02a2802
chore: [DHIS2-12362] update relationships
jasminenguyennn Feb 14, 2022
e9b4a70
chore: [DHIS2-12362] update relationships
jasminenguyennn Feb 14, 2022
eb7239d
fix: [DHIS2-12362] fix flow
jasminenguyennn Feb 14, 2022
ffb7b2f
feat: [DHIS2-12362] add relationship to view enrollment event
jasminenguyennn Feb 15, 2022
4abf6ef
Merge remote-tracking branch 'origin/master' into eh/feat/new-tei-rel…
eirikhaugstulen Feb 17, 2022
d0b115d
fix: changed object for displaying relationships & breadcrumbs
eirikhaugstulen Feb 18, 2022
d88383a
feat: initial layout for linking relationship to existing TEI
eirikhaugstulen Feb 25, 2022
f9dd6e1
fix: close modal on link complete
eirikhaugstulen Feb 25, 2022
7d8b4b7
fix: LGTM
eirikhaugstulen Feb 25, 2022
7c76be0
Merge branch 'master' into DHIS2-12362
jasminenguyennn Mar 2, 2022
88cf85a
Merge branch 'master' into DHIS2-12362
jasminenguyennn Mar 9, 2022
09fa106
Merge branch 'master' into DHIS2-12362
jasminenguyennn Mar 14, 2022
5c66bcd
Merge branch 'master' into DHIS2-12362
jasminenguyennn Mar 20, 2022
363d214
chore: [DHIS2-12362] refactor
jasminenguyennn Mar 23, 2022
6ebc99d
chore: [DHIS2-12362] rename funcs
jasminenguyennn Mar 24, 2022
bdb5562
chore: [DHIS2-12362] use new API
jasminenguyennn Mar 24, 2022
7dd0f93
chore: [DHI2-12362] change type
jasminenguyennn Mar 24, 2022
038ce39
chore: [DHI2-12362] change type
jasminenguyennn Mar 24, 2022
0e43a26
chore: [DHIS2-12362] fix edit event
jasminenguyennn Mar 25, 2022
3b2f70a
Merge branch 'master' into DHIS2-12362
jasminenguyennn Mar 25, 2022
42e6032
Merge branch 'master' into DHIS2-12362
jasminenguyennn Apr 6, 2022
72b7df5
chore: [DHIS2-12362] minor change
jasminenguyennn Apr 6, 2022
7f97c0f
fix: [DHIS2-12362] fix combinations
jasminenguyennn Apr 8, 2022
a788cd1
Merge branch 'master' into DHIS2-12362
jasminenguyennn Apr 21, 2022
f309105
chore: [DHIS2-12362] restructure the components
jasminenguyennn Apr 30, 2022
5183509
Merge branch 'master' into DHIS2-12362
jasminenguyennn May 1, 2022
9682ffe
chore: [DHIS2-12362] change await/async loop
jasminenguyennn May 2, 2022
4e55df3
feat: [DHIS2-12377] Event relationship (#2726)
jasminenguyennn May 2, 2022
ab89592
chore: [DHIS2-12362] address review comments
jasminenguyennn May 4, 2022
dbfe1fb
chore: [DHIS2-12362] rename files
jasminenguyennn May 4, 2022
5a7eec4
chore: [DHIS2-12362] minor change
jasminenguyennn May 5, 2022
e92c9b2
feat: [DHIS2-12362] add display fields
jasminenguyennn May 5, 2022
594ca2a
feat: [DHIS2-12362] add display fields
jasminenguyennn May 5, 2022
81672fc
feat: [DHIS2-12362] add display fields
jasminenguyennn May 5, 2022
015c4b3
chore: [DHIS2-12362] minor change
jasminenguyennn May 5, 2022
2d1af84
chore:[DHIS2-12362] update user storage
jasminenguyennn May 10, 2022
6f09736
chore: [DHIS2-12362] minor change
jasminenguyennn May 10, 2022
7efe0ef
chore: [DHIS2-12362] add creation date
jasminenguyennn May 19, 2022
4e21fc4
chore: [DHIS2-12362] update event
jasminenguyennn May 23, 2022
9ae1f0e
Merge branch 'master' into DHIS2-12362
jasminenguyennn May 23, 2022
ef24bc2
chore: [DHIS2-12362] move type def
jasminenguyennn May 23, 2022
3bce665
chore: [DHIS2-12362] move type def
jasminenguyennn May 23, 2022
59e1026
chore: [DHIS2-12362] minor fix
jasminenguyennn May 23, 2022
f3d5d2d
chore: [DHIS2-12362] return all types
jasminenguyennn May 24, 2022
587180c
Merge branch 'master' into DHIS2-12362
jasminenguyennn May 24, 2022
0607b79
chore: [DHIS2-12362] add created relationship date
jasminenguyennn Jun 4, 2022
c68a666
chore: [DHIS2-12362] use display name
jasminenguyennn Jun 9, 2022
a638306
Merge branch 'master' into DHIS2-12362
jasminenguyennn Jun 27, 2022
419ae84
fix: [DHIS2-13202] fix occurred at label in stages
jasminenguyennn Jul 15, 2022
9202d4d
Merge branch 'master' into DHIS2-12362
jasminenguyennn Jul 20, 2022
8c1fd1e
fix: [DHIS2-12362] cypress
jasminenguyennn Jul 20, 2022
6d2e029
Merge branch 'master' into DHIS2-12362
jasminenguyennn Jul 22, 2022
17836e2
Merge branch 'master' into DHIS2-12362
jasminenguyennn Jul 26, 2022
9886119
Merge branch 'master' into DHIS2-12362
jasminenguyennn Jul 28, 2022
5fd15f8
fix: [DHIS2-12362] convert date
jasminenguyennn Aug 2, 2022
c689e4d
chore: [DHIS2-12362] UI improvements
jasminenguyennn Aug 29, 2022
63bc722
chore: [DHIS2-12362] minor
jasminenguyennn Aug 29, 2022
83cbc52
fix: [DHIS2-12362] fix flow
jasminenguyennn Aug 29, 2022
8d099c0
Merge branch 'master' into DHIS2-12362
jasminenguyennn Aug 29, 2022
d184468
chore: [DHIS2-12362] sort most recent event
jasminenguyennn Aug 30, 2022
bd912e1
Merge branch 'master' into DHIS2-12362
jasminenguyennn Aug 30, 2022
320259c
feat: [DHIS2-12372] view linked record (#2780)
jasminenguyennn Aug 30, 2022
067e1a5
Merge branch 'master' into DHIS2-12362
jasminenguyennn Sep 2, 2022
b60af3f
Merge branch 'DHIS2-12362' of work:dhis2/capture-app into DHIS2-12362
jasminenguyennn Sep 2, 2022
ee5b02f
Merge branch 'master' into DHIS2-12362
jasminenguyennn Sep 12, 2022
2c91cc6
chore: useMetadataQuery utility method
JoakimSM Dec 8, 2022
a87bb76
chore: useIndexedDB utility method
JoakimSM Dec 8, 2022
0f8ece0
feat: changed a hook to implement the custom hooks
eirikhaugstulen Dec 13, 2022
7fa38a2
fix: added error handling to the useIndexedDBQuery
eirikhaugstulen Dec 21, 2022
25cec6e
feat: init relationships
JoakimSM Jun 16, 2022
a36e9f7
Merge remote-tracking branch 'origin/eh/TECH/TECH-1486_UtilityHookFor…
JoakimSM Jan 5, 2023
67b827a
feat: continue relationships
JoakimSM Jan 5, 2023
bc15dc4
Merge branch 'master' into DHIS2-12615
JoakimSM Apr 18, 2023
1e76f2f
fix: postmerge
JoakimSM Apr 18, 2023
7a5cf96
Merge remote-tracking branch 'origin/DHIS2-12362' into DHIS2-12615
eirikhaugstulen Apr 24, 2023
dc5b88d
chore: temp
eirikhaugstulen Apr 27, 2023
43a9c57
feat: first iteration of Relationships Widget
eirikhaugstulen May 2, 2023
7685ec3
fix: code cleanup
eirikhaugstulen May 3, 2023
c3331c8
chore: review comments
eirikhaugstulen May 23, 2023
518456a
chore: review comments
eirikhaugstulen May 26, 2023
4ad1bea
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-12362…
eirikhaugstulen May 26, 2023
5c49e06
feat: [DHIS2-12362] display relationships
JoakimSM Jun 5, 2023
7ebdb59
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-12615…
eirikhaugstulen Jul 21, 2023
c14d0eb
feat: add search functionality
eirikhaugstulen Jul 22, 2023
cb5aa6c
Merge remote-tracking branch 'origin/eh/epics/DHIS2-12361_TeiRelation…
eirikhaugstulen Jul 28, 2023
350d2ac
chore: flow
eirikhaugstulen Jul 28, 2023
438d2cd
feat: [DHIS2-12362][DHIS2-12455] View and filter relationships (#3241)
eirikhaugstulen Jul 28, 2023
4b88893
Merge remote-tracking branch 'origin/eh/epics/DHIS2-12361_TeiRelation…
eirikhaugstulen Jul 28, 2023
30c77c4
chore: flow
eirikhaugstulen Jul 28, 2023
14a2530
chore: temp
eirikhaugstulen Aug 4, 2023
72ac535
feat: create new tei from relationship
eirikhaugstulen Aug 14, 2023
261d312
fix: change program in search
eirikhaugstulen Aug 14, 2023
cb84cf4
chore: upgrade cacheVersion
eirikhaugstulen Aug 15, 2023
c7eafe7
fix: chore remove success snackbar
eirikhaugstulen Aug 24, 2023
abdf53c
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-12616…
eirikhaugstulen Sep 11, 2023
f943323
fix: pr-review
eirikhaugstulen Sep 11, 2023
04e93ed
fix: pr-review
eirikhaugstulen Sep 12, 2023
ebe355d
Merge remote-tracking branch 'origin/master' into eh/epics/DHIS2-1236…
eirikhaugstulen Sep 12, 2023
bc933b6
Merge remote-tracking branch 'origin/eh/epics/DHIS2-12361_TeiRelation…
eirikhaugstulen Sep 12, 2023
07766e1
chore: typo
eirikhaugstulen Sep 12, 2023
d978ed8
chore: loading spinner
eirikhaugstulen Sep 12, 2023
f880324
chore: pr-reviews
eirikhaugstulen Sep 28, 2023
a93bef9
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-12616…
eirikhaugstulen Oct 3, 2023
6016b85
feat: [DHIS2-15906] Add form features for relationship
eirikhaugstulen Oct 17, 2023
afb28dc
docs: [DHIS2-12361] Relationships widget (#3430)
eirikhaugstulen Oct 20, 2023
3ab905d
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-12616…
eirikhaugstulen Oct 20, 2023
c9f297b
chore: bump cache version
eirikhaugstulen Oct 22, 2023
d677101
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-12616…
eirikhaugstulen Oct 23, 2023
b0b54e5
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-12616…
eirikhaugstulen Oct 24, 2023
7bb1032
chore: change tests
eirikhaugstulen Oct 24, 2023
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
Prev Previous commit
Next Next commit
fix: [DHIS2-12362] add event relationshio
  • Loading branch information
jasminenguyennn committed Feb 4, 2022
commit 6b6d0dd593e4eb95722977bd4b7953e798b11d23
Original file line number Diff line number Diff line change
@@ -79,7 +79,11 @@ export const EnrollmentPageDefaultPlain = ({
<WidgetEnrollmentComment />
<WidgetError error={widgetEffects?.errors} />
<WidgetWarning warning={widgetEffects?.warnings} />
<WidgetRelationship title={i18n.t("TEI's Relationships")} relationships={relationships} />
<WidgetRelationship
title={i18n.t("TEI's Relationships")}
relationships={relationships}
onAddRelationship={() => {}}
/>
{!hideWidgets.indicator && (
<WidgetIndicator
indicators={widgetEffects?.indicators}
Original file line number Diff line number Diff line change
@@ -84,6 +84,7 @@ export const EnrollmentPageDefault = () => {
stages={stages}
events={enrollment?.events}
enrollmentId={enrollmentId}
// $FlowFixMe
relationships={{ relationshipsByType, headersByType }}
onDelete={onDelete}
onViewAll={onViewAll}
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
// @flow
import { useMemo } from 'react';
import { type TEIData, type TEIRelationship } from '../../../common/EnrollmentOverviewDomain/useCommonEnrollmentDomainData';

const getRelationshipAttributes = (bidirectional: boolean, teiId: string, from: TEIData, to: TEIData) => {
const { attributes: fromAttributes, trackedEntityInstance: fromTeiId } = from.trackedEntityInstance;
const { attributes: toAttributes, trackedEntityInstance: toTeiId } = to.trackedEntityInstance;

if (!bidirectional) { return { id: toTeiId, attributes: toAttributes }; }

return fromTeiId !== teiId
? { id: fromTeiId, attributes: fromAttributes }
: { id: toTeiId, attributes: toAttributes };
import type {
TEIRelationship, RelationshipData,
} from '../../../common/EnrollmentOverviewDomain/useCommonEnrollmentDomainData';

const getRelationshipAttributes = (
bidirectional: boolean,
teiId: string,
from: RelationshipData,
to: RelationshipData,
) => {
if (from.event) {
return {
id: from.event.event, attributes: from.event.dataValues,
};
}
if (to.trackedEntityInstance) {
const { attributes: fromAttributes, trackedEntityInstance: fromTeiId } = from.trackedEntityInstance;
const { attributes: toAttributes, trackedEntityInstance: toTeiId } = to.trackedEntityInstance;

if (!bidirectional) { return { id: toTeiId, attributes: toAttributes }; }
return fromTeiId !== teiId
? { id: fromTeiId, attributes: fromAttributes }
: { id: toTeiId, attributes: toAttributes };
}
return {};
};

export const useComputeTEIRelationships = (teiId: string, relationships?: ?{[key: string]: Array<TEIRelationship>}) => {
const relationshipsByType = useMemo(() => (relationships?.[teiId]?.reduce((acc, currentRelationship) => {
const { relationshipType: typeId, relationshipName, bidirectional, from, to } = currentRelationship;
const typeExist = acc.find(item => item.id === typeId);
const relationshipAttributes = getRelationshipAttributes(bidirectional, teiId, from, to);

if (typeExist) {
typeExist.relationshipAttributes.push(relationshipAttributes);
} else {
@@ -30,11 +43,11 @@ export const useComputeTEIRelationships = (teiId: string, relationships?: ?{[key
}
return acc;
}, [])), [teiId, relationships]);

// this will change after https://jira.dhis2.org/browse/DHIS2-12249 is done
const headersByType = useMemo(() => (relationshipsByType?.reduce((acc, { id, relationshipAttributes }) => {
acc[id] = relationshipAttributes.reduce((accAttr, { attributes }) => {
accAttr.push(attributes.map(item => ({ id: item.attribute, label: item.displayName })));
// $FlowFixMe
accAttr.push(attributes.map(item => ({ id: item.attribute ?? item.dataElement, label: item.displayName })));
return accAttr;
}, []).reduce((p, current) => p.filter(e => current.find(item => item.id === e.id)));

Original file line number Diff line number Diff line change
@@ -62,19 +62,25 @@ export type TEIData = {|
}
|}

export type EventData = {|
event: Event
|}

export type RelationshipData = TEIData | EventData

export type TEIRelationship = {|
relationshipType: string,
relationshipName: string,
relationship: string,
bidirectional: boolean,
from: TEIData,
to: TEIData
from: RelationshipData,
to: RelationshipData
|}

export type OutputRelationship = {
id: string,
relationshipName: string,
relationshipAttributes: Array<{ id: string, attributes: Array<TEIAttribute>}>
relationshipAttributes: Array<{ id: string, attributes: Array<RelationshipData>}>
}

export type Output = {|
Original file line number Diff line number Diff line change
@@ -39,10 +39,13 @@ export const RelationshipTable = (props: Props) => {
}
return relationshipAttributes.map(({ id: teiId, attributes }) => (
<DataTableRow key={teiId}>
{headers.map(({ id }) => (<DataTableCell key={id}>
{attributes.find(att => att.attribute === id).value}
</DataTableCell>
))}
{headers.map(({ id }) => {
const attribute = attributes.find(att => att.attribute === id || att.dataElement === id);
return (<DataTableCell key={id}>
{attribute?.value}
</DataTableCell>
);
})}
</DataTableRow>
));
};
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// @flow
import React, { type ComponentType } from 'react';
import { withStyles } from '@material-ui/core';
import { spacersNum, spacers, colors } from '@dhis2/ui';
import i18n from '@dhis2/d2-i18n';
import { spacersNum, spacers, colors, Button } from '@dhis2/ui';
import { RelationshipTable } from './RelationshipTable';

type Props = {
relationshipsByType: Object,
headersByType: Object,
onAddRelationship: void,
...CssClasses,
}

@@ -22,21 +24,26 @@ const styles = {
},
wrapper: {
paddingBottom: spacersNum.dp16,
overflow: 'scroll',
},
};
const RelationshipsPlain = ({ relationshipsByType, headersByType, classes }: Props) => (<div
data-test="relationships"
className={classes.container}
>
{
relationshipsByType ? relationshipsByType.map((relationship) => {
const { relationshipName, id, ...passOnProps } = relationship;
return (<div key={id} className={classes.wrapper}>
<div className={classes.title} >{relationshipName}</div>
<RelationshipTable headers={headersByType[id]} {...passOnProps} />
</div>);
}) : null
}
</div>);
const RelationshipsPlain = ({ relationshipsByType, headersByType, classes, onAddRelationship }: Props) => (
<div
data-test="relationships"
className={classes.container}
>
{
relationshipsByType ? relationshipsByType.map((relationship) => {
const { relationshipName, id, ...passOnProps } = relationship;
return (<div key={id} className={classes.wrapper}>
<div className={classes.title} >{relationshipName}</div>
<RelationshipTable headers={headersByType[id]} {...passOnProps} />
</div>);
}) : null
}
<Button onClick={onAddRelationship}>
{i18n.t('Add relationship')}
</Button>
</div>);

export const Relationships: ComponentType<Props> = withStyles(styles)(RelationshipsPlain);
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import { Widget } from '../Widget';
import type { Props } from './widgetRelationship.types';
import { Relationships } from './Relationships/';

export const WidgetRelationship = ({ relationships, title }: Props) => {
export const WidgetRelationship = ({ relationships, title, onAddRelationship }: Props) => {
const [open, setOpenStatus] = useState(true);

return (
@@ -25,7 +25,7 @@ export const WidgetRelationship = ({ relationships, title }: Props) => {
onClose={useCallback(() => setOpenStatus(false), [setOpenStatus])}
open={open}
>
<Relationships {...relationships} />
<Relationships {...relationships} onAddRelationship={onAddRelationship} />
</Widget>
</div>
);
Original file line number Diff line number Diff line change
@@ -4,5 +4,6 @@
export type Props = {|
relationships: Object,
title: string,
onAddRelationship: void,
...CssClasses,
|};