diff --git a/i18n/en.pot b/i18n/en.pot
index c8a238df5..fafad5706 100644
--- a/i18n/en.pot
+++ b/i18n/en.pot
@@ -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: 2023-06-27T14:37:02.617Z\n"
-"PO-Revision-Date: 2023-06-27T14:37:02.617Z\n"
+"POT-Creation-Date: 2023-09-27T14:21:34.503Z\n"
+"PO-Revision-Date: 2023-09-27T14:21:34.503Z\n"
msgid "Add to {{axisName}}"
msgstr "Add to {{axisName}}"
@@ -379,6 +379,13 @@ msgstr "Your most viewed line lists"
msgid "Not available offline"
msgstr "Not available offline"
+msgid ""
+"This line list may show data that was not available when the interpretation "
+"was written."
+msgstr ""
+"This line list may show data that was not available when the interpretation "
+"was written."
+
msgid "Sort by {{column}}"
msgstr "Sort by {{column}}"
diff --git a/src/components/DetailsPanel/DetailsPanel.js b/src/components/DetailsPanel/DetailsPanel.js
index b32df2e86..4735c6c25 100644
--- a/src/components/DetailsPanel/DetailsPanel.js
+++ b/src/components/DetailsPanel/DetailsPanel.js
@@ -5,9 +5,10 @@ import {
} from '@dhis2/analytics'
import PropTypes from 'prop-types'
import { stringify } from 'query-string'
-import React from 'react'
+import React, { useMemo } from 'react'
import { connect } from 'react-redux'
import history from '../../modules/history.js'
+import { isAoWithTimeDimension } from '../../modules/timeDimensions.js'
import { sGetCurrent } from '../../reducers/current.js'
import { sGetLoadError } from '../../reducers/loader.js'
import classes from './styles/DetailsPanel.module.css'
@@ -29,6 +30,10 @@ const DetailsPanel = ({
disabled,
}) => {
const { currentUser } = useCachedDataQuery()
+ const hasTimeDimension = useMemo(
+ () => isAoWithTimeDimension(visualization),
+ [visualization]
+ )
return (
@@ -39,6 +44,7 @@ const DetailsPanel = ({
/>
diff --git a/src/components/DownloadMenu/useDownload.js b/src/components/DownloadMenu/useDownload.js
index bedc32400..211d37eef 100644
--- a/src/components/DownloadMenu/useDownload.js
+++ b/src/components/DownloadMenu/useDownload.js
@@ -3,6 +3,7 @@ import { useConfig, useDataEngine } from '@dhis2/app-runtime'
import { useCallback } from 'react'
import { useSelector } from 'react-redux'
import { validateLineListLayout } from '../../modules/layoutValidation.js'
+import { isAoWithTimeDimension } from '../../modules/timeDimensions.js'
import { OUTPUT_TYPE_ENROLLMENT } from '../../modules/visualization.js'
import { sGetCurrent } from '../../reducers/current.js'
import {
@@ -123,7 +124,7 @@ const useDownload = (relativePeriodDate) => {
req = req.withStage(current.programStage?.id)
}
- if (relativePeriodDate) {
+ if (relativePeriodDate && isAoWithTimeDimension(current)) {
req = req.withRelativePeriodDate(relativePeriodDate)
}
diff --git a/src/components/Visualization/Visualization.js b/src/components/Visualization/Visualization.js
index dd10ff009..4fea0ed52 100644
--- a/src/components/Visualization/Visualization.js
+++ b/src/components/Visualization/Visualization.js
@@ -28,6 +28,7 @@ import {
DataTableFoot,
Pagination,
Tooltip,
+ NoticeBox,
} from '@dhis2/ui'
import cx from 'classnames'
import PropTypes from 'prop-types'
@@ -51,6 +52,7 @@ import {
getFormattedCellValue,
getHeaderText,
} from '../../modules/tableValues.js'
+import { isAoWithTimeDimension } from '../../modules/timeDimensions.js'
import {
getHeadersMap,
transformVisualization,
@@ -91,6 +93,16 @@ const getSizeClass = (displayDensity) => {
}
}
+const getDataTableScrollHeight = (isInModal, noTimeDimensionWarningRef) => {
+ if (isInModal) {
+ const reservedHeight =
+ 285 + (noTimeDimensionWarningRef?.current?.clientHeight ?? 0)
+ return `calc(100vh - ${reservedHeight}px)`
+ } else {
+ return '100%'
+ }
+}
+
const PaginationComponent = ({ offline, ...props }) =>
offline ? (
@@ -113,8 +125,13 @@ export const Visualization = ({
onColumnHeaderClick,
onError,
}) => {
+ const noTimeDimensionWarningRef = useRef(null)
+ const dataTableRef = useRef(null)
const [uniqueLegendSets, setUniqueLegendSets] = useState([])
- const [paginationMaxWidth, setPaginationMaxWidth] = useState(0)
+ const [measuredDimensions, setMeasuredDimensions] = useState({
+ paginationMaxWidth: 0,
+ noticeBoxMaxWidth: 0,
+ })
const [{ sortField, sortDirection, pageSize, page }, setSorting] =
useReducer((sorting, newSorting) => ({ ...sorting, ...newSorting }), {
sortField: null,
@@ -124,6 +141,12 @@ export const Visualization = ({
})
const visualization = useMemo(() => AO && transformVisualization(AO), [AO])
+ const isInModal = !!filters?.relativePeriodDate
+ const hasTimeDimension = useMemo(
+ () => isAoWithTimeDimension(visualization),
+ [visualization]
+ )
+ const shouldShowTimeDimensionWarning = isInModal && !hasTimeDimension
const visualizationRef = useRef(visualization)
@@ -139,12 +162,15 @@ export const Visualization = ({
const containerInnerWidth = node.clientWidth
const scrollBox = node.querySelector('.tablescrollbox')
const scrollbarWidth = scrollBox.offsetWidth - scrollBox.clientWidth
- const maxWidth = Math.max(
+ const paginationMaxWidth = Math.max(
containerInnerWidth - scrollbarWidth,
PAGINATION_MIN_WIDTH
)
- setPaginationMaxWidth(maxWidth)
+ setMeasuredDimensions({
+ paginationMaxWidth,
+ noticeBoxMaxWidth: scrollBox.offsetWidth,
+ })
}
const sizeObserver = new window.ResizeObserver(adjustSize)
@@ -310,8 +336,6 @@ export const Visualization = ({
)
- const isInModal = !!filters?.relativePeriodDate
-
return (
-
-
-
- {data.headers.map((header, index) =>
- header ? (
-
+ {shouldShowTimeDimensionWarning && (
+
+
+ {i18n.t(
+ 'This line list may show data that was not available when the interpretation was written.'
+ )}
+
+
+ )}
+
+
+
+
+ {data.headers.map((header, index) =>
+ header ? (
+
- {formatCellHeader(header)}
-
- ) : (
-
- )
- )}
-
-
- {/* https://jira.dhis2.org/browse/LIBS-278 */}
-
- {data.rows.map((row, index) => (
-
- {row.map((value, index) => (
-
-
- {formatCellValue(
- value,
- data.headers[index]
+ {formatCellHeader(header)}
+
+ ) : (
+
-
- ))}
+ dataTest={'table-header'}
+ />
+ )
+ )}
- ))}
-
-
-
-
-
+ {/* https://jira.dhis2.org/browse/LIBS-278 */}
+
+ {data.rows.map((row, index) => (
+
-
- i18n.t(
- 'Page {{page}}, row {{firstItem}}-{{lastItem}}',
+ {row.map((value, index) => (
+
+
-
-
-
-
-
+ >
+ {formatCellValue(
+ value,
+ data.headers[index]
+ )}
+
+
+ ))}
+
+ ))}
+
+
+
+
+
+
+ i18n.t(
+ 'Page {{page}}, row {{firstItem}}-{{lastItem}}',
+ {
+ firstItem,
+ lastItem,
+ page,
+ }
+ )
+ }
+ />
+
+
+
+
+
+
+ {Boolean(uniqueLegendSets.length) && getLegendKey()}
- {Boolean(uniqueLegendSets.length) && getLegendKey()}
)
}
diff --git a/src/components/Visualization/styles/Visualization.module.css b/src/components/Visualization/styles/Visualization.module.css
index b4d579f88..f032f5ef3 100644
--- a/src/components/Visualization/styles/Visualization.module.css
+++ b/src/components/Visualization/styles/Visualization.module.css
@@ -48,6 +48,15 @@
transition: max-width 200ms ease-out;
}
+.visualizationContainer {
+ display: flex;
+ flex-direction: column;
+ max-width: 100%;
+}
+.noTimeDimensionWarning {
+ padding-bottom: var(--spacers-dp12);
+}
+
.stickyFooter {
position: sticky;
bottom: 0;
diff --git a/src/components/Visualization/useAnalyticsData.js b/src/components/Visualization/useAnalyticsData.js
index 9fda4869e..787c14e8f 100644
--- a/src/components/Visualization/useAnalyticsData.js
+++ b/src/components/Visualization/useAnalyticsData.js
@@ -26,6 +26,7 @@ import {
DIMENSION_IDS_TIME,
} from '../../modules/dimensionConstants.js'
import { getRequestOptions } from '../../modules/getRequestOptions.js'
+import { isAoWithTimeDimension } from '../../modules/timeDimensions.js'
import { extractDimensionIdParts } from '../../modules/utils.js'
import {
OUTPUT_TYPE_ENROLLMENT,
@@ -161,7 +162,7 @@ const fetchAnalyticsData = async ({
req = req.withStage(visualization.programStage?.id)
}
- if (relativePeriodDate) {
+ if (relativePeriodDate && isAoWithTimeDimension(visualization)) {
req = req.withRelativePeriodDate(relativePeriodDate)
}
diff --git a/src/modules/timeDimensions.js b/src/modules/timeDimensions.js
index 512e7f380..998f168c1 100644
--- a/src/modules/timeDimensions.js
+++ b/src/modules/timeDimensions.js
@@ -1,4 +1,4 @@
-import { DIMENSION_TYPE_PERIOD } from '@dhis2/analytics'
+import { DIMENSION_TYPE_PERIOD, layoutGetAllDimensions } from '@dhis2/analytics'
import i18n from '@dhis2/d2-i18n'
import {
DIMENSION_ID_EVENT_DATE,
@@ -6,6 +6,7 @@ import {
DIMENSION_ID_INCIDENT_DATE,
DIMENSION_ID_SCHEDULED_DATE,
DIMENSION_ID_LAST_UPDATED,
+ DIMENSION_IDS_TIME,
} from './dimensionConstants.js'
import { PROGRAM_TYPE_WITH_REGISTRATION } from './programTypes.js'
import { OUTPUT_TYPE_EVENT, OUTPUT_TYPE_ENROLLMENT } from './visualization.js'
@@ -123,3 +124,12 @@ export const getDisabledTimeDimensions = (inputType, program, stage) => {
}
}
}
+
+export const isAoWithTimeDimension = (ao) =>
+ layoutGetAllDimensions(ao).some(
+ ({ dimensionType, dimension, items }) =>
+ (dimensionType === DIMENSION_TYPE_PERIOD ||
+ DIMENSION_IDS_TIME.has(dimension)) &&
+ Array.isArray(items) &&
+ items.length > 0
+ )