2.0.2 • Published 3 years ago

ra-delete-with-custom-confirm-button v2.0.2

Weekly downloads
13
License
MIT
Repository
github
Last release
3 years ago

ra-delete-with-custom-confirm-button

npm version MIT License Build Status

Delete button with your custom confirm dialog for React-admin.

Demo

Installation

# via npm
npm install --save ra-delete-with-custom-confirm-button

# via yarn
yarn add ra-delete-with-custom-confirm-button

Demo

After having cloned this repository, run the following commands:

cd example/
yarn install
yarn start

And then browse to http://localhost:8080/.

The credentials are login/password

Usage

import DeleteWithCustomConfirmButton from 'ra-delete-with-custom-confirm-button';
import Delete from '@material-ui/icons/Delete';
import ErrorOutline from '@material-ui/icons/ErrorOutline';

// Define your custom title of confirm dialog
const DeleteConfirmTitle = 'Are you sure you want to delete this post?';

// Define your custom contents of confirm dialog
const DeleteConfirmContent = props => {
  return (
    <SimpleShowLayout {...props} >
      <TextField source='title' label='title' />
      <TextField source='user' label='user' />
      <TextField source='date' label='date' />
      <RichTextField source='description' label='description' />
    </SimpleShowLayout>
  );
};

const InformationList = props => {
  const translate = useTranslate();
  return (
    <List {...props} >
      <Datagrid>
        <TextField source='title' label='title' />
        <TextField source='date' label='date' />
        <TextField source='user' label='user' />
        <DeleteWithCustomConfirmButton
          title={DeleteConfirmTitle}      // your custom title of delete confirm dialog
          content={DeleteConfirmContent}  // your custom contents of delete confirm dialog
          label='Delete'                  // label of delete button (default: 'Delete')
          confirmColor='warning'          // color of delete button ('warning' or 'primary', default: 'warning')
          ConfirmIcon={Delete}            // icon of delete button (default: 'Delete')
          cancel='Cancel'                 // label of cancel button (default: 'Cancel')
          CancelIcon={ErrorOutline}       // icon of cancel button (default: 'ErrorOutline')
          undoable={true}                 // undoable (default: true)
        />
      </Datagrid>
    </List>
  );
};

export default InformationList;

props

NameTypeDescriptionDefault
titlestringyour custom title of delete confirm dialog
contentelementyour custom contents of delete confirm dialog
labelstringlabel of delete button'ra.action.delete' (Delete in English)
confirmColorstringcolor of delete button ('warning' or 'primary')'warning'
DeleteIconelementicon of delete button from @material-ui/iconsDelete
cancelstringlabel of cancel button'ra.action.cancel' (Cancel in English)
CancelIconelementicon of cancel button from @material-ui/iconsErrorOutline
undoableboolundoable or nottrue
redirectstringredirect to'list'

License

This library is licensed under the MIT License.

2.0.2

3 years ago

2.0.1-0

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

2.0.0-2

4 years ago

2.0.0-1

4 years ago

2.0.0-0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.0.5

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago