From 1b4be20b474f2f5b6c4eb66c37b0c509291b5bf6 Mon Sep 17 00:00:00 2001 From: Eirik Haugstulen Date: Tue, 13 Aug 2024 16:59:13 +0200 Subject: [PATCH] feat: [DHIS2-12288] add enrollment section description (#3750) --- .../DataEntry/FormFoundation/RenderFoundation.js | 5 +++++ .../components/WidgetProfile/hooks/useApiProgram.js | 2 +- .../programs/factory/enrollment/EnrollmentFactory.js | 4 ++++ .../programs/quickStoreOperations/storePrograms.js | 2 +- .../programs/quickStoreOperations/types/apiPrograms.types.js | 3 ++- .../capture-core/storageControllers/cache.types.js | 3 ++- 6 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/core_modules/capture-core/components/WidgetProfile/DataEntry/FormFoundation/RenderFoundation.js b/src/core_modules/capture-core/components/WidgetProfile/DataEntry/FormFoundation/RenderFoundation.js index 4e2d0b26e3..6cbedfb764 100644 --- a/src/core_modules/capture-core/components/WidgetProfile/DataEntry/FormFoundation/RenderFoundation.js +++ b/src/core_modules/capture-core/components/WidgetProfile/DataEntry/FormFoundation/RenderFoundation.js @@ -177,6 +177,7 @@ const buildSection = async ({ optionSets, sectionCustomLabel, sectionCustomId, + sectionDisplayDescription, querySingleResource, minorServerVersion, }: { @@ -185,6 +186,7 @@ const buildSection = async ({ optionSets: Array, sectionCustomLabel: string, sectionCustomId: string, + sectionDisplayDescription: string, querySingleResource: QuerySingleResource, minorServerVersion: number, }) => { @@ -195,6 +197,7 @@ const buildSection = async ({ const section = new Section((o) => { o.id = sectionCustomId; o.name = sectionCustomLabel; + o.displayDescription = sectionDisplayDescription; }); await buildElementsForSection({ @@ -281,6 +284,7 @@ export const buildFormFoundation = async (program: any, querySingleResource: Que programTrackedEntityAttributes: attributes, sectionCustomLabel: formConfigSection.name ?? sectionMetadata?.displayFormName ?? i18n.t('Profile'), sectionCustomId: formConfigSection.id, + sectionDisplayDescription: sectionMetadata?.displayDescription ?? '', minorServerVersion, trackedEntityAttributes, optionSets, @@ -299,6 +303,7 @@ export const buildFormFoundation = async (program: any, querySingleResource: Que optionSets, sectionCustomLabel: programSection.displayFormName, sectionCustomId: programSection.id, + sectionDisplayDescription: programSection.displayDescription, querySingleResource, minorServerVersion, }); diff --git a/src/core_modules/capture-core/components/WidgetProfile/hooks/useApiProgram.js b/src/core_modules/capture-core/components/WidgetProfile/hooks/useApiProgram.js index 073ab42e40..fde2d1575c 100644 --- a/src/core_modules/capture-core/components/WidgetProfile/hooks/useApiProgram.js +++ b/src/core_modules/capture-core/components/WidgetProfile/hooks/useApiProgram.js @@ -8,7 +8,7 @@ const fields = 'dataEntryForm[id,htmlCode],' + 'categoryCombo[id,displayName,isDefault,categories[id,displayName]],' + 'programIndicators[id,displayName,code,shortName,style,displayInForm,expression,displayDescription,description,filter,program[id]],' + - 'programSections[id, displayFormName, sortOrder, trackedEntityAttributes],' + + 'programSections[id,displayFormName,displayDescription,sortOrder,trackedEntityAttributes],' + 'programRuleVariables[id,displayName,programRuleVariableSourceType,valueType,program[id],programStage[id],dataElement[id],trackedEntityAttribute[id],useCodeForOptionSet],' + 'programStages[id,access,autoGenerateEvent,openAfterEnrollment,generatedByEnrollmentDate,reportDateToUse,minDaysFromStart,displayName,description,executionDateLabel,formType,featureType,validationStrategy,enableUserAssignment,style,' + 'dataEntryForm[id,htmlCode],' + diff --git a/src/core_modules/capture-core/metaDataMemoryStoreBuilders/programs/factory/enrollment/EnrollmentFactory.js b/src/core_modules/capture-core/metaDataMemoryStoreBuilders/programs/factory/enrollment/EnrollmentFactory.js index d865498f0a..50074f6951 100644 --- a/src/core_modules/capture-core/metaDataMemoryStoreBuilders/programs/factory/enrollment/EnrollmentFactory.js +++ b/src/core_modules/capture-core/metaDataMemoryStoreBuilders/programs/factory/enrollment/EnrollmentFactory.js @@ -181,6 +181,7 @@ export class EnrollmentFactory { cachedProgramTrackedEntityAttributes?: Array, cachedSectionCustomLabel: string, cachedSectionCustomId: string, + description: string, ) { if (!cachedProgramTrackedEntityAttributes?.length) { return null; @@ -189,6 +190,7 @@ export class EnrollmentFactory { const section = new Section((o) => { o.id = cachedSectionCustomId; o.name = cachedSectionCustomLabel; + o.displayDescription = description; o.group = Section.groups.ENROLLMENT; }); @@ -302,6 +304,7 @@ export class EnrollmentFactory { attributes, formConfigSection.name ?? sectionMetadata?.displayFormName ?? i18n.t('Profile'), formConfigSection.id, + sectionMetadata?.displayDescription ?? '', ); section && enrollmentForm.addSection(section); }); @@ -312,6 +315,7 @@ export class EnrollmentFactory { programSection.trackedEntityAttributes.map(id => trackedEntityAttributeDictionary[id]), programSection.displayFormName, programSection.id, + programSection.displayDescription, ); section && enrollmentForm.addSection(section); }); diff --git a/src/core_modules/capture-core/metaDataStoreLoaders/programs/quickStoreOperations/storePrograms.js b/src/core_modules/capture-core/metaDataStoreLoaders/programs/quickStoreOperations/storePrograms.js index d0b9487308..529cb771b1 100644 --- a/src/core_modules/capture-core/metaDataStoreLoaders/programs/quickStoreOperations/storePrograms.js +++ b/src/core_modules/capture-core/metaDataStoreLoaders/programs/quickStoreOperations/storePrograms.js @@ -93,7 +93,7 @@ const fieldsParam = 'id,displayName,displayShortName,description,programType,sty 'programStageSections[id,displayName,displayDescription,sortOrder,dataElements[id]],' + // eslint-disable-next-line max-len 'programStageDataElements[compulsory,displayInReports,renderOptionsAsRadio,allowFutureDate,renderType[*],dataElement[id]]]' + -'programSections[id, displayFormName, sortOrder, trackedEntityAttributes],' + +'programSections[id, displayDescription, displayFormName, sortOrder, trackedEntityAttributes],' + // eslint-disable-next-line max-len 'programTrackedEntityAttributes[trackedEntityAttribute[id],displayInList,searchable,mandatory,renderOptionsAsRadio,allowFutureDate]'; diff --git a/src/core_modules/capture-core/metaDataStoreLoaders/programs/quickStoreOperations/types/apiPrograms.types.js b/src/core_modules/capture-core/metaDataStoreLoaders/programs/quickStoreOperations/types/apiPrograms.types.js index d4c2e3024d..1112031950 100644 --- a/src/core_modules/capture-core/metaDataStoreLoaders/programs/quickStoreOperations/types/apiPrograms.types.js +++ b/src/core_modules/capture-core/metaDataStoreLoaders/programs/quickStoreOperations/types/apiPrograms.types.js @@ -63,7 +63,8 @@ type apiProgramSections = { id: string, sortOrder: number, displayFormName: string, - trackedEntityAttributes: Array<{ id: string }> + trackedEntityAttributes: Array<{ id: string }>, + description: ?string } type apiOption = { diff --git a/src/core_modules/capture-core/storageControllers/cache.types.js b/src/core_modules/capture-core/storageControllers/cache.types.js index 01c852ec84..121534f5ab 100644 --- a/src/core_modules/capture-core/storageControllers/cache.types.js +++ b/src/core_modules/capture-core/storageControllers/cache.types.js @@ -171,7 +171,8 @@ export type CachedProgramSection = { id: string, displayFormName: string, sortOrder: number, - trackedEntityAttributes: Array + trackedEntityAttributes: Array, + displayDescription: string } export type CachedTrackedEntityType = {