-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
235 additions
and
88 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
62 changes: 62 additions & 0 deletions
62
...es/capture-core/components/WidgetTwoEventWorkspace/WidgetHeader/WidgetHeader.container.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,62 @@ | ||
// @flow | ||
import React, { type ComponentType } from 'react'; | ||
import { spacersNum } from '@dhis2/ui'; | ||
import { withStyles } from '@material-ui/core/'; | ||
import { EnrollmentPageKeys } | ||
from '../../Pages/common/EnrollmentOverviewDomain/EnrollmentPageLayout/DefaultEnrollmentLayout.constants'; | ||
import { NonBundledDhis2Icon } from '../../NonBundledDhis2Icon'; | ||
import type { PlainProps, Props } from './WidgetHeader.types'; | ||
import { OverflowMenuComponent } from '../OverflowMenu'; | ||
|
||
const styles = { | ||
menu: { | ||
marginLeft: 'auto', | ||
}, | ||
icon: { | ||
marginRight: spacersNum.dp8, | ||
}, | ||
}; | ||
|
||
const WidgetHeaderPlain = ({ | ||
linkedStage, | ||
linkedEvent, | ||
orgUnitId, | ||
currentPage, | ||
relationship, | ||
relationshipType, | ||
stage, | ||
eventId, | ||
classes, | ||
}: Props) => { | ||
const { icon } = linkedStage; | ||
return ( | ||
<> | ||
{icon && ( | ||
<div className={classes.icon}> | ||
<NonBundledDhis2Icon | ||
name={icon?.name} | ||
color={icon?.color} | ||
width={30} | ||
height={30} | ||
cornerRadius={2} | ||
/> | ||
</div> | ||
)} | ||
<span> {linkedStage.name} </span> | ||
{currentPage === EnrollmentPageKeys.VIEW_EVENT && ( | ||
<div className={classes.menu}> | ||
<OverflowMenuComponent | ||
linkedEvent={linkedEvent} | ||
relationshipId={relationship} | ||
relationshipType={relationshipType} | ||
orgUnitId={orgUnitId} | ||
originEventId={eventId} | ||
stageWriteAccess={stage?.access?.data?.write} | ||
/> | ||
</div> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export const WidgetHeader: ComponentType<PlainProps> = withStyles(styles)(WidgetHeaderPlain); |
20 changes: 20 additions & 0 deletions
20
...odules/capture-core/components/WidgetTwoEventWorkspace/WidgetHeader/WidgetHeader.types.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,20 @@ | ||
// @flow | ||
import { EnrollmentPageKeys } | ||
from '../../Pages/common/EnrollmentOverviewDomain/EnrollmentPageLayout/DefaultEnrollmentLayout.constants'; | ||
import type { ProgramStage } from '../../../metaData'; | ||
|
||
export type PlainProps = {| | ||
orgUnitId: string, | ||
linkedEvent: { event: string }, | ||
linkedStage: ProgramStage, | ||
currentPage: $Values<typeof EnrollmentPageKeys> | string, | ||
relationship: string, | ||
relationshipType: string, | ||
stage: ProgramStage, | ||
eventId: string, | ||
|}; | ||
|
||
export type Props = {| | ||
...PlainProps, | ||
...CssClasses, | ||
|}; |
2 changes: 2 additions & 0 deletions
2
src/core_modules/capture-core/components/WidgetTwoEventWorkspace/WidgetHeader/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,2 @@ | ||
// @flow | ||
export { WidgetHeader } from './WidgetHeader.container'; |
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
5 changes: 5 additions & 0 deletions
5
...s/capture-core/components/WidgetTwoEventWorkspace/WidgetTwoEventWorkspaceWrapper.const.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,5 @@ | ||
// @flow | ||
|
||
export const WidgetTwoEventWorkspaceWrapperTypes = { | ||
EDIT_EVENT: 'editEvent', | ||
}; |
74 changes: 74 additions & 0 deletions
74
.../capture-core/components/WidgetTwoEventWorkspace/WidgetWrapper/WidgetWrapper.container.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,74 @@ | ||
// @flow | ||
import React from 'react'; | ||
import { colors, spacersNum, IconLink16 } from '@dhis2/ui'; | ||
import i18n from '@dhis2/d2-i18n'; | ||
import { withStyles } from '@material-ui/core/'; | ||
import type { Props } from './WidgetWrapper.types'; | ||
import { WidgetTwoEventWorkspaceWrapperTypes } from '../index'; | ||
|
||
const styles = { | ||
container: { | ||
width: 'fit-content', | ||
marginBottom: '16px', | ||
margin: '16px', | ||
}, | ||
header: { | ||
display: 'flex', | ||
alignItems: 'center', | ||
paddingBottom: spacersNum.dp16, | ||
fontWeight: 500, | ||
fontSize: 16, | ||
color: colors.grey800, | ||
}, | ||
referalResponse: { | ||
padding: spacersNum.dp16, | ||
backgroundColor: colors.blue100, | ||
borderRadius: '3px', | ||
}, | ||
linkedEvent: { | ||
color: colors.blue900, | ||
verticalAlign: 'middle', | ||
display: 'flex', | ||
fontSize: '16px', | ||
fontWeight: '500', | ||
}, | ||
icon: { | ||
marginRight: spacersNum.dp8, | ||
}, | ||
decription: { | ||
margin: `${spacersNum.dp8}px 0`, | ||
}, | ||
}; | ||
|
||
const WidgetWrapperPlain = ({ widget, type, stage, linkedStage, classes }: Props) => { | ||
if (type === WidgetTwoEventWorkspaceWrapperTypes.EDIT_EVENT) { | ||
return ( | ||
<div className={classes.container}> | ||
<div className={classes.header}> {stage?.name} </div> | ||
<div className={classes.referalResponse}> | ||
<div className={classes.linkedEvent}> | ||
<span className={classes.icon}> | ||
<IconLink16 color={colors.blue800} /> | ||
</span> | ||
<div>{i18n.t('Linked event')}</div> | ||
</div> | ||
<div className={classes.decription}> | ||
{i18n.t( | ||
'This {{stageName}} event is linked to a {{linkedStageName}} event. Review the linked event details before entering data below', | ||
{ | ||
linkedStageName: linkedStage?.name, | ||
stageName: stage?.name, | ||
interpolation: { escapeValue: false }, | ||
}, | ||
)} | ||
</div> | ||
{widget} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
return <>{widget}</>; | ||
}; | ||
|
||
export const WidgetWrapper = withStyles(styles)(WidgetWrapperPlain); |
15 changes: 15 additions & 0 deletions
15
...ules/capture-core/components/WidgetTwoEventWorkspace/WidgetWrapper/WidgetWrapper.types.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,15 @@ | ||
// @flow | ||
import { WidgetTwoEventWorkspaceWrapperTypes } from '../index'; | ||
import type { ProgramStage } from '../../../metaData'; | ||
|
||
type PlainProps = {| | ||
widget: any, | ||
linkedStage: ProgramStage, | ||
stage?: ProgramStage, | ||
type?: $Values<typeof WidgetTwoEventWorkspaceWrapperTypes>, | ||
|}; | ||
|
||
export type Props = {| | ||
...PlainProps, | ||
...CssClasses, | ||
|}; |
2 changes: 2 additions & 0 deletions
2
src/core_modules/capture-core/components/WidgetTwoEventWorkspace/WidgetWrapper/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,2 @@ | ||
// @flow | ||
export { WidgetWrapper } from './WidgetWrapper.container'; |
Oops, something went wrong.