Add CRUD component #4146
Labels
linked in docs
The issue is linked in the docs, so completely skew the upvotes
new feature
New feature or request
scope: toolpad-core
Abbreviated to "core"
waiting for 👍
Waiting for upvotes
Milestone
High level proposal
Some Possible Additional Use Cases (not supported in first implementation)
Possible implementation
Separate
List
/Show
/Create
andEdit
components to generate a page from same data source.The
CRUD
component sets predefined routes for each of those 4 components, and automatically integrates with any Javascript web framework being used by the project.or for deeper customization, separate components can be placed in their own pages under a common CRUD provider with the data source:
Data Source
Our concept of a data source has a
fields
property with the exact same shape as the MUI X DataGrid columns definition, but an additionallongString
type for multiline form fields. For example:Besides
fields
, there are methods to interact with data in the data source object, as well as the option to provide a function for form validation. Here's the type definition for the initial data source:It should be easy to replace it with the MUI X data sources once they are complete and available, as they use a similar API.
List component
Generates a page with a
DataGrid
showing the fetched items and column types derived from thefields
definition.By default, the rightmost cell includes "Edit" (typically redirects to the "edit" page) and "Delete" (with a confirmation dialog) options.
If someone wants to customize the behavior of the underlying data grid (e.g.: use the Pro data grid and its features), they can use the
dataGrid
slot and slot props:Possible inline/quick edit implementation:
(uses the default inline editing features of the
DataGrid
and shows an inline edit button along with the options menu)Including a
createOne
method in the data source renders a "Create New"/"Add new" button in the List view above the table.Show component
This component corresponds to the details of an individual list item, usually accessible when you click on an individual row in from the
List
.Create & Edit components
These are separate components with similar functionality but slightly different default content (submit button text, for example).
(Auto-renders a form with the fields based on the
fields
definition)The forms are controlled forms using react state, and using no particular form library under the hood.
Through the
validate
function in the data source, these forms can be integrated with any library, such asyup
orzod
.We could eventually provide adapters for the most popular schema libraries - for now, they should be present in examples and easy to copy.
Benchmark:
Refine
https://refine.dev/docs/#use-cases
Shows a full featured CRUD component with separate views for edit, create, show and a dashboard layout with sign
in/sign out.
https://refine.dev/docs/guides-concepts/forms/#edit
Exposes a
useForm
hook which is a wrapper overreact-hook-form
and integrates with Refine'sdataProvider
Exposes
props
such assaveButtonProps
and the individual field props when you useuseForm
with aresource
parameter, you define all the form fields individually yourselfReact-Admin
https://marmelab.com/react-admin/Edit.html -> You specify form UIs yourself with their custom components, such as
TextField
fromreact-admin
etc.Out of the box UI for CRUD forms does not use visual space efficiently - easy area to improve on
Has a paid
EditInDialog
/CreateInDialog
component that allows quick editsTremor
Edit
componentEdit
component to be as customisable as possible, then it leaves space for blocks to be built on top as wellMinimals CRUD (Visual benchmark)
The text was updated successfully, but these errors were encountered: