diff --git a/packages/ui-components/src/components/Map/__tests__/markerFormats.test.js b/packages/ui-components/src/components/Map/__tests__/markerFormats.test.js index 9f30b93710..f14512ccbf 100644 --- a/packages/ui-components/src/components/Map/__tests__/markerFormats.test.js +++ b/packages/ui-components/src/components/Map/__tests__/markerFormats.test.js @@ -185,6 +185,26 @@ describe('measures', () => { const display3 = getMeasureDisplayInfo({ questionC: 0.5 }, [optionsSpectrum]); expect(display3).toHaveProperty('color', 'hsl(50, 100%, 50%)'); }); + + it('should support coloured radius', () => { + // A coloured radius will choose colour from a spectrum option, and pick radius size from a radius option + const questionAValue = 100; + const display = getMeasureDisplayInfo( + { + questionC: 0.5, + questionA: questionAValue, + }, + [ + { + ...optionsSpectrum, + scaleType: 'performanceDesc', + }, + { ...optionsRadius, key: 'questionA' }, + ], + ); + expect(display).toHaveProperty('color', 'hsl(50, 100%, 50%)'); + expect(display).toHaveProperty('radius', questionAValue); + }); }); describe('popup', () => { diff --git a/packages/web-frontend/src/containers/mobile/Dashboard.js b/packages/web-frontend/src/containers/mobile/Dashboard.js index e845106782..56020ef0e9 100644 --- a/packages/web-frontend/src/containers/mobile/Dashboard.js +++ b/packages/web-frontend/src/containers/mobile/Dashboard.js @@ -74,13 +74,13 @@ export const DashboardComponent = ({ const filterItems = dashboards.map(({ dashboardName }) => ({ label: dashboardName, - id: dashboardName, + code: dashboardName, value: dashboardName, })); - const currentFilter = filterItems.find(item => item.id === currentDashboardName) || { + const currentFilter = filterItems.find(item => item.code === currentDashboardName) || { label: 'General', - id: 'General', + code: 'General', }; return ( diff --git a/packages/web-frontend/src/utils/index.js b/packages/web-frontend/src/utils/index.js index b4fc01e171..f8ad8d6448 100644 --- a/packages/web-frontend/src/utils/index.js +++ b/packages/web-frontend/src/utils/index.js @@ -15,11 +15,7 @@ export { isMobile, delayMobileTapCallback } from './mobile'; export { getCenterAndZoomForBounds } from './getCenterAndZoomForBounds'; export { getOrgUnitPhotoUrl } from './getOrgUnitPhotoUrl'; export { getMapUrl } from './getMapUrl'; -export { - processMeasureInfo, - getSingleFormattedValue, - flattenNumericalMeasureData, -} from './measures'; +export { processMeasureInfo, flattenNumericalMeasureData } from './measures'; export { getMapOverlaysFromHierarchy, checkHierarchyIncludesMapOverlayCodes, diff --git a/packages/web-frontend/src/utils/measures.js b/packages/web-frontend/src/utils/measures.js index 4687132f3e..89a839b46c 100644 --- a/packages/web-frontend/src/utils/measures.js +++ b/packages/web-frontend/src/utils/measures.js @@ -14,7 +14,6 @@ import { } from '@tupaia/ui-components/lib/map'; import { VALUE_TYPES } from '../components/View/constants'; import { MAP_COLORS } from '../styles'; -import { formatDataValue } from './formatters'; import { MARKER_TYPES, SCALE_TYPES } from '../constants'; export const MEASURE_TYPE_ICON = 'icon'; @@ -104,27 +103,6 @@ const getNullValueMapping = type => { return baseMapping; }; -function getFormattedValue(value, type, valueInfo, scaleType, valueType, submissionDate) { - switch (type) { - case MEASURE_TYPE_SPECTRUM: - case MEASURE_TYPE_SHADED_SPECTRUM: - if (scaleType === SCALE_TYPES.TIME) { - return `last submission on ${submissionDate}`; - } - return formatDataValue(value, valueType); - case MEASURE_TYPE_RADIUS: - case MEASURE_TYPE_ICON: - case MEASURE_TYPE_COLOR: - case MEASURE_TYPE_SHADING: - if (scaleType === SCALE_TYPES.TIME) { - return `last submission on ${submissionDate}`; - } - return valueInfo.name || value; - default: - return value; - } -} - const getSpectrumScaleValues = (measureData, measureOption) => { const { key, scaleType, startDate, endDate } = measureOption; @@ -223,78 +201,6 @@ export function processMeasureInfo(response) { }; } -function getValueInfo(value, valueMapping, hiddenValues = {}) { - if (!value && typeof value !== 'number' && valueMapping.null) { - // use 'no data' value - const nullValue = hiddenValues.null || hiddenValues[valueMapping.null.value]; - - return { - ...valueMapping.null, - isHidden: nullValue, - }; - } - - const matchedValue = valueMapping[value]; - - if (!matchedValue) { - // use 'other' value - return { - ...valueMapping.other, - isHidden: hiddenValues.other, - value, - }; - } - - return { - ...matchedValue, - isHidden: hiddenValues[matchedValue.value], - }; -} - -export function getFormattedInfo(orgUnitData, measureOption) { - const { key, valueMapping, type, displayedValueKey, scaleType, valueType } = measureOption; - - const value = orgUnitData[key]; - const valueInfo = getValueInfo(value, valueMapping); - - if ( - displayedValueKey && - (orgUnitData[displayedValueKey] || orgUnitData[displayedValueKey] === 0) - ) { - return { - formattedValue: formatDataValue( - orgUnitData[displayedValueKey], - valueType, - orgUnitData.metadata, - ), - valueInfo, - }; - } - - // note: dont use !value here, as 0 is a valid value. - if (value === null || value === undefined) { - return { formattedValue: valueInfo.name || 'No data', valueInfo }; - } - - return { - formattedValue: getFormattedValue( - value, - type, - valueInfo, - scaleType, - valueType, - orgUnitData.submissionDate, - ), - valueInfo, - }; -} - -export function getSingleFormattedValue(orgUnitData, measureOptions) { - // For situations where we can only show one value, just show the value - // of the first measure. - return getFormattedInfo(orgUnitData, measureOptions[0]).formattedValue; -} - // Take a measureData array where the [key]: value is a number // and filters NaN values (e.g. undefined). export function flattenNumericalMeasureData(measureData, key) {