From cdf97b1f9b5867ecfc8c8d4445c20839bed9ac0d Mon Sep 17 00:00:00 2001 From: anoop narang Date: Thu, 16 Jul 2020 22:51:05 +0530 Subject: [PATCH] [INFRA-421] | Anoop | Add foldable group renderer --- src/components/manifest/SchemaForm.tsx | 12 +++++--- src/renderer/FoldableGroup.tsx | 42 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 src/renderer/FoldableGroup.tsx diff --git a/src/components/manifest/SchemaForm.tsx b/src/components/manifest/SchemaForm.tsx index 70bd100..fe21183 100644 --- a/src/components/manifest/SchemaForm.tsx +++ b/src/components/manifest/SchemaForm.tsx @@ -11,6 +11,7 @@ import { JsonForms } from '@jsonforms/react' import { materialCells, materialRenderers } from '@jsonforms/material-renderers' import customAjv from '../../ajv/CustomAjv' import _ from 'lodash' +import { FoldableGroupTester, FoldableGroupRenderer } from '../../renderer/FoldableGroup' interface IProps { csrfToken?: any name: string @@ -22,9 +23,11 @@ interface IProps { manifestData?: any } -function isProperJsonSchema(schema: any) { - const schemaStr = JSON.stringify(schema) - return schemaStr.search("resource:/") === -1 +function isProperJsonSchema(completeSchema: any) { + let jsonSchema = completeSchema.jsonSchema + const schemaStr = JSON.stringify(jsonSchema) + let isProperSchema = schemaStr.search("resource:/") === -1 + return isProperSchema } export default function SchemaForm(props: IProps) { @@ -78,7 +81,7 @@ export default function SchemaForm(props: IProps) { { - (!props.updateCompleteSchemaHandler && isProperJsonSchema(completeSchema.jsonSchema)) ? + (!props.updateCompleteSchemaHandler && isProperJsonSchema(completeSchema)) ? { diff --git a/src/renderer/FoldableGroup.tsx b/src/renderer/FoldableGroup.tsx new file mode 100644 index 0000000..9d0d712 --- /dev/null +++ b/src/renderer/FoldableGroup.tsx @@ -0,0 +1,42 @@ +import { withJsonFormsLayoutProps } from '@jsonforms/react'; +import { rankWith, uiTypeIs } from "@jsonforms/core"; +import { MaterialLayoutRenderer, MaterialLayoutRendererProps } from "@jsonforms/material-renderers"; +import { + ExpansionPanel, + ExpansionPanelDetails, + ExpansionPanelSummary, + Hidden, + Typography +} from "@material-ui/core"; +import ExpandMoreIcon from "@material-ui/icons/ExpandMore"; +import React from "react"; + +const FoldableGroup = props => { + const { uischema, schema, path, visible, renderers} = props; + + const layoutProps : MaterialLayoutRendererProps = { + elements: uischema.elements, + schema: schema, + path: path, + direction: 'column', + visible: visible, + uischema: uischema, + renderers: renderers + }; + + return ( + + + }> + {uischema.label} + + + + + + + ); +}; + +export const FoldableGroupRenderer = withJsonFormsLayoutProps(FoldableGroup); +export const FoldableGroupTester = rankWith(100, uiTypeIs("FoldableGroup")); \ No newline at end of file