Skip to content

Commit

Permalink
Merge branch 'main' into datatype-update
Browse files Browse the repository at this point in the history
  • Loading branch information
arodidev authored Aug 14, 2024
2 parents 25661f5 + 01bf937 commit 6474cb1
Show file tree
Hide file tree
Showing 15 changed files with 255 additions and 1,409 deletions.
2 changes: 1 addition & 1 deletion 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
10 changes: 7 additions & 3 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 Expand Up @@ -116,5 +116,9 @@
"*.{ts,tsx}": "eslint --cache --fix --max-warnings 0",
"*.{css,scss,ts,tsx}": "prettier --write --list-different"
},
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"resolutions": {
"@openmrs/openmrs-form-engine-lib": "portal:/Users/denniskigen/Code/openmrs/openmrs-form-engine-lib",
"@carbon/react": ">1.47.0 <1.50.0"
}
}
2 changes: 1 addition & 1 deletion src/components/dashboard/dashboard.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function ActionButtons({ form, mutate, responsiveSize, t }: ActionButtonsProps)
<IconButton
align="center"
enterDelayMs={defaultEnterDelayInMs}
iconDescription={t('import', 'Import')}
label={t('import', 'Import')}
kind="ghost"
onClick={() => navigate({ to: `${window.spaBase}/form-builder/edit/${form.uuid}` })}
size={responsiveSize}
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 } 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 Expand Up @@ -380,8 +380,8 @@ const InteractiveBuilder: React.FC<InteractiveBuilderProps> = ({
</div>
<IconButton
enterDelayMs={300}
label={t('deletePage', 'Delete page')}
kind="ghost"
label={t('deletePage', 'Delete page')}
onClick={() => launchDeletePageModal(pageIndex)}
size="md"
>
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 interface Form {
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 6474cb1

Please sign in to comment.