diff --git a/core/i18n/resources/en.js b/core/i18n/resources/en.js index e1dd075989..9944b18c5b 100644 --- a/core/i18n/resources/en.js +++ b/core/i18n/resources/en.js @@ -385,6 +385,12 @@ Thank you and enjoy **$t(common.appNameFull)**!`, availableSpace: 'Available ({{size}})', usedSpace: 'Used ({{size}})', }, + samplingPointDataCompletion: 'Sampling Point Data Completion', + step: { + entry: 'Data Entry', + cleansing: 'Data Cleansing', + analysis: 'Data Analysis', + }, }, surveyDeleted: 'Survey {{surveyName}} has been deleted', surveyInfo: { diff --git a/webapp/views/App/views/Home/Dashboard/SamplingPointDataSummary/SamplingDataChart.js b/webapp/views/App/views/Home/Dashboard/SamplingPointDataSummary/SamplingDataChart.js index 8f2d1e95d3..4b38829183 100644 --- a/webapp/views/App/views/Home/Dashboard/SamplingPointDataSummary/SamplingDataChart.js +++ b/webapp/views/App/views/Home/Dashboard/SamplingPointDataSummary/SamplingDataChart.js @@ -1,11 +1,15 @@ import React, { useEffect, useRef, useContext } from 'react' import * as d3 from 'd3' + import { countSamplingPointData } from '@webapp/service/api/categories' +import { useI18n } from '@webapp/store/system' + import { RecordsSummaryContext } from '../RecordsSummaryContext' const SamplingDataChart = (surveyInfo) => { const ref = useRef() const { dataEntry, dataCleansing } = useContext(RecordsSummaryContext) + const i18n = useI18n() useEffect(() => { const fetchData = async () => { @@ -43,7 +47,9 @@ const SamplingDataChart = (surveyInfo) => { .attr('d', arcGenerator1) .attr('fill', (d, i) => color(i)) - d3.select('#tooltip1').style('visibility', 'visible').html(`Data Entry: ${dataEntry} / ${totalRows}`) + d3.select('#tooltip1') + .style('visibility', 'visible') + .html(`${i18n.t('homeView.dashboard.step.entry')}: ${dataEntry} / ${totalRows}`) // Create second pie const data_ready2 = pie(data2) @@ -56,14 +62,16 @@ const SamplingDataChart = (surveyInfo) => { .attr('d', arcGenerator2) .attr('fill', (d, i) => color2(i)) - d3.select('#tooltip2').style('visibility', 'visible').html(`Data Cleansing: ${dataCleansing} / ${totalRows}`) + d3.select('#tooltip2') + .style('visibility', 'visible') + .html(`${i18n.t('homeView.dashboard.step.cleansing')}: ${dataCleansing} / ${totalRows}`) } fetchData() }, []) return (
-

Sampling Datapoint Completion

+

{i18n.t('homeView.dashboard.samplingPointDataCompletion')}

diff --git a/webapp/views/App/views/Home/Dashboard/hooks/useHasSamplingPointData.js b/webapp/views/App/views/Home/Dashboard/hooks/useHasSamplingPointData.js index 689154e66a..d167a7b0cd 100644 --- a/webapp/views/App/views/Home/Dashboard/hooks/useHasSamplingPointData.js +++ b/webapp/views/App/views/Home/Dashboard/hooks/useHasSamplingPointData.js @@ -1,5 +1,8 @@ import { useState, useEffect } from 'react' + import * as Survey from '@core/survey/survey' +import * as NodeDef from '@core/survey/nodeDef' + import { useSurvey } from '@webapp/store/survey' export const useHasSamplingPointData = () => { @@ -8,7 +11,16 @@ export const useHasSamplingPointData = () => { useEffect(() => { const samplingPointDataNodeDefs = Survey.getSamplingPointDataNodeDefs(survey) - setHasSamplingPointData(samplingPointDataNodeDefs.length > 0) + if (samplingPointDataNodeDefs.length === 0) { + setHasSamplingPointData(false) + return + } + const rootKeyDefs = Survey.getNodeDefRootKeys(survey) + const samplingPointDataNodeDefUuids = samplingPointDataNodeDefs.map(NodeDef.getUuid) + const allKeysUseSamplingPointData = rootKeyDefs.every((rootKeyDef) => + samplingPointDataNodeDefUuids.includes(NodeDef.getUuid(rootKeyDef)) + ) + setHasSamplingPointData(allKeysUseSamplingPointData) }, [survey]) return hasSamplingPointData