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: apply legend to all numeric and boolean types (DHIS2-17611) #1683

Merged
merged 7 commits into from
Jun 26, 2024
34 changes: 2 additions & 32 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-01-25T12:05:03.360Z\n"
"PO-Revision-Date: 2024-01-25T12:05:03.360Z\n"
"POT-Creation-Date: 2024-06-18T13:13:17.172Z\n"
"PO-Revision-Date: 2024-06-18T13:13:17.172Z\n"

msgid "view only"
msgstr "view only"
Expand Down Expand Up @@ -38,11 +38,6 @@ msgstr "Created {{time}} by {{author}}"
msgid "Created {{time}}"
msgstr "Created {{time}}"

msgid "Viewed {{count}} times"
janhenrikoverland marked this conversation as resolved.
Show resolved Hide resolved
msgid_plural "Viewed {{count}} times"
msgstr[0] "Viewed 1 time"
msgstr[1] "Viewed {{count}} times"

msgid "Notifications"
msgstr "Notifications"

Expand Down Expand Up @@ -395,11 +390,6 @@ msgstr "Interpretations"
msgid "Reply"
msgstr "Reply"

msgid "{{count}} replies"
msgid_plural "{{count}} replies"
msgstr[0] "{{count}} reply"
msgstr[1] "{{count}} replies"

msgid "View replies"
msgstr "View replies"

Expand Down Expand Up @@ -582,21 +572,6 @@ msgstr "Options"
msgid "Hide"
msgstr "Hide"

msgid "{{count}} org units"
msgid_plural "{{count}} org units"
msgstr[0] "{{count}} org unit"
msgstr[1] "{{count}} org units"

msgid "{{count}} levels"
msgid_plural "{{count}} levels"
msgstr[0] "{{count}} level"
msgstr[1] "{{count}} levels"

msgid "{{count}} groups"
msgid_plural "{{count}} groups"
msgstr[0] "{{count}} group"
msgstr[1] "{{count}} groups"

msgid "Selected: {{commaSeparatedListOfOrganisationUnits}}"
msgstr "Selected: {{commaSeparatedListOfOrganisationUnits}}"

Expand Down Expand Up @@ -1206,10 +1181,5 @@ msgstr "Base"
msgid "Axis {{axisId}}"
msgstr "Axis {{axisId}}"

msgid "{{count}} items"
msgid_plural "{{count}} items"
msgstr[0] "{{count}} item"
msgstr[1] "{{count}} items"

msgid "Reset zoom"
msgstr "Reset zoom"
9 changes: 6 additions & 3 deletions src/components/PivotTable/PivotTableValueCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import PropTypes from 'prop-types'
import React, { useRef } from 'react'
import { applyLegendSet } from '../../modules/pivotTable/applyLegendSet.js'
import { CELL_TYPE_VALUE } from '../../modules/pivotTable/pivotTableConstants.js'
import { VALUE_TYPE_NUMBER } from '../../modules/valueTypes.js'
import {
isNumericValueType,
isBooleanValueType,
} from '../../modules/valueTypes.js'
import { PivotTableCell } from './PivotTableCell.js'
import { PivotTableEmptyCell } from './PivotTableEmptyCell.js'
import { usePivotTableEngine } from './PivotTableEngineContext.js'
Expand Down Expand Up @@ -43,10 +46,10 @@ export const PivotTableValueCell = ({
)
}

// TODO: Add support for 'INTEGER' type (requires server changes)
const legendStyle =
cellContent.cellType === CELL_TYPE_VALUE &&
cellContent.valueType === VALUE_TYPE_NUMBER
(isNumericValueType(cellContent.valueType) ||
isBooleanValueType(cellContent.valueType))
? applyLegendSet(
cellContent.rawValue,
cellContent.dxDimension,
Expand Down
7 changes: 5 additions & 2 deletions src/modules/renderValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
NUMBER_TYPE_ROW_PERCENTAGE,
NUMBER_TYPE_COLUMN_PERCENTAGE,
} from './pivotTable/pivotTableConstants.js'
import { isNumericValueType } from './valueTypes.js'
import { isNumericValueType, isBooleanValueType } from './valueTypes.js'

const trimTrailingZeros = (stringValue) => stringValue.replace(/\.?0+$/, '')

Expand Down Expand Up @@ -53,7 +53,10 @@ const toFixedPrecisionString = (value, skipRounding) => {
}

export const renderValue = (value, valueType, visualization) => {
if (!isNumericValueType(valueType) || value === undefined) {
if (
!(isNumericValueType(valueType) || isBooleanValueType(valueType)) ||
value === undefined
) {
return String(value).replace(/[^\S\n]+/, ' ')
}

Expand Down
3 changes: 3 additions & 0 deletions src/modules/valueTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ const NUMERIC_VALUE_TYPES = [
VALUE_TYPE_INTEGER_ZERO_OR_POSITIVE,
]

const BOOLEAN_VALUE_TYPES = [VALUE_TYPE_BOOLEAN, VALUE_TYPE_TRUE_ONLY]

export const isNumericValueType = (type) => NUMERIC_VALUE_TYPES.includes(type)
export const isBooleanValueType = (type) => BOOLEAN_VALUE_TYPES.includes(type)
Loading