Skip to content

Commit

Permalink
Merge pull request #218 from Dias999/feature/Crud_mod_and_Navigation_…
Browse files Browse the repository at this point in the history
…enhancements

Feature/crud mod and navigation enhancements
  • Loading branch information
andreneto97 authored Sep 10, 2024
2 parents 9985bf7 + 1cde439 commit a294d8f
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ChevronRight from '@mui/icons-material/ChevronRight';
import { DrawerItem, DrawerItemProps } from './DrawerItem';
import { Image } from '../Image';
import Box from '@mui/material/Box';
import { TextProps } from 'interfaces';
import { TextProps } from '../../interfaces';
import { SxProps, Theme } from '@mui/material/styles';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { Box } from '@mui/material';
import { DrawerButton, DrawerButtonProps } from './Styles';
import Text from '../Text';
import { TextProps } from 'interfaces';
import { TextProps } from '../../interfaces';

export const DEFAULT_DRAWER_TEXT_PROPS = {
fontSize: 12,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const renderComponent = (filter: FilterType) => {
label={filter.label}
isLoading={filter.isLoading}
options={filter.options}
defaultValue={filter.defaultValue || ''}
defaultValue={filter.defaultValue ?? allOption.value}
onChange={filter.onChange}
value={filter.value}
variant="outlined"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Drawer open={isVisible} anchor="right">
<Box
Expand All @@ -120,11 +133,7 @@ const DrawerFormSubmodule = (props: FormSubmoduleProps) => {
ml={1}
>
<Typography variant="h5" sx={{ marginLeft: 3, fontSize: '20px' }}>
{viewMode === 'creation'
? 'Add Data'
: viewMode === 'edit'
? 'Edit Data'
: 'View Data'}
{title()}
</Typography>
<IconButton
aria-label="close"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,22 @@ const ModalFormSubmodule = (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 (
<Dialog open={isVisible} maxWidth="md" fullWidth onClose={onClose}>
<DialogTitle>
{viewMode === 'creation'
? 'Add Data'
: viewMode === 'edit'
? 'Edit Data'
: 'View Data'}
</DialogTitle>
<DialogTitle>{title()}</DialogTitle>
<IconButton
aria-label="close"
onClick={onClose}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export type FormSubmoduleProps = PropsWithChildren<
> & {
isVisible: boolean;
queryResource: string;
title?: string;
formSchema?: RJSFSchema;
viewMode?: Action | null;
formUiSchema?: UiSchema;
Expand Down
1 change: 0 additions & 1 deletion packages/react-material-ui/src/modules/crud/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ const CrudModule = (props: ModuleProps) => {
{enhancedFormProps && (
<FormComponent
isVisible={isFormVisible}
title={titleName}
queryResource={props.resource}
viewMode={drawerViewMode}
formData={selectedRow}
Expand Down
3 changes: 2 additions & 1 deletion packages/react-navigation/src/components/Resource.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { ReactNode } from 'react';
import { Route } from 'react-router-dom';
import { ModuleProps } from '@concepta/react-material-ui/dist/modules/crud';
import { DrawerItemProps } from '@concepta/react-material-ui';

type ResourceProps = {
id: string;
name: string;
icon: ReactNode;
icon: DrawerItemProps['icon'];
showDrawerItem?: boolean;
isUnprotected?: boolean;
showAppBar?: boolean;
Expand Down

0 comments on commit a294d8f

Please sign in to comment.