Compare commits

...

1 Commits

Author SHA1 Message Date
Michael Albert
a2807fe281 Allow importing csv files
Change-Id: I8f4c417c1762ba6dbc0fa929ecf8262e6e8a2e42
2020-04-15 11:38:11 +02:00
2 changed files with 32 additions and 1 deletions

View File

@ -25,7 +25,8 @@
"react": "^16.13.1", "react": "^16.13.1",
"react-admin": "^3.4.0", "react-admin": "^3.4.0",
"react-dom": "^16.13.1", "react-dom": "^16.13.1",
"react-scripts": "^3.4.1" "react-scripts": "^3.4.1",
"react-admin-import-csv": "^0.2.5"
}, },
"scripts": { "scripts": {
"start": "react-scripts start", "start": "react-scripts start",

View File

@ -21,10 +21,14 @@ import {
TextField, TextField,
TextInput, TextInput,
ReferenceField, ReferenceField,
Toolbar,
TopToolbar,
SelectInput, SelectInput,
regex, regex,
Pagination, Pagination,
} from "react-admin"; } from "react-admin";
import { ImportButton } from "react-admin-import-csv";
import { CreateButton, ExportButton } from "ra-ui-materialui";
const UserPagination = props => ( const UserPagination = props => (
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} /> <Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
@ -41,6 +45,31 @@ const UserFilter = props => (
</Filter> </Filter>
); );
const ListActions = props => {
const {
className,
basePath,
total,
resource,
currentSort,
filterValues,
exporter
} = props;
return (
<TopToolbar className={className}>
<CreateButton basePath={basePath} />
<ImportButton {...props} />
<ExportButton
disabled={total === 0}
resource={resource}
sort={currentSort}
filter={filterValues}
exporter={exporter}
/>
</TopToolbar>
);
};
export const UserList = props => ( export const UserList = props => (
<List <List
{...props} {...props}
@ -48,6 +77,7 @@ export const UserList = props => (
filterDefaultValues={{ guests: true, deactivated: false }} filterDefaultValues={{ guests: true, deactivated: false }}
bulkActionButtons={false} bulkActionButtons={false}
pagination={<UserPagination />} pagination={<UserPagination />}
actions={<ListActions />}
> >
<Datagrid rowClick="edit"> <Datagrid rowClick="edit">
<ReferenceField <ReferenceField