From b9ec237af595a1112dc6db01206e8332c9bb6647 Mon Sep 17 00:00:00 2001 From: eirikhaugstulen Date: Wed, 20 Sep 2023 13:57:39 +0200 Subject: [PATCH] feat: [DHIS2-15830] Add orgUnitId to plugin context --- .../D2Form/FormFieldPlugin/FormFieldPlugin.container.js | 4 ++++ .../D2Form/FormFieldPlugin/FormFieldPlugin.types.js | 1 + 2 files changed, 5 insertions(+) diff --git a/src/core_modules/capture-core/components/D2Form/FormFieldPlugin/FormFieldPlugin.container.js b/src/core_modules/capture-core/components/D2Form/FormFieldPlugin/FormFieldPlugin.container.js index 7f4b193646..65e4cf82e8 100644 --- a/src/core_modules/capture-core/components/D2Form/FormFieldPlugin/FormFieldPlugin.container.js +++ b/src/core_modules/capture-core/components/D2Form/FormFieldPlugin/FormFieldPlugin.container.js @@ -6,11 +6,13 @@ import { usePluginMessages } from './hooks/usePluginMessages'; import { usePluginCallbacks } from './hooks/usePluginCallbacks'; import { usePluginValues } from './hooks/usePluginValues'; import { formatPluginConfig } from './formatPluginConfig'; +import { useLocationQuery } from '../../../utils/routing'; export const FormFieldPlugin = (props: ContainerProps) => { const { pluginSource, fieldsMetadata, formId, onUpdateField, pluginContext } = props; const metadataByPluginId = useMemo(() => Object.fromEntries(fieldsMetadata), [fieldsMetadata]); const configuredPluginIds = useMemo(() => Object.keys(metadataByPluginId), [metadataByPluginId]); + const { orgUnitId } = useLocationQuery(); // Plugin related functionality and feedback const { pluginValues } = usePluginValues(formId, metadataByPluginId, pluginContext); @@ -39,6 +41,7 @@ export const FormFieldPlugin = (props: ContainerProps) => { return ( { /> ); }; + diff --git a/src/core_modules/capture-core/components/D2Form/FormFieldPlugin/FormFieldPlugin.types.js b/src/core_modules/capture-core/components/D2Form/FormFieldPlugin/FormFieldPlugin.types.js index 3aa8638400..9a97d2e42a 100644 --- a/src/core_modules/capture-core/components/D2Form/FormFieldPlugin/FormFieldPlugin.types.js +++ b/src/core_modules/capture-core/components/D2Form/FormFieldPlugin/FormFieldPlugin.types.js @@ -64,6 +64,7 @@ export type ComponentProps = {| fieldsMetadata: MetadataByPluginId, formSubmitted: boolean, values: { [id: string]: any }, + orgUnitId: string, setFieldValue: (SetFieldValueProps) => void, errors: { [id: string]: Array }, warnings: { [id: string]: Array },