From eb5a4b036db93f7b94548e6fd66f4ed0038ce343 Mon Sep 17 00:00:00 2001 From: eirikhaugstulen Date: Tue, 12 Sep 2023 16:59:37 +0200 Subject: [PATCH 1/2] feat: added orgUnitId and programId to plugin --- .../D2Form/FormFieldPlugin/FormFieldPlugin.container.js | 5 +++++ .../D2Form/FormFieldPlugin/FormFieldPlugin.types.js | 2 ++ 2 files changed, 7 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..dad661d39c 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 { programId, orgUnitId } = useLocationQuery(); // Plugin related functionality and feedback const { pluginValues } = usePluginValues(formId, metadataByPluginId, pluginContext); @@ -39,6 +41,8 @@ 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..969b63aed7 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,8 @@ export type ComponentProps = {| fieldsMetadata: MetadataByPluginId, formSubmitted: boolean, values: { [id: string]: any }, + orgUnitId: string, + programId: string, setFieldValue: (SetFieldValueProps) => void, errors: { [id: string]: Array }, warnings: { [id: string]: Array }, From 6e99259d6b27646d3b7f91fc378af7bf93d0794a Mon Sep 17 00:00:00 2001 From: eirikhaugstulen Date: Tue, 19 Sep 2023 13:57:50 +0200 Subject: [PATCH 2/2] chore: remove contextId temporarily --- .../D2Form/FormFieldPlugin/FormFieldPlugin.container.js | 3 +-- .../components/D2Form/FormFieldPlugin/FormFieldPlugin.types.js | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) 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 dad661d39c..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 @@ -12,7 +12,7 @@ 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 { programId, orgUnitId } = useLocationQuery(); + const { orgUnitId } = useLocationQuery(); // Plugin related functionality and feedback const { pluginValues } = usePluginValues(formId, metadataByPluginId, pluginContext); @@ -42,7 +42,6 @@ export const FormFieldPlugin = (props: ContainerProps) => { return ( void, errors: { [id: string]: Array }, warnings: { [id: string]: Array },