From 75dd8715cb15347cb889307e4e1d42f88b9f3ec8 Mon Sep 17 00:00:00 2001 From: henrikmv Date: Wed, 25 Sep 2024 11:17:17 +0200 Subject: [PATCH 1/6] feat: update client to list converter --- .../capture-core/converters/clientToList.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/core_modules/capture-core/converters/clientToList.js b/src/core_modules/capture-core/converters/clientToList.js index a5f39b4105..b6580f0601 100644 --- a/src/core_modules/capture-core/converters/clientToList.js +++ b/src/core_modules/capture-core/converters/clientToList.js @@ -8,6 +8,7 @@ import { dataElementTypes, type DataElement } from '../metaData'; import { convertMomentToDateFormatString } from '../utils/converters/date'; import { stringifyNumber } from './common/stringifyNumber'; import { MinimalCoordinates } from '../components/MinimalCoordinates'; +import { TooltipOrgUnit } from '../components/Tooltips/TooltipOrgUnit'; function convertDateForListDisplay(rawValue: string): string { const momentDate = moment(rawValue); @@ -37,6 +38,11 @@ type ImageClientValue = { previewUrl: string, }; +type OrgUnitClientValue = { + name: string, + ancestors?: Array, +}; + function convertFileForDisplay(clientValue: FileClientValue) { // Fallback until https://dhis2.atlassian.net/browse/DHIS2-16994 is implemented if (typeof clientValue === 'string' || clientValue instanceof String) { @@ -86,8 +92,13 @@ function convertStatusForDisplay(clientValue: Object) { ); } -function convertOrgUnitForDisplay(rawValue: string | Object) { - return (typeof rawValue === 'string' ? rawValue : rawValue.name); +function convertOrgUnitForDisplay(clientValue: OrgUnitClientValue) { + return ( + + ); } const valueConvertersForType = { @@ -120,6 +131,7 @@ const valueConvertersForType = { }; export function convertValue(value: any, type: $Keys, dataElement?: ?DataElement) { + console.log('convertValue', value); if (!value && value !== 0 && value !== false) { return value; } From 284a227a5ec1b7608e3b3bdff559641724d52c11 Mon Sep 17 00:00:00 2001 From: henrikmv Date: Thu, 26 Sep 2024 10:54:31 +0200 Subject: [PATCH 2/6] feat: changes in tooltip component --- .../TooltipOrgUnit.component.js | 11 ++++++----- .../WidgetEnrollment.component.js | 4 ++-- .../WidgetProfile/hooks/getSubValueForTei.js | 19 ++++--------------- .../capture-core/converters/clientToList.js | 13 +++---------- .../capture-core/converters/clientToView.js | 14 +++----------- 5 files changed, 18 insertions(+), 43 deletions(-) diff --git a/src/core_modules/capture-core/components/Tooltips/TooltipOrgUnit/TooltipOrgUnit.component.js b/src/core_modules/capture-core/components/Tooltips/TooltipOrgUnit/TooltipOrgUnit.component.js index 8b756f7e9c..db3c76c3bf 100644 --- a/src/core_modules/capture-core/components/Tooltips/TooltipOrgUnit/TooltipOrgUnit.component.js +++ b/src/core_modules/capture-core/components/Tooltips/TooltipOrgUnit/TooltipOrgUnit.component.js @@ -1,18 +1,19 @@ // @flow import React from 'react'; import { Tooltip } from '@dhis2/ui'; +import { useOrgUnitNameWithAncestors } from '../../../metadataRetrieval/orgUnitName'; type Props = { - orgUnitName: string, - ancestors?: Array, + orgUnitId: string, }; -export const TooltipOrgUnit = ({ orgUnitName, ancestors = [] }: Props) => { - const fullPath = [...ancestors, orgUnitName].join(' / '); +export const TooltipOrgUnit = ({ orgUnitId }: Props) => { + const { displayName, ancestors = [] } = useOrgUnitNameWithAncestors(orgUnitId); + const fullPath = [...ancestors, displayName].join(' / '); return ( - {orgUnitName} + {displayName} ); }; diff --git a/src/core_modules/capture-core/components/WidgetEnrollment/WidgetEnrollment.component.js b/src/core_modules/capture-core/components/WidgetEnrollment/WidgetEnrollment.component.js index 3bec583e85..00c44c0a6e 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollment/WidgetEnrollment.component.js +++ b/src/core_modules/capture-core/components/WidgetEnrollment/WidgetEnrollment.component.js @@ -78,8 +78,8 @@ export const WidgetEnrollmentPlain = ({ const { displayName: orgUnitName, ancestors } = useOrgUnitNameWithAncestors(enrollment?.orgUnit); const { displayName: ownerOrgUnitName, ancestors: ownerAncestors } = useOrgUnitNameWithAncestors(ownerOrgUnit?.id); - const orgUnitClientValue = { name: orgUnitName, ancestors }; - const ownerOrgUnitClientValue = { name: ownerOrgUnitName, ancestors: ownerAncestors }; + const orgUnitClientValue = { id: enrollment?.orgUnit, name: orgUnitName, ancestors }; + const ownerOrgUnitClientValue = { id: ownerOrgUnit?.id, name: ownerOrgUnitName, ancestors: ownerAncestors }; return (
diff --git a/src/core_modules/capture-core/components/WidgetProfile/hooks/getSubValueForTei.js b/src/core_modules/capture-core/components/WidgetProfile/hooks/getSubValueForTei.js index 89a9e819cf..b817c49404 100644 --- a/src/core_modules/capture-core/components/WidgetProfile/hooks/getSubValueForTei.js +++ b/src/core_modules/capture-core/components/WidgetProfile/hooks/getSubValueForTei.js @@ -2,6 +2,7 @@ import type { QuerySingleResource } from 'capture-core/utils/api'; import { dataElementTypes } from '../../../metaData'; import { FEATURES, hasAPISupportForFeature } from '../../../../capture-core-utils'; +import { getOrgUnitNames } from '../../../metadataRetrieval/orgUnitName'; type Attribute = { id: string, @@ -46,22 +47,10 @@ const getImageResourceSubvalue = async ({ attribute, minorServerVersion }: SubVa }; }; -const getOrganisationUnitSubvalue = async ({ attribute, querySingleResource }: SubValueFunctionParams) => { - const organisationUnit = await querySingleResource({ - resource: 'organisationUnits', - id: attribute.value, - params: { - fields: 'id,name,ancestors[displayName]', - }, - }); +const getOrganisationUnitSubvalue = async ({ attribute: { value }, querySingleResource }: SubValueFunctionParams) => { + const orgUnits = await getOrgUnitNames([value], querySingleResource); - const orgUnitClientValue = { - id: organisationUnit.id, - name: organisationUnit.name, - ancestors: organisationUnit.ancestors.map(ancestor => ancestor.displayName), - }; - - return orgUnitClientValue; + return orgUnits[value]; }; export const subValueGetterByElementType = { diff --git a/src/core_modules/capture-core/converters/clientToList.js b/src/core_modules/capture-core/converters/clientToList.js index b6580f0601..870d0d7981 100644 --- a/src/core_modules/capture-core/converters/clientToList.js +++ b/src/core_modules/capture-core/converters/clientToList.js @@ -38,10 +38,6 @@ type ImageClientValue = { previewUrl: string, }; -type OrgUnitClientValue = { - name: string, - ancestors?: Array, -}; function convertFileForDisplay(clientValue: FileClientValue) { // Fallback until https://dhis2.atlassian.net/browse/DHIS2-16994 is implemented @@ -92,15 +88,13 @@ function convertStatusForDisplay(clientValue: Object) { ); } -function convertOrgUnitForDisplay(clientValue: OrgUnitClientValue) { +function convertOrgUnitForDisplay(clientValue: { id: string }) { return ( - + ); } + const valueConvertersForType = { [dataElementTypes.NUMBER]: stringifyNumber, [dataElementTypes.INTEGER]: stringifyNumber, @@ -131,7 +125,6 @@ const valueConvertersForType = { }; export function convertValue(value: any, type: $Keys, dataElement?: ?DataElement) { - console.log('convertValue', value); if (!value && value !== 0 && value !== false) { return value; } diff --git a/src/core_modules/capture-core/converters/clientToView.js b/src/core_modules/capture-core/converters/clientToView.js index 115bcbeb69..2849a02b01 100644 --- a/src/core_modules/capture-core/converters/clientToView.js +++ b/src/core_modules/capture-core/converters/clientToView.js @@ -34,11 +34,6 @@ type ImageClientValue = { previewUrl: string, }; -type OrgUnitClientValue = { - name: string, - ancestors?: Array, - tooltip?: string, -}; function convertFileForDisplay(clientValue: FileClientValue) { return ( @@ -57,16 +52,13 @@ function convertImageForDisplay(clientValue: ImageClientValue) { return ; } -function convertOrgUnitForDisplay(clientValue: OrgUnitClientValue) { +function convertOrgUnitForDisplay(clientValue: { id: string }) { return ( - + ); } + const valueConvertersForType = { [dataElementTypes.NUMBER]: stringifyNumber, [dataElementTypes.INTEGER]: stringifyNumber, From 3c147c7cf2fc5e65018a211ac8004a8264db6ec6 Mon Sep 17 00:00:00 2001 From: henrikmv Date: Thu, 26 Sep 2024 14:28:21 +0200 Subject: [PATCH 3/6] feat: add orgunit context stages and events widget --- .../Tooltips/TooltipOrgUnit/TooltipOrgUnit.component.js | 2 +- .../Stages/Stage/StageDetail/hooks/helpers.js | 6 +++--- .../Stages/Stage/StageDetail/hooks/useEventList.js | 4 ++-- .../capture-core/metadataRetrieval/orgUnitName/index.js | 1 - .../metadataRetrieval/orgUnitName/orgUnitName.js | 2 -- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/core_modules/capture-core/components/Tooltips/TooltipOrgUnit/TooltipOrgUnit.component.js b/src/core_modules/capture-core/components/Tooltips/TooltipOrgUnit/TooltipOrgUnit.component.js index db3c76c3bf..7173df8144 100644 --- a/src/core_modules/capture-core/components/Tooltips/TooltipOrgUnit/TooltipOrgUnit.component.js +++ b/src/core_modules/capture-core/components/Tooltips/TooltipOrgUnit/TooltipOrgUnit.component.js @@ -12,7 +12,7 @@ export const TooltipOrgUnit = ({ orgUnitId }: Props) => { const fullPath = [...ancestors, displayName].join(' / '); return ( - + {displayName} ); diff --git a/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/StageDetail/hooks/helpers.js b/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/StageDetail/hooks/helpers.js index d4f2d6b2a6..dfe9868086 100644 --- a/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/StageDetail/hooks/helpers.js +++ b/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/StageDetail/hooks/helpers.js @@ -8,7 +8,7 @@ import type { StageDataElement } from '../../../../types/common.types'; import { Notes } from '../Notes.component'; import type { QuerySingleResource } from '../../../../../../utils/api/api.types'; import { isEventOverdue } from '../../../../../../utils/isEventOverdue'; -import { getCachedOrgUnitName } from '../../../../../../metadataRetrieval/orgUnitName'; +import { TooltipOrgUnit } from '../../../../../Tooltips/TooltipOrgUnit/TooltipOrgUnit.component'; const getEventStatus = (event: ApiEnrollmentEvent) => { const today = moment().startOf('day'); @@ -58,8 +58,8 @@ const convertStatusForView = (event: ApiEnrollmentEvent) => { }; }; -const convertOrgUnitForView = (event: ApiEnrollmentEvent) => getCachedOrgUnitName(event.orgUnit); - +const convertOrgUnitForView = (event: ApiEnrollmentEvent) => ; + const convertNoteForView = (event: ApiEnrollmentEvent) => ; const groupRecordsByType = async ( diff --git a/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/StageDetail/hooks/useEventList.js b/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/StageDetail/hooks/useEventList.js index 2199216154..3345d145d0 100644 --- a/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/StageDetail/hooks/useEventList.js +++ b/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/StageDetail/hooks/useEventList.js @@ -22,7 +22,7 @@ import { } from '../../../../../../metaDataMemoryStoreBuilders/common/helpers/dataElement/unsupportedMultiText'; import { useOrgUnitNames } from '../../../../../../metadataRetrieval/orgUnitName'; -const baseKeys = [{ id: 'status' }, { id: 'occurredAt' }, { id: 'assignedUser' }, { id: 'orgUnitName' }, { id: 'scheduledAt' }, { id: 'notes' }]; +const baseKeys = [{ id: 'status' }, { id: 'occurredAt' }, { id: 'assignedUser' }, { id: 'orgUnit' }, { id: 'scheduledAt' }, { id: 'notes' }]; const basedFieldTypes = [ { type: dataElementTypes.STATUS, resolveValue: convertStatusForView }, { type: dataElementTypes.DATE }, @@ -82,7 +82,7 @@ const useComputeDataFromEvent = (dataElements: Array, events: acc[field.id] = convertServerToClient(getValueByKeyFromEvent(event, field), field.type); return acc; }, {}); - + const allFields = getAllFieldsWithValue(eventId, dataElements, dataElementsByType); eventsData.push({ id: eventId, diff --git a/src/core_modules/capture-core/metadataRetrieval/orgUnitName/index.js b/src/core_modules/capture-core/metadataRetrieval/orgUnitName/index.js index 21e8b84212..204c983009 100644 --- a/src/core_modules/capture-core/metadataRetrieval/orgUnitName/index.js +++ b/src/core_modules/capture-core/metadataRetrieval/orgUnitName/index.js @@ -3,5 +3,4 @@ export { useOrgUnitNameWithAncestors, useOrgUnitNames, getOrgUnitNames, - getCachedOrgUnitName, } from './orgUnitName'; diff --git a/src/core_modules/capture-core/metadataRetrieval/orgUnitName/orgUnitName.js b/src/core_modules/capture-core/metadataRetrieval/orgUnitName/orgUnitName.js index 56d222c119..c86c4d7c14 100644 --- a/src/core_modules/capture-core/metadataRetrieval/orgUnitName/orgUnitName.js +++ b/src/core_modules/capture-core/metadataRetrieval/orgUnitName/orgUnitName.js @@ -209,5 +209,3 @@ export const useOrgUnitNameWithAncestors = (orgUnitId: ?string): { return { error }; }; - -export const getCachedOrgUnitName = (orgUnitId: string): ?string => displayNameCache[orgUnitId]?.displayName; From 2d76188e28cf34f6b01292cf8ae0b70279630d5f Mon Sep 17 00:00:00 2001 From: henrikmv Date: Thu, 26 Sep 2024 16:08:51 +0200 Subject: [PATCH 4/6] feat: use cache for subvalues --- .../hooks/getSubValueForTei.js | 12 ++++-------- .../WidgetProfile/hooks/getSubValueForTei.js | 4 ++-- .../Stages/Stage/StageDetail/hooks/helpers.js | 2 +- .../Stage/StageDetail/hooks/useEventList.js | 2 +- .../Stages/Stage/getEventDataWithSubValue.js | 17 ++++------------- .../utils/getSubValueForDataValue.js | 14 +++++--------- 6 files changed, 17 insertions(+), 34 deletions(-) diff --git a/src/core_modules/capture-core/components/DataEntries/EnrollmentRegistrationEntry/hooks/getSubValueForTei.js b/src/core_modules/capture-core/components/DataEntries/EnrollmentRegistrationEntry/hooks/getSubValueForTei.js index b8df8130ed..eab8d88a89 100644 --- a/src/core_modules/capture-core/components/DataEntries/EnrollmentRegistrationEntry/hooks/getSubValueForTei.js +++ b/src/core_modules/capture-core/components/DataEntries/EnrollmentRegistrationEntry/hooks/getSubValueForTei.js @@ -1,6 +1,8 @@ // @flow import type { QuerySingleResource } from 'capture-core/utils/api'; import { dataElementTypes } from '../../../../metaData'; +import { getOrgUnitNames } from '../../../../metadataRetrieval/orgUnitName'; + const getImageOrFileResourceSubvalue = async (key: string, querySingleResource: QuerySingleResource) => { const { id, displayName: name } = await querySingleResource({ resource: 'fileResources', id: key }); @@ -11,14 +13,8 @@ const getImageOrFileResourceSubvalue = async (key: string, querySingleResource: }; const getOrganisationUnitSubvalue = async (key: string, querySingleResource: QuerySingleResource) => { - const organisationUnit = await querySingleResource({ - resource: 'organisationUnits', - id: key, - params: { - fields: 'id,name', - }, - }); - return { ...organisationUnit }; + const organisationUnit = await getOrgUnitNames([key], querySingleResource); + return organisationUnit[key]; }; export const subValueGetterByElementType = { diff --git a/src/core_modules/capture-core/components/WidgetProfile/hooks/getSubValueForTei.js b/src/core_modules/capture-core/components/WidgetProfile/hooks/getSubValueForTei.js index b817c49404..7a34cd0cb6 100644 --- a/src/core_modules/capture-core/components/WidgetProfile/hooks/getSubValueForTei.js +++ b/src/core_modules/capture-core/components/WidgetProfile/hooks/getSubValueForTei.js @@ -48,9 +48,9 @@ const getImageResourceSubvalue = async ({ attribute, minorServerVersion }: SubVa }; const getOrganisationUnitSubvalue = async ({ attribute: { value }, querySingleResource }: SubValueFunctionParams) => { - const orgUnits = await getOrgUnitNames([value], querySingleResource); + const organisationUnit = await getOrgUnitNames([value], querySingleResource); - return orgUnits[value]; + return organisationUnit[value]; }; export const subValueGetterByElementType = { diff --git a/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/StageDetail/hooks/helpers.js b/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/StageDetail/hooks/helpers.js index dfe9868086..74ae039f19 100644 --- a/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/StageDetail/hooks/helpers.js +++ b/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/StageDetail/hooks/helpers.js @@ -59,7 +59,7 @@ const convertStatusForView = (event: ApiEnrollmentEvent) => { }; const convertOrgUnitForView = (event: ApiEnrollmentEvent) => ; - + const convertNoteForView = (event: ApiEnrollmentEvent) => ; const groupRecordsByType = async ( diff --git a/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/StageDetail/hooks/useEventList.js b/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/StageDetail/hooks/useEventList.js index 3345d145d0..f160eb00e3 100644 --- a/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/StageDetail/hooks/useEventList.js +++ b/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/StageDetail/hooks/useEventList.js @@ -82,7 +82,7 @@ const useComputeDataFromEvent = (dataElements: Array, events: acc[field.id] = convertServerToClient(getValueByKeyFromEvent(event, field), field.type); return acc; }, {}); - + const allFields = getAllFieldsWithValue(eventId, dataElements, dataElementsByType); eventsData.push({ id: eventId, diff --git a/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/getEventDataWithSubValue.js b/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/getEventDataWithSubValue.js index 29919f0fe8..92ea3af2a6 100644 --- a/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/getEventDataWithSubValue.js +++ b/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/getEventDataWithSubValue.js @@ -2,6 +2,7 @@ import { featureAvailable, FEATURES } from 'capture-core-utils'; import { dataElementTypes } from '../../../../metaData'; import type { QuerySingleResource } from '../../../../utils/api/api.types'; +import { getOrgUnitNames } from '../../../../metadataRetrieval/orgUnitName'; const getFileResourceSubvalue = async (keys: Object, querySingleResource: QuerySingleResource, eventId: string, absoluteApiPath: string) => { const promises = Object.keys(keys) @@ -55,19 +56,9 @@ const getImageSubvalue = (keys: Object, querySingleResource: QuerySingleResource ); const getOrganisationUnitSubvalue = async (keys: Object, querySingleResource: QuerySingleResource) => { - const ids = Object.values(keys) - .join(','); - - const { organisationUnits = [] } = await querySingleResource({ - resource: 'organisationUnits', - params: { filter: `id:in:[${ids}]` }, - }); - - return organisationUnits - .reduce((acc, { id, displayName: name }) => { - acc[id] = { id, name }; - return acc; - }, {}); + const ids = Object.values(keys).map(value => String(value)); + const orgUnitNames = await getOrgUnitNames(ids, querySingleResource); + return orgUnitNames; }; const subValueGetterByElementType = { diff --git a/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/utils/getSubValueForDataValue.js b/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/utils/getSubValueForDataValue.js index 8936d423b5..58f9ca8708 100644 --- a/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/utils/getSubValueForDataValue.js +++ b/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/utils/getSubValueForDataValue.js @@ -2,6 +2,7 @@ import { dataElementTypes } from '../../../metaData'; import type { QuerySingleResource } from '../../../utils/api'; import { featureAvailable, FEATURES } from '../../../../capture-core-utils'; +import { getOrgUnitNames } from '../../../metadataRetrieval/orgUnitName'; type SubValueFunctionProps = { dataElement: Object, @@ -42,15 +43,10 @@ const getImageSubvalue = async ({ dataElement, querySingleResource, eventId, abs }; }; -const getOrganisationUnitSubvalue = async ({ dataElement, querySingleResource }: SubValueFunctionProps) => { - const organisationUnit = await querySingleResource({ - resource: 'organisationUnits', - id: dataElement.value, - params: { - fields: 'id,name', - }, - }); - return { ...organisationUnit }; +const getOrganisationUnitSubvalue = async ({ dataElement: { value }, querySingleResource }: SubValueFunctionProps) => { + const organisationUnit = await getOrgUnitNames([value], querySingleResource); + + return organisationUnit[value]; }; export const subValueGetterByElementType = { From fdd87eb3309b93f374e02706ed27c1d4375e847d Mon Sep 17 00:00:00 2001 From: henrikmv Date: Fri, 27 Sep 2024 09:02:31 +0200 Subject: [PATCH 5/6] feat: orgunit context event workspace --- .../FlatListOrgUnitField.js | 19 ------------------- .../FlatListOrgUnitField/index.js | 3 --- .../utils/getDataEntryDetails.js | 4 ++-- 3 files changed, 2 insertions(+), 24 deletions(-) delete mode 100644 src/core_modules/capture-core/components/WidgetTwoEventWorkspace/FlatListOrgUnitField/FlatListOrgUnitField.js delete mode 100644 src/core_modules/capture-core/components/WidgetTwoEventWorkspace/FlatListOrgUnitField/index.js diff --git a/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/FlatListOrgUnitField/FlatListOrgUnitField.js b/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/FlatListOrgUnitField/FlatListOrgUnitField.js deleted file mode 100644 index aaf3ffdf3c..0000000000 --- a/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/FlatListOrgUnitField/FlatListOrgUnitField.js +++ /dev/null @@ -1,19 +0,0 @@ -// @flow -import React from 'react'; -import { useOrgUnitNameWithAncestors } from '../../../metadataRetrieval/orgUnitName'; - -type Props = { - orgUnitId: string, -} - -export const FlatListOrgUnitField = ({ - orgUnitId, -}: Props) => { - const { displayName } = useOrgUnitNameWithAncestors(orgUnitId); - - return ( - - {displayName} - - ); -}; diff --git a/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/FlatListOrgUnitField/index.js b/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/FlatListOrgUnitField/index.js deleted file mode 100644 index cf8e8c20b7..0000000000 --- a/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/FlatListOrgUnitField/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow - -export { FlatListOrgUnitField } from './FlatListOrgUnitField'; diff --git a/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/utils/getDataEntryDetails.js b/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/utils/getDataEntryDetails.js index 3e42d171de..a76d895a77 100644 --- a/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/utils/getDataEntryDetails.js +++ b/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/utils/getDataEntryDetails.js @@ -5,7 +5,7 @@ import i18n from '@dhis2/d2-i18n'; import { dataElementTypes, type RenderFoundation } from '../../../metaData'; import { convertClientToView, convertServerToClient } from '../../../converters'; import type { LinkedEvent } from '../WidgetTwoEventWorkspace.types'; -import { FlatListOrgUnitField } from '../FlatListOrgUnitField'; +import { TooltipOrgUnit } from '../../Tooltips/TooltipOrgUnit'; const convertFn = pipe(convertServerToClient, convertClientToView); @@ -37,7 +37,7 @@ const DataEntryFieldsToInclude = { type: dataElementTypes.ORGANISATION_UNIT, placement: Placements.TOP, label: i18n.t('Organisation unit'), - convertFn: orgUnitId => , + convertFn: orgUnitId => , }, status: { apiKey: 'status', From 29d96a21ddc73c9bdfb128180afd80870ded7546 Mon Sep 17 00:00:00 2001 From: henrikmv Date: Mon, 30 Sep 2024 15:59:45 +0200 Subject: [PATCH 6/6] fix: renaming of return statement --- .../components/WidgetProfile/hooks/getSubValueForTei.js | 5 ++--- .../WidgetTwoEventWorkspace/utils/getSubValueForDataValue.js | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/core_modules/capture-core/components/WidgetProfile/hooks/getSubValueForTei.js b/src/core_modules/capture-core/components/WidgetProfile/hooks/getSubValueForTei.js index 7a34cd0cb6..f7d8d670f8 100644 --- a/src/core_modules/capture-core/components/WidgetProfile/hooks/getSubValueForTei.js +++ b/src/core_modules/capture-core/components/WidgetProfile/hooks/getSubValueForTei.js @@ -48,9 +48,8 @@ const getImageResourceSubvalue = async ({ attribute, minorServerVersion }: SubVa }; const getOrganisationUnitSubvalue = async ({ attribute: { value }, querySingleResource }: SubValueFunctionParams) => { - const organisationUnit = await getOrgUnitNames([value], querySingleResource); - - return organisationUnit[value]; + const organisationUnits = await getOrgUnitNames([value], querySingleResource); + return organisationUnits[value]; }; export const subValueGetterByElementType = { diff --git a/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/utils/getSubValueForDataValue.js b/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/utils/getSubValueForDataValue.js index 58f9ca8708..8697c031ec 100644 --- a/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/utils/getSubValueForDataValue.js +++ b/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/utils/getSubValueForDataValue.js @@ -44,9 +44,8 @@ const getImageSubvalue = async ({ dataElement, querySingleResource, eventId, abs }; const getOrganisationUnitSubvalue = async ({ dataElement: { value }, querySingleResource }: SubValueFunctionProps) => { - const organisationUnit = await getOrgUnitNames([value], querySingleResource); - - return organisationUnit[value]; + const organisationUnits = await getOrgUnitNames([value], querySingleResource); + return organisationUnits[value]; }; export const subValueGetterByElementType = {