Skip to content

Commit

Permalink
Use full schema for list filter
Browse files Browse the repository at this point in the history
  • Loading branch information
andersw-lolo committed Aug 10, 2023
1 parent 3bce37a commit 4e81fbe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lolocompany/react-admin-lolo",
"version": "2.1.9",
"version": "2.1.10",
"description": "A library for schema-driven web apps using [Lolo](https://lolo.company), [React Admin](https://github.com/marmelab/react-admin) and [RJSF](https://github.com/rjsf-team/react-jsonschema-form)",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down
13 changes: 8 additions & 5 deletions src/views/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,28 @@ const BulkActionButtons = props => (
);

const List = props => {
const { listSchema: schema } = useContext(ResourceContext);
const { listSchema, schema } = useContext(ResourceContext);

if (!Object.keys(schema).length) return null;
if (!Object.keys(listSchema).length) return null;

const filterSchema = JSON.parse(JSON.stringify(schema));
delete filterSchema.properties.accountId;

return (
<ra.List
{...props}
bulkActionButtons={props.hasEdit ? <BulkActionButtons /> : false}
filters={<Filter schema={schema} />}
filters={<Filter schema={filterSchema} />}
actions={<ListActions />}
empty={<ListEmpty />}
sort={{ field: 'createdAt', order: 'ASC' }}
title={schema.title ? pluralize(schema.title) : undefined}
title={listSchema.title ? pluralize(listSchema.title) : undefined}
>
<ra.Datagrid
rowClick={props.hasShow ? 'show' : props.hasEdit ? 'edit' : null}
expand={props.expand || <ExpandPanel />}
>
{Object.entries(schema.properties).map(toField)}
{Object.entries(listSchema.properties).map(toField)}
</ra.Datagrid>
</ra.List>
);
Expand Down

0 comments on commit 4e81fbe

Please sign in to comment.