Disable undo function in react-admin for List view - react-admin

It is possible to set the property undoable={false} for the Edit and Create component. This successfully disables the undo feature.
It seems as if this property is not applicable to the List view. Is that correct?
Use Case:
The user is in the List view. She selects an item and chooses to delete it. The delete shall not be undoable.

For List, the undoable property must be specified in DeleteButton:
<List {...props} >
<Datagrid>
...
<DeleteButton undoable={true} />
</Datagrid>

Related

How can I add a Datagrid reflecting currect state of ReferenceArrayInput to a react-admin edit form?

I'm writing a user management using react-admin and try to make adding users to groups easier, i.e. by adding groups from a user's edit page using auto-complete. Starting with an example, I've got some success using the following:
<ReferenceArrayInput
label="Group"
source="groups"
reference="groups"
>
<AutocompleteArrayInput
{...props}
resettable={true}
allowEmpty={true}
optionText="name"
fullWidth
/>
</ReferenceArrayInput>
However, this method uses Chip component to display selected items inline. I would like to use a Datagrid instead. I know from the source code that I cannot override the display part of an auto-complete (yet?), so I thought I could resort to hiding Chips via CSS, but I would still need a way to display a Datagrid with current selection. So I tried this (it's wrapped in FormWithRedirect, hence formProps):
<ReferenceArrayField
{...formProps}
label="Group"
source="groups"
reference="groups"
>
<Datagrid>
<TextField source="name" />
</Datagrid>
</ReferenceArrayField>
<ReferenceArrayInput
{...formProps}
label="Group"
source="groups"
reference="groups"
>
<AutocompleteArrayInput
resettable={true}
allowEmpty={true}
optionText="name"
fullWidth
/>
</ReferenceArrayInput>
This works almost exactly as I want it, a Datagrid is displayed and it shows the right data for the selection, however, it's not updated when selected items on AutocompleteArrayInput change. How ever I tried (been through probably all the hooks and contexts), I could not make it work.
Is this possible? How can I make Datagrid update when selection changes on AutocompleteArrayInput?

React-Select dropdown is not persisting value after reordering(sorting) them by react-sortable-hoc

I am trying to create a list of dropdowns which can be reordered by dragging them. For drag and drop i am using react-sortable-hoc. Here i am attaching a working sample. Link for sample
To reproduce the issue, Select value in first dropdown by mouse or keyboard. after that drag that element (first dropdown) and drop it at 3rd or 4th position then you observed that dropped dropdown will not persist the value. Selected value displayed at first element. What could be the cause for this? How can i fix it?
You need to pass onSortEnd handler to your srotableContainer as props
<List items={this.state.items} onSortEnd={this.onSortEnd}/>;
I also suggest you add a key on your Item
<Item key={item} data={item} index={index} />
Here is the forked sandbox where it is working:
https://codesandbox.io/s/adoring-raman-l72xw?fontsize=14

How to disable delete action in List view in react admin?

Before version 2 you could just not pass remove prop to <Resource/> component. However now delete action is included by default in <List/> view and I can't find anywhere in docs how I can disable it.
Putting false to bulkActionButtons of List disables bulk actions.
<List bulkActionButtons={false}>
..
</List>
transGLUKator mentioned about bulkActionButtons but it took time for me to find value to disable bulk actions.
Reference
Source code of List of react-admin: https://github.com/marmelab/react-admin/blob/93bc43fcec652e6c2eaaa2dc7bdf45b2f64e12fb/packages/ra-ui-materialui/src/list/List.js#L128
<Datagrid/> component has bulkActionButtons prop, where you can customize how bulk actions work. Here is the link to docs
If you are using the version 3 or lower you can provide the bulkActionButtons to the <List /> component.
https://github.com/marmelab/react-admin/blob/00ffc81e27d19b5242c93c28eb8b6668928439a0/docs/Upgrade.md#list-bulkactionbuttons-prop-moved-to-datagrid
The <List> bulkActionButtons prop is now deprecated—instead you use it directly on <DataGrid>, e.g.
<List>
<Datagrid bulkActionButtons={false}>
…
</Datagrid>
</List>
See the DataGrid bulkActionButtons docs

Material-UI password input required

Using MUI #Next and the TextField component.
MUI very nicely adds a little * at the end of the label when you add required as a prop, however it seems to not work out of the box when you add the endAdornment in order to enable a "show password" toggle.
I have created a codesandbox of my issue.
The regular <Texfield /> component shows the * as expected, but the also required password field doesn't.
While making the codesandbox reproduction of my issue, I found the answer, but thought I'd leave it here for others who come across this.
The required prop has to go on the <FormControl /> wrapper of the input:
<FormControl required ... >
<InputLabel ... >Password</InputLabel>
<Input ... />
</FormControl>

Listview webpart in site definition makes it all fail

I have made a listdefinition which I've put in to a web scoped feature which I've added to WebFeatures in my sitedefinition. In my sitedefinition I've added a list view web part which shall display the list created through the listdefinition. My issue is that when I add the list's name to the List property in the list view web part like so:
<View List="OrderList" BaseViewID="1" WebPartZoneID="Footer" WebPartOrder="2">
</View>
the process of creating the new sub site fails because of this alone. I have 2 other lists which is added to the sitedefinition in the exact same way
<View List="Documents" BaseViewID="1" Type="HTML" WebPartZoneID="Footer" WebPartOrder="1">
</View>
<View List="108" BaseViewID="3" WebPartZoneID="Footer" ContentTypeID="0x012001" WebPartOrder="4">
</View>
The only difference is that those 2 lists are standard sharepoint Documents library and Discussion board. If I remove the custom list's list view web part the entire flow works correctly, but as soon as I add it the entire thing fails.
I've created the listdefinition through VS2010 own listdefinition template etc and I haven't touched a thing. Only changed the name in the List Instance and made sure everything matched in the Elements.xml and Schema.xml files
What is the Url attribute of your ListInstance?
Because the List attribute of the View element must match the Url from the ListInstance. For example, if your ListInstance is defined as:
<ListInstance
FeatureId="00000000-0000-0000-0000-000000000000"
TemplateType="0000"
Title="My Test List"
Url="Lists/OrderList">
</ListInstance>
then your View must be:
<View List="Lists/OrderList" BaseViewID="1" WebPartZoneID="Footer" WebPartOrder="2">
</View>