Skip to content

Commit 3fae0ef

Browse files
setUiSchema
1 parent 722aea3 commit 3fae0ef

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

packages/edit-form/features/form/Form.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { useCallback } from 'react';
2-
32
import { JsonForms } from '@jsonforms/react';
4-
import schema from '../table/example-jsonschema.json';
5-
63
import { useAppSelector, selectData, selectEditorState, useAppDispatch, setRowData } from 'state';
7-
import { selectJsonSchema } from 'project-state';
4+
import { selectJsonSchema, selectUiSchema } from 'project-state';
85

96
import {
107
materialRenderers,
@@ -14,6 +11,7 @@ import {
1411

1512
export function Form() {
1613
const schema = useAppSelector(selectJsonSchema);
14+
const uiSchema = useAppSelector(selectUiSchema);
1715
const tableData = useAppSelector(selectData);
1816
// @ts-ignore
1917
const { selectedRows } = useAppSelector(selectEditorState);
@@ -33,6 +31,7 @@ export function Form() {
3331
renderers={materialRenderers}
3432
cells={materialCells}
3533
schema={schema}
34+
uischema={uiSchema}
3635
data={rowData}
3736
onChange={onChange}
3837
/>

packages/project-state/features/slices/schemaSlice.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
22
import { RootState } from "../state/store";
3-
import { JsonSchema } from '@jsonforms/core'
3+
import { JsonSchema, UISchemaElement } from '@jsonforms/core'
44

55
export interface SchemaState {
66
jsonSchema?: JsonSchema
7-
uiSchema?: any
7+
uiSchema?: UISchemaElement
88
}
99

1010
const initialState: SchemaState = {
@@ -18,6 +18,12 @@ export const schemaSlice = createSlice({
1818
reducers: {
1919
setJsonSchema: (state: SchemaState, action: PayloadAction<JsonSchema>) => {
2020
state.jsonSchema = action.payload;
21+
},
22+
setUiSchema: (state: SchemaState, action: PayloadAction<UISchemaElement>) => {
23+
state.uiSchema = action.payload;
24+
},
25+
setSchemaState: (state: SchemaState, action: PayloadAction<SchemaState>) => {
26+
state = {...state, ...action.payload};
2127
}
2228
}
2329
});

0 commit comments

Comments
 (0)