Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [DHIS2-14775][DHIS2-14729] Render data entry plugins #3222

Merged
merged 45 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
b258e20
feat: build form metadata for registration page on demand
eirikhaugstulen Feb 28, 2023
f3e53e7
fix: include program search groups in enrollment to allow duplicate s…
eirikhaugstulen Mar 1, 2023
0f9f8cc
fix: fully replace the existing metadata-hook
eirikhaugstulen Mar 1, 2023
20e9666
fix: build metadata form based on config
eirikhaugstulen Mar 7, 2023
275827d
fix: code cleanup
eirikhaugstulen Mar 7, 2023
3847e51
Merge remote-tracking branch 'origin/master' into eh/TECH/TECH-1506_B…
eirikhaugstulen Mar 8, 2023
99be369
fix: review comments
eirikhaugstulen Mar 16, 2023
5d81c3c
fix: temp
eirikhaugstulen Mar 23, 2023
113779b
fix: render data entry plugins
eirikhaugstulen Mar 30, 2023
cdb9c2d
fix: temporarily comment out flow
eirikhaugstulen Mar 30, 2023
fc829d4
Merge remote-tracking branch 'origin/master' into eh/TECH/TECH-1506_B…
eirikhaugstulen Mar 31, 2023
9f0d7a3
fix: PR-comments
eirikhaugstulen Mar 31, 2023
2030bd1
fix: change handling of saveButtonText
eirikhaugstulen Apr 3, 2023
3d65553
fix: add a plugin context for data entry
eirikhaugstulen Apr 5, 2023
8891bcf
Merge remote-tracking branch 'origin/eh/TECH/TECH-1506_BuildFormMetad…
eirikhaugstulen Apr 5, 2023
ef90ffa
fix: add setContextFieldValue
eirikhaugstulen Apr 5, 2023
f1c631e
fix: yarn.lock
eirikhaugstulen Apr 5, 2023
96b2c69
fix: yarn.lock
eirikhaugstulen Apr 5, 2023
942f17f
fix: corejs dependency error
eirikhaugstulen Apr 17, 2023
40626e1
fix: add context values to the plugin values
eirikhaugstulen Apr 18, 2023
e5ec9a1
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-14729…
eirikhaugstulen Apr 18, 2023
3acd9b9
chore: flow
eirikhaugstulen Apr 18, 2023
09b13cd
fix: build field validator on demand from plugin
eirikhaugstulen May 9, 2023
d20cdde
fix: remove id from metadata
eirikhaugstulen May 9, 2023
cb69c7e
fix: add code to form elements
eirikhaugstulen May 9, 2023
1118af0
fix: rename plugin to FormFieldPlugin
eirikhaugstulen May 9, 2023
dd8f5bc
fix: moved FormBuilder to D2Form
eirikhaugstulen May 10, 2023
a671a50
fix: add errorOnComplete and formSubmitted
eirikhaugstulen May 10, 2023
f219901
chore: flow
eirikhaugstulen May 10, 2023
59f2c49
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-14729…
eirikhaugstulen May 11, 2023
e4d4b28
fix: add option sets to metadata
eirikhaugstulen May 11, 2023
f1a7497
feat: add attributes to TEAs
eirikhaugstulen May 12, 2023
a69f067
chore: PR-reviews
eirikhaugstulen May 12, 2023
010c847
chore: add attributes to plugin objects
eirikhaugstulen May 20, 2023
1d71102
chore: refactor for-loop
eirikhaugstulen May 23, 2023
706a1b5
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-14729…
eirikhaugstulen Jun 26, 2023
418cb86
chore: revert plugin component
eirikhaugstulen Jun 26, 2023
43c3ce7
fix: pr-reviews
eirikhaugstulen Jun 26, 2023
11d5fec
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-14729…
eirikhaugstulen Jun 27, 2023
aea5052
fix: flow
eirikhaugstulen Jun 27, 2023
9bf5fd3
fix: alpha package
eirikhaugstulen Jun 27, 2023
12c25e3
fix: lockfile
eirikhaugstulen Jun 27, 2023
6c46edf
fix: lockfile
eirikhaugstulen Jun 28, 2023
fa7e0ce
fix: core-js resolution
eirikhaugstulen Jul 3, 2023
92f1878
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-14729…
eirikhaugstulen Jul 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 12 additions & 21 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ msgstr "Date of enrollment"
msgid "Last updated"
msgstr "Last updated"

msgid "error encountered during field validation"
msgstr "error encountered during field validation"

msgid "error"
msgstr "error"

msgid "Plugins are not yet available - Please contact your system administrator"
msgstr "Plugins are not yet available - Please contact your system administrator"

msgid "This value is validating"
msgstr "This value is validating"

Expand Down Expand Up @@ -823,6 +832,9 @@ msgstr "You can also choose a program from the top bar and create in that progra
msgid "New Enrollment in program{{escape}} {{programName}}"
msgstr "New Enrollment in program{{escape}} {{programName}}"

msgid "Save {{trackedEntityTypeName}}"
msgstr "Save {{trackedEntityTypeName}}"

msgid "Save {{trackedEntityName}}"
msgstr "Save {{trackedEntityName}}"

Expand Down Expand Up @@ -977,11 +989,6 @@ msgstr "You can also choose a program from the top bar and search in that progra
msgid "Choose a type to start searching"
msgstr "Choose a type to start searching"

msgid "Fill in at least {{count}} attribute to search"
msgid_plural "Fill in at least {{count}} attribute to search"
msgstr[0] "Fill in at least {{count}} attribute to search"
msgstr[1] "Fill in at least {{count}} attributes to search"

msgid "Search {{name}}"
msgstr "Search {{name}}"

Expand Down Expand Up @@ -1235,22 +1242,12 @@ msgstr "Scheduled automatically for {{suggestedScheduleDate}}"
msgid "The scheduled date matches the suggested date, but can be changed if needed."
msgstr "The scheduled date matches the suggested date, but can be changed if needed."

msgid "The scheduled date is {{count}} days {{position}} the suggested date."
msgid_plural "The scheduled date is {{count}} days {{position}} the suggested date."
msgstr[0] "The scheduled date is {{count}} day {{position}} the suggested date."
msgstr[1] "The scheduled date is {{count}} days {{position}} the suggested date."

msgid "after"
msgstr "after"

msgid "before"
msgstr "before"

msgid "There are {{count}} scheduled event in {{orgUnitName}} on this day."
msgid_plural "There are {{count}} scheduled event in {{orgUnitName}} on this day."
msgstr[0] "There are {{count}} scheduled event in {{orgUnitName}} on this day."
msgstr[1] "There are {{count}} scheduled events in {{orgUnitName}} on this day."

msgid "Scheduling an event in {{stageName}} for {{programName}} in {{orgUnitName}}"
msgstr "Scheduling an event in {{stageName}} for {{programName}} in {{orgUnitName}}"

Expand Down Expand Up @@ -1521,12 +1518,6 @@ msgstr "To date"
msgid "To time"
msgstr "To time"

msgid "error encountered during field validation"
msgstr "error encountered during field validation"

msgid "error"
msgstr "error"

msgid "Delete polygon"
msgstr "Delete polygon"

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
"packages/rules-engine"
],
"dependencies": {
"@dhis2/rules-engine-javascript": "100.33.0",
"@dhis2/app-runtime": "^3.8.0",
"@dhis2/d2-i18n": "^1.1.0",
"@dhis2/d2-icons": "^1.0.1",
"@dhis2/d2-ui-app": "^2.0.0",
"@dhis2/d2-ui-org-unit-tree": "^7.3.3",
"@dhis2/d2-ui-rich-text": "^7.4.0",
"@dhis2/d2-ui-sharing-dialog": "^7.3.3",
"@dhis2/rules-engine-javascript": "100.33.0",
"@dhis2/ui": "^8.7.7",
"@joakim_sm/react-infinite-calendar": "^2.4.2",
"@material-ui/core": "3.9.4",
Expand Down Expand Up @@ -130,7 +130,8 @@
"wait-on": "^6.0.1"
},
"resolutions": {
"@babel/preset-react": "7.16.7"
"@babel/preset-react": "7.16.7",
"core-js": "2.5.7"
},
"browserslist": {
"production": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from 'react';
import log from 'loglevel';
import { walk, kinds } from 'react-transform-tree';
import { errorCreator } from 'capture-core-utils';
import type { FieldConfig } from 'capture-ui/FormBuilder/FormBuilder.component';
import type { FieldConfig } from '../FormBuilder';
import { CustomForm } from '../../../metaData';

type Props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
import React, { Component } from 'react';
import log from 'loglevel';
import { errorCreator } from 'capture-core-utils';
import type { FormBuilder, FieldConfig } from 'capture-ui/FormBuilder/FormBuilder.component';
import { FormBuilderContainer } from './FormBuilder.container';
import type { FieldConfig, FormBuilder } from './FormBuilder/FormBuilder.component';
import { FormBuilderContainer } from './FormBuilder/FormBuilder.container';
import { withDivider } from './FieldDivider/withDivider';
import { withAlternateBackgroundColors } from './FieldAlternateBackgroundColors/withAlternateBackgroundColors';
import { withCustomForm } from './D2CustomForm/withCustomForm';
import { buildField } from './field/buildField';
import { validationStrategies } from '../../metaData/RenderFoundation/renderFoundation.const';
import type { DataElement, CustomForm } from '../../metaData';
import type { CustomForm, DataElement } from '../../metaData';
import { messageStateKeys } from '../../reducers/descriptions/rulesEffects.reducerDescription';
import { validatorTypes } from './field/validators/constants';
import type { QuerySingleResource } from '../../utils/api/api.types';
import { FormFieldPlugin } from './FormFieldPlugin';
import { FormFieldPluginConfig } from '../../metaData/FormFieldPluginConfig';

const CustomFormHOC = withCustomForm()(withDivider()(withAlternateBackgroundColors()(FormBuilderContainer)));
type FormsValues = {
Expand All @@ -38,7 +40,7 @@ type RulesMessages = {
};

type Props = {
fieldsMetaData: Map<string, DataElement>,
fieldsMetaData: Map<string, DataElement | FormFieldPluginConfig>,
values: FormsValues,
rulesMessages: RulesMessages,
rulesHiddenFields: RulesHiddenFields,
Expand All @@ -64,17 +66,33 @@ export class D2SectionFieldsComponent extends Component<Props> {
return Array.from(fieldsMetaData.entries())
.map(entry => entry[1])
// $FlowFixMe[incompatible-return] automated comment
.map(metaDataElement => buildField(
metaDataElement,
{
formHorizontal: props.formHorizontal,
formId: props.formId,
viewMode: props.viewMode,
...fieldOptions,
},
!!customForm,
querySingleResource,
))
.map((metaDataElement) => {
if (metaDataElement instanceof FormFieldPluginConfig) {
return ({
id: metaDataElement.id,
component: FormFieldPlugin,
plugin: true,
props: {
pluginSource: metaDataElement.pluginSource,
fieldsMetadata: metaDataElement.fields,
formId: props.formId,
},
});
}

// $FlowFixMe - filter removes undefined values
return buildField(
metaDataElement,
{
formHorizontal: props.formHorizontal,
formId: props.formId,
viewMode: props.viewMode,
...fieldOptions,
},
!!customForm,
querySingleResource,
);
})
.filter(field => field);
}

Expand Down Expand Up @@ -239,7 +257,6 @@ export class D2SectionFieldsComponent extends Component<Props> {
values,
onUpdateField,
formId,
formBuilderId,
rulesCompulsoryFields,
rulesDisabledFields,
rulesHiddenFields,
Expand All @@ -256,8 +273,9 @@ export class D2SectionFieldsComponent extends Component<Props> {
// $FlowFixMe[cannot-spread-inexact] automated comment
<CustomFormHOC
formBuilderRef={(instance) => { this.formBuilderInstance = instance; }}
id={formBuilderId}
id={formId}
fields={this.getFieldConfigWithRulesEffects()}
dataElements={this.formFields}
values={values}
onUpdateField={this.handleUpdateField}
onUpdateFieldAsync={this.handleUpdateFieldAsync}
Expand Down
Loading
Loading