-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [DHIS2-17591][DHIS2-17607] Plugins in event forms (#3684)
- Loading branch information
1 parent
24be388
commit 205b9f5
Showing
38 changed files
with
492 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 0 additions & 54 deletions
54
...tries/SingleEventRegistrationEntry/DataEntryWrapper/newEventDataEntryWrapper.selectors.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...ules/capture-core/components/DataEntries/common/ProgramStage/buildProgramStageMetadata.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// @flow | ||
import type { | ||
CachedDataElement, | ||
CachedOptionSet, | ||
CachedProgramStage, | ||
} from '../../../../storageControllers'; | ||
import type { DataEntryFormConfig } from '../TEIAndEnrollment'; | ||
import { getUserStorageController, userStores } from '../../../../storageControllers'; | ||
import { ProgramStageFactory } from '../../../../metaDataMemoryStoreBuilders/programs/factory/programStage'; | ||
|
||
export const buildProgramStageMetadata = async ({ | ||
cachedProgramStage, | ||
programId, | ||
cachedDataElements, | ||
cachedOptionSets, | ||
locale, | ||
minorServerVersion, | ||
dataEntryFormConfig, | ||
}: { | ||
cachedProgramStage: CachedProgramStage, | ||
programId: string, | ||
cachedOptionSets: Array<CachedOptionSet>, | ||
cachedDataElements: Array<CachedDataElement>, | ||
dataEntryFormConfig: ?DataEntryFormConfig, | ||
locale: string, | ||
minorServerVersion: number, | ||
}) => { | ||
const storageController = getUserStorageController(); | ||
|
||
const cachedRelationshipTypes = await storageController.getAll(userStores.RELATIONSHIP_TYPES); | ||
|
||
const programStageFactory = new ProgramStageFactory({ | ||
cachedOptionSets: new Map<string, CachedOptionSet>(cachedOptionSets.map(optionSet => [optionSet.id, optionSet])), | ||
cachedRelationshipTypes, | ||
cachedDataElements: new Map<string, CachedDataElement>(cachedDataElements.map(dataElement => [dataElement.id, dataElement])), | ||
locale, | ||
minorServerVersion, | ||
dataEntryFormConfig, | ||
}); | ||
|
||
return programStageFactory.build( | ||
cachedProgramStage, | ||
programId, | ||
); | ||
}; |
4 changes: 4 additions & 0 deletions
4
src/core_modules/capture-core/components/DataEntries/common/ProgramStage/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// @flow | ||
|
||
export { useDataElementsForStage } from './useDataElementsForStage'; | ||
export { buildProgramStageMetadata } from './buildProgramStageMetadata'; |
41 changes: 41 additions & 0 deletions
41
...odules/capture-core/components/DataEntries/common/ProgramStage/useDataElementsForStage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// @flow | ||
import { useIndexedDBQuery } from '../../../../utils/reactQueryHelpers'; | ||
import { getUserStorageController, userStores } from '../../../../storageControllers'; | ||
|
||
type Props = {| | ||
programId: string, | ||
dataElementIds: Array<string>, | ||
stageId?: string, | ||
|} | ||
|
||
const getDataElementsForStage = async ({ | ||
dataElementIds, | ||
}) => { | ||
const storageController = getUserStorageController(); | ||
|
||
return storageController.getAll(userStores.DATA_ELEMENTS, { | ||
predicate: dataElement => dataElementIds.includes(dataElement.id), | ||
}); | ||
}; | ||
|
||
export const useDataElementsForStage = ({ | ||
dataElementIds, | ||
programId, | ||
stageId, | ||
}: Props) => { | ||
const { data, isLoading } = useIndexedDBQuery( | ||
// $FlowFixMe | ||
[programId, 'dataElements', stageId, { dataElementIds }], | ||
() => getDataElementsForStage({ | ||
dataElementIds, | ||
}), | ||
{ | ||
enabled: !!dataElementIds, | ||
}, | ||
); | ||
|
||
return { | ||
dataElements: data, | ||
isLoading, | ||
}; | ||
}; |
Oops, something went wrong.