From a54a9293e6eca2039a5474c204f565a00e5298d2 Mon Sep 17 00:00:00 2001 From: eirikhaugstulen Date: Fri, 9 Aug 2024 21:05:24 +0200 Subject: [PATCH 1/3] feat: add enrollment section description --- .../programs/factory/enrollment/EnrollmentFactory.js | 4 ++++ .../programs/quickStoreOperations/storePrograms.js | 4 +++- .../programs/quickStoreOperations/types/apiPrograms.types.js | 3 ++- .../capture-core/storageControllers/cache.types.js | 3 ++- 4 files changed, 11 insertions(+), 3 deletions(-) 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..699ab13007 100644 --- a/src/core_modules/capture-core/metaDataStoreLoaders/programs/quickStoreOperations/storePrograms.js +++ b/src/core_modules/capture-core/metaDataStoreLoaders/programs/quickStoreOperations/storePrograms.js @@ -24,6 +24,8 @@ const convert = (() => { (apiProgramSections || []) .map(apiProgramSection => ({ ...apiProgramSection, + description: undefined, + displayDescription: apiProgramSection.description || '', trackedEntityAttributes: apiProgramSection.trackedEntityAttributes.map(te => te.id), })) .sort((a, b) => a.sortOrder - b.sortOrder); @@ -93,7 +95,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, description, 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 = { From 28a1696e48b34f973d697d7e2bc822f3fd70431b Mon Sep 17 00:00:00 2001 From: eirikhaugstulen Date: Tue, 13 Aug 2024 10:17:54 +0200 Subject: [PATCH 2/3] fix: use displayDescription --- .../programs/quickStoreOperations/storePrograms.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 699ab13007..529cb771b1 100644 --- a/src/core_modules/capture-core/metaDataStoreLoaders/programs/quickStoreOperations/storePrograms.js +++ b/src/core_modules/capture-core/metaDataStoreLoaders/programs/quickStoreOperations/storePrograms.js @@ -24,8 +24,6 @@ const convert = (() => { (apiProgramSections || []) .map(apiProgramSection => ({ ...apiProgramSection, - description: undefined, - displayDescription: apiProgramSection.description || '', trackedEntityAttributes: apiProgramSection.trackedEntityAttributes.map(te => te.id), })) .sort((a, b) => a.sortOrder - b.sortOrder); @@ -95,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, description, displayFormName, sortOrder, trackedEntityAttributes],' + +'programSections[id, displayDescription, displayFormName, sortOrder, trackedEntityAttributes],' + // eslint-disable-next-line max-len 'programTrackedEntityAttributes[trackedEntityAttribute[id],displayInList,searchable,mandatory,renderOptionsAsRadio,allowFutureDate]'; From 778326f34ab4f7507def85c1e0af87aea136b119 Mon Sep 17 00:00:00 2001 From: eirikhaugstulen Date: Tue, 13 Aug 2024 14:13:40 +0200 Subject: [PATCH 3/3] fix: add description to profile widget --- .../DataEntry/FormFoundation/RenderFoundation.js | 5 +++++ .../components/WidgetProfile/hooks/useApiProgram.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) 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],' +