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

fix: show no data message when geojson feature has no data #3145

Merged
merged 5 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 8 additions & 2 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-03-05T16:53:36.408Z\n"
"PO-Revision-Date: 2024-03-05T16:53:36.408Z\n"
"POT-Creation-Date: 2024-03-07T13:44:00.589Z\n"
"PO-Revision-Date: 2024-03-07T13:44:00.589Z\n"

msgid "Untitled map, {{date}}"
msgstr "Untitled map, {{date}}"
Expand Down Expand Up @@ -521,6 +521,9 @@ msgstr "No relationship types were found for tracked entity type {{type}}"
msgid "Relationship type"
msgstr "Relationship type"

msgid "No data to show for this feature."
msgstr "No data to show for this feature."

msgid "Feature profile"
msgstr "Feature profile"

Expand Down Expand Up @@ -1341,6 +1344,9 @@ msgstr "Layer authorization is no longer valid"
msgid "Url to geojson was not found"
msgstr "Url to geojson was not found"

msgid "Unknown error"
msgstr "Unknown error"

msgid "Organisation units"
msgstr "Organisation units"

Expand Down
2 changes: 1 addition & 1 deletion src/components/datatable/styles/DataTable.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ td.lightText {
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
color: #333;
color: var(--colors-grey600);
font-style: italic;
}
47 changes: 33 additions & 14 deletions src/components/feature/FeatureProfile.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,43 @@
import i18n from '@dhis2/d2-i18n'
import { IconCross24 } from '@dhis2/ui'
import PropTypes from 'prop-types'
import React from 'react'
import { useSelector, useDispatch } from 'react-redux'
import { closeFeatureProfile } from '../../actions/feature.js'
import Drawer from '../core/Drawer.js'
import styles from './styles/FeatureProfile.module.css'

const DrawerContent = ({ data }) => {
if (Object.keys(data).length === 0) {
return (
<div className={styles.noData}>
{i18n.t('No data to show for this feature.')}
</div>
)
}

return (
<div className={styles.featureData}>
<div className={styles.dataTable}>
<table>
<tbody>
{Object.keys(data).map((key) => (
<tr key={key}>
<th>{key}</th>
<td>{data[key]}</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
)
}

DrawerContent.propTypes = {
data: PropTypes.object.isRequired,
}

const FeatureProfile = () => {
const featureProfile = useSelector((state) => state.featureProfile)
const dispatch = useDispatch()
Expand All @@ -24,20 +56,7 @@ const FeatureProfile = () => {
</span>
</div>
<div className={styles.content}>
<div className={styles.featureData}>
<div className={styles.dataTable}>
<table>
<tbody>
{Object.keys(data).map((key) => (
<tr key={key}>
<th>{key}</th>
<td>{data[key]}</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
<DrawerContent data={data} />
</div>
</Drawer>
)
Expand Down
7 changes: 7 additions & 0 deletions src/components/feature/styles/FeatureProfile.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,10 @@
padding: 10px 0 9px;
white-space: nowrap;
}

.noData {
text-align: center;
padding: var(--spacers-dp16);
color: var(--colors-grey600);
font-style: italic;
}
Loading