-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [DHIS2-17655] Two event workspace (#3726)
- Loading branch information
1 parent
c08efd0
commit bad5312
Showing
17 changed files
with
659 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...ture-core/components/WidgetTwoEventWorkspace/FlatListOrgUnitField/FlatListOrgUnitField.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
3 changes: 3 additions & 0 deletions
3
...ore_modules/capture-core/components/WidgetTwoEventWorkspace/FlatListOrgUnitField/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// @flow | ||
|
||
export { FlatListOrgUnitField } from './FlatListOrgUnitField'; |
59 changes: 59 additions & 0 deletions
59
...ules/capture-core/components/WidgetTwoEventWorkspace/WidgetTwoEventWorkspace.component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Oops, something went wrong.