diff --git a/i18n/en.pot b/i18n/en.pot index 2720600aa4..0bb33c9118 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -709,6 +709,9 @@ msgstr "" msgid "Save as new" msgstr "" +msgid "View dashboard" +msgstr "" + msgid "Create for" msgstr "" @@ -802,9 +805,6 @@ msgstr "" msgid "Choose a type to start searching" msgstr "" -msgid "View dashboard" -msgstr "" - msgid "View active enrollment" msgstr "" diff --git a/src/core_modules/capture-core/components/CardList/CardList.component.js b/src/core_modules/capture-core/components/CardList/CardList.component.js index 630b3d5c45..8e504f89cc 100644 --- a/src/core_modules/capture-core/components/CardList/CardList.component.js +++ b/src/core_modules/capture-core/components/CardList/CardList.component.js @@ -1,18 +1,19 @@ // @flow import React from 'react'; -import type { ComponentType, Element } from 'react'; +import type { ComponentType } from 'react'; import { withStyles } from '@material-ui/core'; import { CardListItem } from './CardListItem.component'; import { makeElementsContainerSelector } from './CardList.selectors'; -import type { CardDataElementsInformation, SearchResultItem } from '../Pages/Search/SearchResults/SearchResults.types'; +import type { CardDataElementsInformation } from '../Pages/Search/SearchResults/SearchResults.types'; +import type { ListItem, RenderCustomCardActions } from './CardList.types'; type OwnProps = $ReadOnly<{| dataElements: CardDataElementsInformation, - items: Array, + items: Array, currentProgramId?: string, currentSearchScopeName?: string, noItemsText?: string, - getCustomItemBottomElements?: (itemProps: Object) => Element, + renderCustomCardActions?: RenderCustomCardActions, |}> const getStyles = (theme: Theme) => ({ @@ -22,10 +23,11 @@ const getStyles = (theme: Theme) => ({ }, }); + const CardListIndex = ({ classes, items, - getCustomItemBottomElements, + renderCustomCardActions, dataElements, noItemsText, currentProgramId, @@ -47,7 +49,7 @@ const CardListIndex = ({ item={item} currentSearchScopeName={currentSearchScopeName} currentProgramId={currentProgramId} - getCustomBottomElements={getCustomItemBottomElements} + renderCustomCardActions={renderCustomCardActions} profileImageDataElement={profileImageDataElement} dataElements={dataElementsExceptProfileImage} /> diff --git a/src/core_modules/capture-core/components/CardList/CardList.types.js b/src/core_modules/capture-core/components/CardList/CardList.types.js new file mode 100644 index 0000000000..45c25eabad --- /dev/null +++ b/src/core_modules/capture-core/components/CardList/CardList.types.js @@ -0,0 +1,36 @@ +// @flow +import { type Node } from 'react'; +import { typeof enrollmentTypes } from './CardList.constants'; + +export type Tei = $ReadOnly<{ + created: string, + orgUnit: string, + trackedEntityInstance: string, + lastUpdated: string, + trackedEntityType: string, + deleted: boolean, + featureType: string, + programOwners: Array, + enrollments: Array, + relationships: ?Array, + orgUnit: string, + attributes: Array<{ + lastUpdated: string, + code: string, + displayName: string, + created: string, + valueType: string, + attribute: string, + value: string + }> +}> + +export type ListItem = {| + +id: string, + +values: { + [elementId: string]: any, + }, + +tei: Tei, +|} + +export type RenderCustomCardActions = ({item: ListItem, programName?: string, enrollmentType: $Keys}) => Node diff --git a/src/core_modules/capture-core/components/CardList/CardListItem.component.js b/src/core_modules/capture-core/components/CardList/CardListItem.component.js index 1ef5a9da5d..8bca463117 100644 --- a/src/core_modules/capture-core/components/CardList/CardListItem.component.js +++ b/src/core_modules/capture-core/components/CardList/CardListItem.component.js @@ -2,28 +2,33 @@ import i18n from '@dhis2/d2-i18n'; import React from 'react'; import moment from 'moment'; -import type { ComponentType, Element } from 'react'; +import type { ComponentType } from 'react'; import { Avatar, Grid, withStyles } from '@material-ui/core'; import DoneIcon from '@material-ui/icons/Done'; import { colors, Tag } from '@dhis2/ui'; import type { CardDataElementsInformation, CardProfileImageElementInformation, - SearchResultItem, } from '../Pages/Search/SearchResults/SearchResults.types'; -import { availableCardListButtonState, enrollmentTypes } from './CardList.constants'; +import { enrollmentTypes } from './CardList.constants'; import { ListEntry } from './ListEntry.component'; import { dataElementTypes } from '../../metaData'; +import type { ListItem, RenderCustomCardActions } from './CardList.types'; type OwnProps = $ReadOnly<{| - item: SearchResultItem, + item: ListItem, currentSearchScopeName?: string, currentProgramId?: string, - getCustomBottomElements?: (props: Object) => Element, + renderCustomCardActions?: RenderCustomCardActions, profileImageDataElement: ?CardProfileImageElementInformation, dataElements: CardDataElementsInformation, |}>; +type Props = $ReadOnly<{| + ...OwnProps, + ...CssClasses +|}>; + const getStyles = (theme: Theme) => ({ itemContainer: { maxWidth: theme.typography.pxToRem(600), @@ -58,22 +63,11 @@ const getStyles = (theme: Theme) => ({ height: theme.typography.pxToRem(44), marginRight: theme.typography.pxToRem(8), }, + buttonMargin: { + marginTop: theme.typography.pxToRem(8), + }, }); -const deriveNavigationButtonState = - (type): $Keys => { - switch (type) { - case enrollmentTypes.ACTIVE: - return availableCardListButtonState.SHOW_VIEW_ACTIVE_ENROLLMENT_BUTTON; - case enrollmentTypes.CANCELLED: - case enrollmentTypes.COMPLETED: - return availableCardListButtonState.SHOW_RE_ENROLLMENT_BUTTON; - default: - return availableCardListButtonState.DONT_SHOW_BUTTON; - } - }; - - const deriveEnrollmentType = (enrollments, currentProgramId): $Keys => { if (!currentProgramId) { @@ -116,11 +110,11 @@ const CardListItemIndex = ({ item, classes, profileImageDataElement, - getCustomBottomElements, + renderCustomCardActions, dataElements, currentProgramId, currentSearchScopeName, -}: OwnProps & CssClasses) => { +}: Props) => { const renderImageDataElement = (imageElement: CardProfileImageElementInformation) => { const imageValue = item.values[imageElement.id]; return ( @@ -227,15 +221,23 @@ const CardListItemIndex = ({ { - getCustomBottomElements && - getCustomBottomElements({ - item, - navigationButtonsState: deriveNavigationButtonState(enrollmentType), - programName: currentSearchScopeName, - }) + renderCustomCardActions + && +
+ { + renderCustomCardActions({ + item, + // we pass the programName because we have the case that the scope of the search + // can be different that the scopeId from the url + // this can happen for example when you are registering through the relationships + programName: currentSearchScopeName, + enrollmentType, + }) + } +
} ); }; -export const CardListItem: ComponentType = withStyles(getStyles)(CardListItemIndex); +export const CardListItem: ComponentType<$Diff> = withStyles(getStyles)(CardListItemIndex); diff --git a/src/core_modules/capture-core/components/DataEntries/SingleEventRegistrationEntry/NewRelationshipWrapper/NewEventNewRelationshipWrapper.component.js b/src/core_modules/capture-core/components/DataEntries/SingleEventRegistrationEntry/NewRelationshipWrapper/NewEventNewRelationshipWrapper.component.js index a9e5bc93fd..baf3773336 100644 --- a/src/core_modules/capture-core/components/DataEntries/SingleEventRegistrationEntry/NewRelationshipWrapper/NewEventNewRelationshipWrapper.component.js +++ b/src/core_modules/capture-core/components/DataEntries/SingleEventRegistrationEntry/NewRelationshipWrapper/NewEventNewRelationshipWrapper.component.js @@ -3,7 +3,7 @@ import * as React from 'react'; import i18n from '@dhis2/d2-i18n'; import Paper from '@material-ui/core/Paper'; import withStyles from '@material-ui/core/styles/withStyles'; -import NewRelatonship from '../../../Pages/NewRelationship/NewRelationship.container'; +import NewRelationship from '../../../Pages/NewRelationship/NewRelationship.container'; import ConfirmDialog from '../../../Dialogs/ConfirmDialog.component'; import LinkButton from '../../../Buttons/LinkButton.component'; @@ -111,7 +111,7 @@ class NewEventNewRelationshipWrapper extends React.Component { {/* $FlowFixMe[cannot-spread-inexact] automated comment */} - { diff --git a/src/core_modules/capture-core/components/DataEntryWidgetOutput/DataEntryWidgetOutput.component.js b/src/core_modules/capture-core/components/DataEntryWidgetOutput/DataEntryWidgetOutput.component.js index c6564a457d..9ad76d0027 100644 --- a/src/core_modules/capture-core/components/DataEntryWidgetOutput/DataEntryWidgetOutput.component.js +++ b/src/core_modules/capture-core/components/DataEntryWidgetOutput/DataEntryWidgetOutput.component.js @@ -9,7 +9,7 @@ import FeedbacksSection from '../Pages/ViewEvent/RightColumn/FeedbacksSection/Fe import IndicatorsSection from '../Pages/ViewEvent/RightColumn/IndicatorsSection/IndicatorsSection.container'; type Props = { - onLink: (teiId: string) => void, + onLink: (teiId: string, values: Object) => void, classes: { stickyOnScroll: string, } @@ -34,7 +34,8 @@ const componentContainers = [ class DataEntryWidgetOutputComponent extends React.Component { renderComponent = (container: {id: string, Component: React.ComponentType }, props: Object) => { - const { onLink, ...otherProps } = props; + const { renderCardActions, ...otherProps } = props; + const passOnProps = container.id === 'WarningsSection' ? props : otherProps; return ( diff --git a/src/core_modules/capture-core/components/DataEntryWidgetOutput/DataEntryWidgetOutput.container.js b/src/core_modules/capture-core/components/DataEntryWidgetOutput/DataEntryWidgetOutput.container.js index f3e973eba4..e91053acfd 100644 --- a/src/core_modules/capture-core/components/DataEntryWidgetOutput/DataEntryWidgetOutput.container.js +++ b/src/core_modules/capture-core/components/DataEntryWidgetOutput/DataEntryWidgetOutput.container.js @@ -3,9 +3,10 @@ import { connect } from 'react-redux'; import React, { type ComponentType } from 'react'; import GeneralOutputComponent from './DataEntryWidgetOutput.component'; import getDataEntryKey from '../DataEntry/common/getDataEntryKey'; +import type { RenderCustomCardActions } from '../CardList/CardList.types'; type OwnProps = {| - onLink?: (teiId: string) => void, + renderCardActions?: RenderCustomCardActions, dataEntryId: string, selectedScopeId: string, |} diff --git a/src/core_modules/capture-core/components/DataEntryWidgetOutput/WarningsSection/SearchGroupDuplicate/SearchGroupDuplicate.component.js b/src/core_modules/capture-core/components/DataEntryWidgetOutput/WarningsSection/SearchGroupDuplicate/SearchGroupDuplicate.component.js index 01c1b76700..dd3827ecb6 100644 --- a/src/core_modules/capture-core/components/DataEntryWidgetOutput/WarningsSection/SearchGroupDuplicate/SearchGroupDuplicate.component.js +++ b/src/core_modules/capture-core/components/DataEntryWidgetOutput/WarningsSection/SearchGroupDuplicate/SearchGroupDuplicate.component.js @@ -4,9 +4,10 @@ import i18n from '@dhis2/d2-i18n'; import { Button } from '../../../Buttons'; import { WarningMessageCreator } from './WarningMessageCreator.component'; import { PossibleDuplicatesDialog } from '../../../PossibleDuplicatesDialog'; +import type { RenderCustomCardActions } from '../../../CardList/CardList.types'; type Props = {| - onLink: Function, + renderCardActions: RenderCustomCardActions, selectedScopeId: string, dataEntryId: string |}; @@ -44,7 +45,7 @@ export class SearchGroupDuplicate extends React.Component { } render() { - const { onLink, selectedScopeId, dataEntryId } = this.props; + const { selectedScopeId, dataEntryId, renderCardActions } = this.props; const { duplicatesReviewDialogOpen } = this.state; return ( @@ -59,8 +60,8 @@ export class SearchGroupDuplicate extends React.Component { selectedScopeId={selectedScopeId} open={duplicatesReviewDialogOpen} onCancel={this.handleCloseReviewDialog} - onLink={onLink} extraActions={this.getHideButton()} + renderCardActions={renderCardActions} /> ); diff --git a/src/core_modules/capture-core/components/DataEntryWidgetOutput/WarningsSection/warningsSection.selectors.js b/src/core_modules/capture-core/components/DataEntryWidgetOutput/WarningsSection/warningsSection.selectors.js index 4126a6e7e9..00a5ae18ac 100644 --- a/src/core_modules/capture-core/components/DataEntryWidgetOutput/WarningsSection/warningsSection.selectors.js +++ b/src/core_modules/capture-core/components/DataEntryWidgetOutput/WarningsSection/warningsSection.selectors.js @@ -8,17 +8,17 @@ const searchGroupCountSelector = (state, props) => state.dataEntriesSearchGroupsResults[props.dataEntryKey].main && state.dataEntriesSearchGroupsResults[props.dataEntryKey].main.count; -const onLinkSelector = (state, props) => props.onLink; +const renderCardActionsSelector = (state, props) => props.renderCardActions; const selectedScopeIdSelector = (_, props) => props.selectedScopeId; const dataEntryIdSelector = (_, props) => props.dataEntryId; // $FlowFixMe export const makeGetSearchGroupWarning = () => createSelector( searchGroupCountSelector, - onLinkSelector, + renderCardActionsSelector, selectedScopeIdSelector, dataEntryIdSelector, - (count: ?number, onLink: Function, selectedScopeId: string, dataEntryId: string) => { + (count: ?number, renderCardActions, selectedScopeId: string, dataEntryId: string) => { if (!count) { return null; } @@ -28,7 +28,7 @@ export const makeGetSearchGroupWarning = () => createSelector( ), }; diff --git a/src/core_modules/capture-core/components/Pages/New/RegistrationDataEntry/RegistrationDataEntry.component.js b/src/core_modules/capture-core/components/Pages/New/RegistrationDataEntry/RegistrationDataEntry.component.js index 1acc779b03..23d8614802 100644 --- a/src/core_modules/capture-core/components/Pages/New/RegistrationDataEntry/RegistrationDataEntry.component.js +++ b/src/core_modules/capture-core/components/Pages/New/RegistrationDataEntry/RegistrationDataEntry.component.js @@ -1,5 +1,6 @@ // @flow import React, { type ComponentType, useContext, useState } from 'react'; +import { useSelector } from 'react-redux'; import i18n from '@dhis2/d2-i18n'; import { Button } from '@dhis2/ui'; import { Grid, Paper, withStyles } from '@material-ui/core'; @@ -14,6 +15,7 @@ import { DataEntryWidgetOutput } from '../../../DataEntryWidgetOutput/DataEntryW import { PossibleDuplicatesDialog } from '../../../PossibleDuplicatesDialog/PossibleDuplicatesDialog.component'; import { usePossibleDuplicatesExist } from '../../../PossibleDuplicatesDialog/usePossibleDuplicatesExist'; import { ResultsPageSizeContext } from '../../shared-contexts'; +import { navigateToTrackedEntityDashboard } from '../../../../utils/navigateToTrackedEntityDashboard'; const getStyles = ({ typography }) => ({ paper: { @@ -54,6 +56,22 @@ const DialogButtons = ({ onCancel, onSave }) => (<> } ); +const CardListButton = (({ teiId, orgUnitId }) => { + const scopeHierarchy = useSelector(({ router: { location: { query } } }) => (query.programId ? 'PROGRAM' : 'TRACKED_ENTITY_TYPE')); + const selectedScopeId: string = useSelector(({ router: { location: { query } } }) => query.trackedEntityTypeId || query.programId); + const scopeSearchParam = `${scopeHierarchy.toLowerCase()}=${selectedScopeId}`; + + return ( + + ); +}); + const useHandleSaveAttempt = (dataEntryId, onReviewDuplicates) => { const { resultsPageSize } = useContext(ResultsPageSizeContext); @@ -144,6 +162,9 @@ const RegistrationDataEntryPlain = ( + + } /> @@ -152,6 +173,10 @@ const RegistrationDataEntryPlain = ( selectedScopeId={selectedScopeId} open={modalIsOpen} onCancel={closeModal} + renderCardActions={ + ({ item }) => + + } extraActions={ + + } /> @@ -207,6 +235,9 @@ const RegistrationDataEntryPlain = ( selectedScopeId={selectedScopeId} open={modalIsOpen} onCancel={closeModal} + renderCardActions={({ item }) => + + } extraActions={ ({ }, }); + +const CardListButton = (({ teiId, values, handleOnClick }) => ( + +)); + const RegisterTeiPlain = ({ onLink, onSave, @@ -91,15 +102,19 @@ const RegisterTeiPlain = ({ + + } /> + + } /> ); diff --git a/src/core_modules/capture-core/components/Pages/NewRelationship/RegisterTei/RegisterTei.types.js b/src/core_modules/capture-core/components/Pages/NewRelationship/RegisterTei/RegisterTei.types.js index d5567a0179..406691f780 100644 --- a/src/core_modules/capture-core/components/Pages/NewRelationship/RegisterTei/RegisterTei.types.js +++ b/src/core_modules/capture-core/components/Pages/NewRelationship/RegisterTei/RegisterTei.types.js @@ -12,7 +12,7 @@ type DispatchersFromRedux = {| |}; export type OwnProps = {| - onLink: (teiId: string) => void, + onLink: (teiId: string, values: Object) => void, onGetUnsavedAttributeValues?: ?Function, onSave: Function, |}; diff --git a/src/core_modules/capture-core/components/Pages/NewRelationship/TeiRelationship/SearchResults/TeiRelationshipSearchResults.component.js b/src/core_modules/capture-core/components/Pages/NewRelationship/TeiRelationship/SearchResults/TeiRelationshipSearchResults.component.js index f5e56a4ff9..003b3c5c07 100644 --- a/src/core_modules/capture-core/components/Pages/NewRelationship/TeiRelationship/SearchResults/TeiRelationshipSearchResults.component.js +++ b/src/core_modules/capture-core/components/Pages/NewRelationship/TeiRelationship/SearchResults/TeiRelationshipSearchResults.component.js @@ -10,9 +10,9 @@ import makeAttributesSelector from './teiRelationshipSearchResults.selectors'; import { CardList } from '../../../../CardList'; import type { CurrentSearchTerms } from '../../../Search/SearchForm/SearchForm.types'; import { SearchResultsHeader } from '../../../../SearchResultsHeader'; -import { type SearchResultItem } from '../../../Search/SearchResults/SearchResults.types'; import { type SearchGroup } from '../../../../../metaData'; import { ResultsPageSizeContext } from '../../../shared-contexts'; +import type { ListItem } from '../../../../CardList/CardList.types'; const SearchResultsPager = withNavigation()(Pagination); @@ -25,7 +25,7 @@ type Props = {| searchGroup: SearchGroup, searchValues: any, selectedProgramId: string, - teis: Array, + teis: Array, trackedEntityTypeName: string, ...CssClasses |} @@ -59,6 +59,16 @@ const getStyles = (theme: Theme) => ({ }, }); +const CardListButton = ({ handleOnClick, teiId }) => ( + +); + class TeiRelationshipSearchResultsPlain extends React.Component { getAttributes: Function; constructor(props: Props) { @@ -70,22 +80,6 @@ class TeiRelationshipSearchResultsPlain extends React.Component { this.props.onAddRelationship(item.id, item.values); } - getItemActions = ({ item }: Object) => { - const classes = this.props.classes; - return ( -
- -
- ); - } - renderResults = () => { const attributes = this.getAttributes(this.props); const { teis, trackedEntityTypeName, selectedProgramId } = this.props; @@ -98,7 +92,9 @@ class TeiRelationshipSearchResultsPlain extends React.Component { items={teis} dataElements={attributes} noItemsText={i18n.t('No {{trackedEntityTypeName}} found.', { trackedEntityTypeName })} - getCustomItemBottomElements={itemProps => this.getItemActions(itemProps)} + renderCustomCardActions={({ item }) => + this.onAddRelationship(item)} /> + } /> {this.renderPager()} diff --git a/src/core_modules/capture-core/components/Pages/Search/SearchResults/SearchResults.component.js b/src/core_modules/capture-core/components/Pages/Search/SearchResults/SearchResults.component.js index 0ff0868f7c..07386d568a 100644 --- a/src/core_modules/capture-core/components/Pages/Search/SearchResults/SearchResults.component.js +++ b/src/core_modules/capture-core/components/Pages/Search/SearchResults/SearchResults.component.js @@ -10,7 +10,7 @@ import withNavigation from '../../../Pagination/withDefaultNavigation'; import { searchScopes } from '../SearchPage.constants'; import type { Props } from './SearchResults.types'; import { navigateToTrackedEntityDashboard } from '../../../../utils/navigateToTrackedEntityDashboard'; -import { availableCardListButtonState } from '../../../CardList/CardList.constants'; +import { availableCardListButtonState, enrollmentTypes } from '../../../CardList/CardList.constants'; import { SearchResultsHeader } from '../../../SearchResultsHeader'; import { ResultsPageSizeContext } from '../../shared-contexts'; import { useScopeInfo } from '../../../../hooks/useScopeInfo'; @@ -35,9 +35,6 @@ export const getStyles = (theme: Theme) => ({ }); const buttonStyles = (theme: Theme) => ({ - margin: { - marginTop: theme.typography.pxToRem(8), - }, buttonMargin: { marginLeft: theme.typography.pxToRem(8), }, @@ -49,15 +46,30 @@ const CardListButtons = withStyles(buttonStyles)( currentSearchScopeType, id, orgUnitId, - navigationButtonsState, + enrollmentType, programName, classes, }) => { + const deriveNavigationButtonState = + (type): $Keys => { + switch (type) { + case enrollmentTypes.ACTIVE: + return availableCardListButtonState.SHOW_VIEW_ACTIVE_ENROLLMENT_BUTTON; + case enrollmentTypes.CANCELLED: + case enrollmentTypes.COMPLETED: + return availableCardListButtonState.SHOW_RE_ENROLLMENT_BUTTON; + default: + return availableCardListButtonState.DONT_SHOW_BUTTON; + } + }; + + const navigationButtonsState = deriveNavigationButtonState(enrollmentType); + const scopeSearchParam = `${currentSearchScopeType.toLowerCase()}=${currentSearchScopeId}`; const { pathname, search } = useLocation(); return ( -
+ <>
+ ); }); @@ -151,14 +163,14 @@ export const SearchResultsIndex = ({ currentProgramId={currentProgramId} items={searchResults} dataElements={dataElements} - getCustomItemBottomElements={({ item, navigationButtonsState, programName }) => ( + renderCustomCardActions={({ item, enrollmentType, programName }) => ( )} /> diff --git a/src/core_modules/capture-core/components/Pages/Search/SearchResults/SearchResults.types.js b/src/core_modules/capture-core/components/Pages/Search/SearchResults/SearchResults.types.js index 40d3e5e9d0..d43890e121 100644 --- a/src/core_modules/capture-core/components/Pages/Search/SearchResults/SearchResults.types.js +++ b/src/core_modules/capture-core/components/Pages/Search/SearchResults/SearchResults.types.js @@ -3,49 +3,19 @@ import type { CurrentSearchTerms } from '../SearchForm/SearchForm.types'; import { typeof searchScopes } from '../SearchPage.constants'; import { typeof dataElementTypes } from '../../../../metaData'; import type { AvailableSearchOptions } from '../SearchPage.types'; +import type { ListItem } from '../../../CardList/CardList.types'; export type CardDataElementsInformation = Array<{| id: string, name: string, type: $Values |}> export type CardProfileImageElementInformation = $ReadOnly<{| id: string, name: string, type: "IMAGE" |}> -type Tei = $ReadOnly<{ - created: string, - orgUnit: string, - trackedEntityInstance: string, - lastUpdated: string, - trackedEntityType: string, - deleted: boolean, - featureType: string, - programOwners: Array, - enrollments: Array, - relationships: ?Array, - attributes: Array<{ - lastUpdated: string, - code: string, - displayName: string, - created: string, - valueType: string, - attribute: string, - value: string - }> -}> - -export type SearchResultItem = {| - +id: string, - +values: { - [elementId: string]: any, - }, - +tei?: Tei, -|} - - export type PropsFromRedux ={| +currentPage: number, +currentSearchScopeType: $Keys, +currentSearchScopeId: string, +currentSearchScopeName: string, +currentFormId: string, - +searchResults: Array, + +searchResults: Array, +currentSearchTerms: CurrentSearchTerms, +dataElements: CardDataElementsInformation |} diff --git a/src/core_modules/capture-core/components/PossibleDuplicatesDialog/PossibleDuplicatesDialog.component.js b/src/core_modules/capture-core/components/PossibleDuplicatesDialog/PossibleDuplicatesDialog.component.js index 601ef9dc1c..5a35b3ff34 100644 --- a/src/core_modules/capture-core/components/PossibleDuplicatesDialog/PossibleDuplicatesDialog.component.js +++ b/src/core_modules/capture-core/components/PossibleDuplicatesDialog/PossibleDuplicatesDialog.component.js @@ -4,12 +4,13 @@ import { withStyles } from '@material-ui/core'; import Dialog from '@material-ui/core/Dialog'; import DialogActions from '@material-ui/core/DialogActions'; import { ReviewDialogContents } from './ReviewDialogContents/ReviewDialogContents.container'; +import type { RenderCustomCardActions } from '../CardList/CardList.types'; type Props = {| dataEntryId: string, open: boolean, onCancel: () => void, - onLink?: Function, + renderCardActions?: RenderCustomCardActions, extraActions?: ?React.Node, selectedScopeId: string |}; @@ -26,7 +27,7 @@ class ReviewDialogClass extends React.Component { }; render() { - const { open, onCancel, onLink, extraActions, selectedScopeId, dataEntryId } = this.props; + const { open, onCancel, extraActions, selectedScopeId, dataEntryId, renderCardActions } = this.props; return ( { {extraActions} diff --git a/src/core_modules/capture-core/components/PossibleDuplicatesDialog/ReviewDialogContents/ReviewDialogContents.component.js b/src/core_modules/capture-core/components/PossibleDuplicatesDialog/ReviewDialogContents/ReviewDialogContents.component.js index ff5509c5ee..c0e5d18439 100644 --- a/src/core_modules/capture-core/components/PossibleDuplicatesDialog/ReviewDialogContents/ReviewDialogContents.component.js +++ b/src/core_modules/capture-core/components/PossibleDuplicatesDialog/ReviewDialogContents/ReviewDialogContents.component.js @@ -4,7 +4,6 @@ import DialogContent from '@material-ui/core/DialogContent'; import DialogTitle from '@material-ui/core/DialogTitle'; import { withStyles } from '@material-ui/core/styles'; import i18n from '@dhis2/d2-i18n'; -import { Button } from '../../Buttons'; import { CardList } from '../../CardList'; import { ReviewDialogContentsPager } from './ReviewDialogContentsPager.container'; import { ResultsPageSizeContext } from '../../Pages/shared-contexts'; @@ -21,31 +20,14 @@ const getStyles = (theme: Theme) => ({ }); const ReviewDialogContentsPlain = ({ - onLink, classes, dataElements, teis, selectedScopeId, dataEntryId, + renderCardActions, }: Props) => { const { resultsPageSize } = useContext(ResultsPageSizeContext); - const getLinkButton = (itemProps: Object) => { - if (!onLink) { - return
; - } - const { id, values } = itemProps.item; - return ( -
- -
- ); - }; - return ( @@ -56,7 +38,7 @@ const ReviewDialogContentsPlain = ({ noItemsText={i18n.t('No results found')} items={teis} dataElements={dataElements} - getCustomItemBottomElements={getLinkButton} + renderCustomCardActions={renderCardActions} /> void, + renderCardActions?: RenderCustomCardActions, selectedScopeId: string, dataEntryId: string, selectedScopeId: string @@ -15,7 +15,7 @@ type PropsFromRedux = {| ready: boolean, isUpdating: boolean, error: ?string, - teis: Array, + teis: Array, dataElements: CardDataElementsInformation, |}