-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement info popover for dimensions (DHIS2-14774)
- Loading branch information
Showing
14 changed files
with
863 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { useDataQuery } from '@dhis2/app-runtime' | ||
import PropTypes from 'prop-types' | ||
import React from 'react' | ||
import i18n from '../../../locales/index.js' | ||
import { getCommonFields, InfoTable } from './InfoTable.js' | ||
import styles from './styles/InfoPopover.style.js' | ||
|
||
const calculationQuery = { | ||
calculation: { | ||
resource: 'expressionDimensionItems', | ||
id: ({ id }) => id, | ||
params: ({ displayNameProp }) => ({ | ||
fields: `${getCommonFields(displayNameProp)},expression`, | ||
}), | ||
}, | ||
} | ||
|
||
export const CalculationInfo = ({ id, displayNameProp }) => { | ||
const { loading, error, data } = useDataQuery(calculationQuery, { | ||
variables: { id, displayNameProp }, | ||
}) | ||
|
||
return ( | ||
<> | ||
<InfoTable data={data?.calculation} loading={loading} error={error}> | ||
<tr> | ||
<th>{i18n.t('Expression')}</th> | ||
<td className="code">{data?.calculation.expression}</td> | ||
</tr> | ||
</InfoTable> | ||
<style jsx>{styles}</style> | ||
</> | ||
) | ||
} | ||
|
||
CalculationInfo.propTypes = { | ||
displayNameProp: PropTypes.string, | ||
id: PropTypes.string, | ||
} |
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,81 @@ | ||
import { useDataQuery } from '@dhis2/app-runtime' | ||
import PropTypes from 'prop-types' | ||
import React from 'react' | ||
import i18n from '../../../locales/index.js' | ||
import { getCommonFields, InfoTable } from './InfoTable.js' | ||
import styles from './styles/InfoPopover.style.js' | ||
|
||
const dataElementQuery = { | ||
dataElement: { | ||
resource: 'dataElements', | ||
id: ({ id }) => id, | ||
params: ({ displayNameProp }) => ({ | ||
fields: `${getCommonFields( | ||
displayNameProp | ||
)},valueType,aggregationType,zeroIsSignificant,categoryCombo[id,displayName],legendSets[id,displayName],dataElementGroups[id,displayName]`, | ||
}), | ||
}, | ||
} | ||
|
||
export const DataElementInfo = ({ id, displayNameProp }) => { | ||
const { loading, error, data } = useDataQuery(dataElementQuery, { | ||
variables: { id, displayNameProp }, | ||
}) | ||
|
||
return ( | ||
<> | ||
<InfoTable data={data?.dataElement} loading={loading} error={error}> | ||
<tr> | ||
<th>{i18n.t('Value type')}</th> | ||
<td>{data?.dataElement.valueType}</td> | ||
</tr> | ||
<tr> | ||
<th>{i18n.t('Aggregation type')}</th> | ||
<td>{data?.dataElement.aggregationType}</td> | ||
</tr> | ||
<tr> | ||
<th>{i18n.t('Category combo')}</th> | ||
<td>{data?.dataElement.categoryCombo.displayName}</td> | ||
</tr> | ||
<tr> | ||
<th>{i18n.t('Data element groups')}</th> | ||
<td> | ||
<ul> | ||
{data?.dataElement.dataElementGroups.map( | ||
({ id, displayName }) => ( | ||
<li key={id}>{displayName}</li> | ||
) | ||
)} | ||
</ul> | ||
</td> | ||
</tr> | ||
<tr> | ||
<th>{i18n.t('Legend sets')}</th> | ||
<td> | ||
<ul> | ||
{data?.dataElement.legendSets.map( | ||
({ id, displayName }) => ( | ||
<li key={id}>{displayName}</li> | ||
) | ||
)} | ||
</ul> | ||
</td> | ||
</tr> | ||
<tr> | ||
<th>{i18n.t('Zero is significant')}</th> | ||
<td> | ||
{data?.dataElement.zeroIsSignificant | ||
? i18n.t('True') | ||
: i18n.t('False')} | ||
</td> | ||
</tr> | ||
</InfoTable> | ||
<style jsx>{styles}</style> | ||
</> | ||
) | ||
} | ||
|
||
DataElementInfo.propTypes = { | ||
displayNameProp: PropTypes.string, | ||
id: PropTypes.string, | ||
} |
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,55 @@ | ||
import { useDataQuery } from '@dhis2/app-runtime' | ||
import PropTypes from 'prop-types' | ||
import React from 'react' | ||
import i18n from '../../../locales/index.js' | ||
import { getCommonFields, InfoTable } from './InfoTable.js' | ||
import styles from './styles/InfoPopover.style.js' | ||
|
||
const dataSetQuery = { | ||
dataSet: { | ||
resource: 'dataSets', | ||
id: ({ id }) => id, | ||
params: ({ displayNameProp }) => ({ | ||
fields: `${getCommonFields( | ||
displayNameProp | ||
)},periodType,dataSetElements[dataElement[id,displayName]]`, | ||
}), | ||
}, | ||
} | ||
|
||
export const DataSetInfo = ({ id, displayNameProp }) => { | ||
const { loading, error, data } = useDataQuery(dataSetQuery, { | ||
variables: { id, displayNameProp }, | ||
}) | ||
|
||
return ( | ||
<> | ||
<InfoTable data={data?.dataSet} loading={loading} error={error}> | ||
<tr> | ||
<th>{i18n.t('Period type')}</th> | ||
<td>{data?.dataSet.periodType}</td> | ||
</tr> | ||
<tr> | ||
<th>{i18n.t('Data set elements')}</th> | ||
<td> | ||
<ul> | ||
{data?.dataSet.dataSetElements.map( | ||
({ dataElement }) => ( | ||
<li key={dataElement.id}> | ||
{dataElement.displayName} | ||
</li> | ||
) | ||
)} | ||
</ul> | ||
</td> | ||
</tr> | ||
</InfoTable> | ||
<style jsx>{styles}</style> | ||
</> | ||
) | ||
} | ||
|
||
DataSetInfo.propTypes = { | ||
displayNameProp: PropTypes.string, | ||
id: PropTypes.string, | ||
} |
Oops, something went wrong.