From 1cde439ac53eb1b6c02424688d6e0cae41427df9 Mon Sep 17 00:00:00 2001 From: Rodrigo Dias Date: Tue, 10 Sep 2024 11:04:52 -0300 Subject: [PATCH] feat: crudModule - form title customization --- .../submodules/DrawerForm/index.tsx | 19 ++++++++++++----- .../components/submodules/ModalForm/index.tsx | 21 ++++++++++++------- .../src/components/submodules/types/Form.ts | 1 - .../src/modules/crud/index.tsx | 1 - 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/packages/react-material-ui/src/components/submodules/DrawerForm/index.tsx b/packages/react-material-ui/src/components/submodules/DrawerForm/index.tsx index a7ee8abd..45b0f4c9 100644 --- a/packages/react-material-ui/src/components/submodules/DrawerForm/index.tsx +++ b/packages/react-material-ui/src/components/submodules/DrawerForm/index.tsx @@ -109,6 +109,19 @@ const DrawerFormSubmodule = (props: FormSubmoduleProps) => { ...widgets, }; + const title = () => { + if (formSchema?.title) { + return formSchema.title; + } + if (viewMode === 'creation') { + return 'Add Data'; + } + if (viewMode === 'edit') { + return 'Edit Data'; + } + return 'View Data'; + }; + return ( { ml={1} > - {viewMode === 'creation' - ? 'Add Data' - : viewMode === 'edit' - ? 'Edit Data' - : 'View Data'} + {title()} { ...widgets, }; + const title = () => { + if (formSchema?.title) { + return formSchema.title; + } + if (viewMode === 'creation') { + return 'Add Data'; + } + if (viewMode === 'edit') { + return 'Edit Data'; + } + return 'View Data'; + }; + return ( - - {viewMode === 'creation' - ? 'Add Data' - : viewMode === 'edit' - ? 'Edit Data' - : 'View Data'} - + {title()} & { isVisible: boolean; queryResource: string; - title?: string; formSchema?: RJSFSchema; viewMode?: Action | null; formUiSchema?: UiSchema; diff --git a/packages/react-material-ui/src/modules/crud/index.tsx b/packages/react-material-ui/src/modules/crud/index.tsx index ca586199..17e49d11 100644 --- a/packages/react-material-ui/src/modules/crud/index.tsx +++ b/packages/react-material-ui/src/modules/crud/index.tsx @@ -281,7 +281,6 @@ const CrudModule = (props: ModuleProps) => { {enhancedFormProps && (