Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ilder into feat/validation-rule-builder
  • Loading branch information
senthil-athiban committed Aug 10, 2024
2 parents 800e66d + 190cf27 commit ff66b14
Show file tree
Hide file tree
Showing 14 changed files with 206 additions and 264 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The Form Builder is a widget used to create OpenMRS form schemas. It enables use

## Running this code

Under the hood, the Form Builder uses the [OHRI form engine](https://www.npmjs.com/package/@openmrs/openmrs-form-engine-lib) to render a visual representation of your schema. This visual preview gets progressively updated as you build your schema. When done building, you can save your schema to an OpenMRS server. You can also publish your schema to make it available to your frontend.
Under the hood, the Form Builder uses the [React form engine](https://www.npmjs.com/package/@openmrs/esm-form-engine-lib) to render a visual representation of your schema. This visual preview gets progressively updated as you build your schema. When done building, you can save your schema to an OpenMRS server. You can also publish your schema to make it available to your frontend.

To set up environment variables for the project, follow these steps:

Expand Down Expand Up @@ -95,7 +95,7 @@ Then, in a separate terminal, run:
yarn test-e2e --headed
```

Read the [e2e testing guide](/e2e/README.md) to learn more about End-to-End tests in this project.
Read the [E2E testing guide](https://o3-docs.openmrs.org/docs/frontend-modules/end-to-end-testing) to learn more about End-to-End tests in this project.

#### Troubleshooting

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"coverage": "yarn test --coverage --passWithNoTests",
"postinstall": "husky install",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' --config ./i18next-parser.config.js",
"ci:bump-form-engine-lib": "yarn up @openmrs/openmrs-form-engine-lib@next"
"ci:bump-form-engine-lib": "yarn up @openmrs/esm-form-engine-lib@next"
},
"files": [
"dist",
Expand All @@ -47,7 +47,7 @@
},
"dependencies": {
"@carbon/react": "^1.47.0",
"@openmrs/openmrs-form-engine-lib": "next",
"@openmrs/esm-form-engine-lib": "next",
"ajv": "^8.13.0",
"dotenv": "^16.4.5",
"file-loader": "^6.2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/form-editor/form-editor.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { useParams } from 'react-router-dom';
import { type TFunction, useTranslation } from 'react-i18next';
import { ConfigurableLink, showModal, useConfig } from '@openmrs/esm-framework';
import type { IMarker } from 'react-ace';
import type { FormSchema } from '@openmrs/openmrs-form-engine-lib';
import type { FormSchema } from '@openmrs/esm-form-engine-lib';
import type { Schema } from '../../types';
import { useClobdata } from '../../hooks/useClobdata';
import { useForm } from '../../hooks/useForm';
Expand Down
2 changes: 1 addition & 1 deletion src/components/form-renderer/form-renderer.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
import { ErrorBoundary } from 'react-error-boundary';
import { useTranslation } from 'react-i18next';
import { Button, InlineLoading, Tile } from '@carbon/react';
import { type FormSchema, FormEngine } from '@openmrs/openmrs-form-engine-lib';
import { type FormSchema, FormEngine } from '@openmrs/esm-form-engine-lib';
import styles from './form-renderer.scss';

interface ErrorFallbackProps {
Expand Down
2 changes: 1 addition & 1 deletion src/components/interactive-builder/add-question.modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
} from '@carbon/react';
import { ArrowUpRight } from '@carbon/react/icons';
import { showSnackbar, useConfig, useDebounce } from '@openmrs/esm-framework';
import type { ProgramState, RenderType } from '@openmrs/openmrs-form-engine-lib';
import type { ProgramState, RenderType } from '@openmrs/esm-form-engine-lib';

import type { ConfigObject } from '../../config-schema';
import type {
Expand Down
9 changes: 6 additions & 3 deletions src/components/interactive-builder/edit-question.modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
} from '@carbon/react';
import { ArrowUpRight } from '@carbon/react/icons';
import { showSnackbar, useConfig } from '@openmrs/esm-framework';
import type { ProgramState, RenderType } from '@openmrs/openmrs-form-engine-lib';
import type { ProgramState, RenderType } from '@openmrs/esm-form-engine-lib';

import type { ConfigObject } from '../../config-schema';
import type {
Expand Down Expand Up @@ -144,7 +144,10 @@ const EditQuestionModal: React.FC<EditQuestionModalProps> = ({
);
const [programWorkflows, setProgramWorkflows] = useState<Array<ProgramWorkflow>>([]);

const hasConceptChanged = selectedConcept && questionToEdit?.questionOptions?.concept !== selectedConcept?.uuid;
const hasConceptChanged =
selectedConcept &&
questionToEdit?.questionOptions.concept &&
questionToEdit?.questionOptions?.concept !== selectedConcept?.uuid;
const [addInlineDate, setAddInlineDate] = useState(false);

// Maps the data type of a concept to a date picker type.
Expand Down Expand Up @@ -276,8 +279,8 @@ const EditQuestionModal: React.FC<EditQuestionModalProps> = ({
rendering: fieldType ? fieldType : questionToEdit.questionOptions.rendering,
...((selectedConcept || questionToEdit.questionOptions.concept) && {
concept: selectedConcept ? selectedConcept.uuid : questionToEdit.questionOptions.concept,
conceptMappings: conceptMappings?.length ? conceptMappings : questionToEdit.questionOptions.conceptMappings,
}),
conceptMappings: conceptMappings?.length ? conceptMappings : questionToEdit.questionOptions.conceptMappings,
answers: mappedAnswers,
...(questionType === 'patientIdentifier' && {
identifierType: selectedPatientIdentifierType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Accordion, AccordionItem, Button, IconButton, InlineLoading } from '@ca
import { Add, TrashCan } from '@carbon/react/icons';
import { useParams } from 'react-router-dom';
import { showModal, showSnackbar, useFeatureFlag } from '@openmrs/esm-framework';
import type { FormSchema } from '@openmrs/openmrs-form-engine-lib';
import type { FormSchema } from '@openmrs/esm-form-engine-lib';
import type { Schema, Question } from '../../types';
import DraggableQuestion from './draggable-question.component';
import Droppable from './droppable-container.component';
Expand Down
2 changes: 1 addition & 1 deletion src/config-schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Type } from '@openmrs/esm-framework';
import { type RenderType } from '@openmrs/openmrs-form-engine-lib';
import { type RenderType } from '@openmrs/esm-form-engine-lib';
import { type QuestionType } from './types';

export const configSchema = {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useConceptName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ export function useConceptName(conceptId: string | undefined) {
return {
conceptName: data?.data?.name?.display ?? null,
conceptNameLookupError: error,
isLoadingConceptName: (!data && !error) || false,
isLoadingConceptName: (conceptId && !data && !error) || false,
};
}
2 changes: 1 addition & 1 deletion src/hooks/useProgramStates.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import useSWR from 'swr';
import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
import { type ProgramWorkflowState } from '@openmrs/openmrs-form-engine-lib';
import { type ProgramWorkflowState } from '@openmrs/esm-form-engine-lib';
import { type Program, type ProgramWorkflow } from '../types';

export function usePrograms() {
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { OpenmrsResource } from '@openmrs/esm-framework';
import type { ProgramState, ReferencedForm, RenderType, RequiredFieldProps } from '@openmrs/openmrs-form-engine-lib';
import type { ProgramState, ReferencedForm, RenderType, RequiredFieldProps } from '@openmrs/esm-form-engine-lib';
import type { AuditInfo } from './components/audit-details/audit-details.component';

export enum ActionType {
Expand Down
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
"es2015.promise",
"es2016.array.include",
"es2018",
"es2020"
"es2020",
"esnext"
],
"module": "esnext",
"moduleResolution": "node",
"noEmit": true,
"noImplicitAny": false,
"resolveJsonModule": true,
"skipLibCheck": true,
"target": "esnext"
"target": "es2015"
},
"types": ["@testing-library/jest-dom", "lodash"],
}
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ config.overrides.resolve = {
extensions: ['.tsx', '.ts', '.jsx', '.js', '.scss', '.json'],
alias: {
'@openmrs/esm-framework': '@openmrs/esm-framework/src/internal',
'@openmrs/openmrs-form-engine-lib': '@openmrs/openmrs-form-engine-lib/src/index',
'@openmrs/esm-form-engine-lib': '@openmrs/esm-form-engine-lib/src/index',
},
};
module.exports = config;
Loading

0 comments on commit ff66b14

Please sign in to comment.