Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Datagrid has no padding when disabling bulk actions #3840

Merged
merged 1 commit into from
Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions examples/demo/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,6 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date(); a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');

ga('create', 'UA-46201426-1', 'auto');
ga('send', 'pageview');
</script>
</body>

</html>
8 changes: 6 additions & 2 deletions examples/demo/src/orders/OrderList.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ class TabbedDatagrid extends React.Component {
) : (
<div>
{filterValues.status === 'ordered' && (
<Datagrid {...props} ids={this.state.ordered}>
<Datagrid
{...props}
ids={this.state.ordered}
optimized
rowClick="edit"
>
<DateField source="date" showTime />
<TextField source="reference" />
<CustomerReferenceField />
Expand All @@ -111,7 +116,6 @@ class TabbedDatagrid extends React.Component {
}}
className={classes.total}
/>
<EditButton />
</Datagrid>
)}
{filterValues.status === 'delivered' && (
Expand Down
1 change: 1 addition & 0 deletions examples/demo/src/reviews/ReviewListDesktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const ReviewListDesktop = props => {
rowClick="edit"
rowStyle={rowStyle}
classes={{ headerRow: classes.headerRow }}
optimized
{...props}
>
<DateField source="date" />
Expand Down
7 changes: 6 additions & 1 deletion examples/demo/src/visitors/SegmentsField.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import { useTranslate } from 'react-admin';
import segments from '../segments/data';

const styles = {
main: { display: 'flex', flexWrap: 'wrap' },
main: {
display: 'flex',
flexWrap: 'wrap',
marginTop: -8,
marginBottom: -8,
},
chip: { margin: 4 },
};

Expand Down
3 changes: 1 addition & 2 deletions examples/demo/src/visitors/VisitorList.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const VisitorList = props => {
{isXsmall ? (
<MobileGrid />
) : (
<Datagrid>
<Datagrid optimized rowClick="edit">
<CustomerLinkField />
<DateField source="last_seen" type="date" />
<NumberField
Expand All @@ -61,7 +61,6 @@ const VisitorList = props => {
<DateField source="latest_purchase" showTime />
<BooleanField source="has_newsletter" label="News." />
<SegmentsField />
<EditButton />
</Datagrid>
)}
</List>
Expand Down
4 changes: 3 additions & 1 deletion examples/simple/src/posts/PostList.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ const usePostListActionToolbarStyles = makeStyles({
toolbar: {
alignItems: 'center',
display: 'flex',
marginTop: -1,
marginBottom: -1,
},
});

Expand Down Expand Up @@ -134,7 +136,7 @@ const PostList = props => {
}
/>
) : (
<Datagrid rowClick={rowClick} expand={PostPanel}>
<Datagrid rowClick={rowClick} expand={PostPanel} optimized>
<TextField source="id" />
<TextField source="title" cellClassName={classes.title} />
<DateField
Expand Down
1 change: 1 addition & 0 deletions examples/simple/src/users/UserList.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const UserList = ({ permissions, ...props }) => (
<Datagrid
rowClick={rowClick(permissions)}
expand={<UserEditEmbedded />}
optimized
>
<TextField source="id" />
<TextField source="name" />
Expand Down
26 changes: 7 additions & 19 deletions packages/ra-ui-materialui/src/list/Datagrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,17 @@ const useStyles = makeStyles(theme => ({
tableLayout: 'auto',
},
thead: {},
tbody: {
height: 'inherit',
},
tbody: {},
headerRow: {},
headerCell: {
height: 42,
minHeight: 42,
padding: '0 12px',
'&:last-child': {
padding: '0 12px',
},
},
headerCell: {},
checkbox: {},
row: {},
clickableRow: {
cursor: 'pointer',
},
rowEven: {},
rowOdd: {},
rowCell: {
padding: '0 12px',
'&:last-child': {
padding: '0 12px',
},
},
rowCell: {},
expandHeader: {
padding: 0,
width: theme.spacing(6),
Expand Down Expand Up @@ -122,6 +108,7 @@ function Datagrid({ classes: classesOverride, ...props }) {
rowStyle,
selectedIds,
setSort,
size = 'small',
total,
version,
...rest
Expand Down Expand Up @@ -161,6 +148,7 @@ function Datagrid({ classes: classesOverride, ...props }) {
expand={expand}
hasBulkActions={hasBulkActions}
nbChildren={React.Children.count(children)}
size={size}
/>
);
}
Expand All @@ -182,6 +170,7 @@ function Datagrid({ classes: classesOverride, ...props }) {
return (
<Table
className={classnames(classes.table, className)}
size={size}
{...sanitizeListRestProps(rest)}
>
<TableHead className={classes.thead}>
Expand All @@ -195,7 +184,7 @@ function Datagrid({ classes: classesOverride, ...props }) {
/>
)}
{hasBulkActions && (
<TableCell padding="none">
<TableCell padding="checkbox">
<Checkbox
className="select-all"
color="primary"
Expand All @@ -221,7 +210,6 @@ function Datagrid({ classes: classesOverride, ...props }) {
key={field.props.source || index}
resource={resource}
updateSort={updateSort}
padding="none"
/>
) : null
)}
Expand Down
18 changes: 5 additions & 13 deletions packages/ra-ui-materialui/src/list/DatagridLoading.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ const DatagridLoading = ({
hasBulkActions,
nbChildren,
nbFakeLines = 5,
size,
}) => (
<Table className={classnames(classes.table, className)}>
<Table className={classnames(classes.table, className)} size={size}>
<TableHead>
<TableRow className={classes.row}>
{expand && (
Expand All @@ -44,7 +45,7 @@ const DatagridLoading = ({
)}
{hasBulkActions && (
<TableCell
padding="none"
padding="checkbox"
className={classes.expandIconCell}
>
<Checkbox
Expand All @@ -59,9 +60,6 @@ const DatagridLoading = ({
variant="head"
className={classes.headerCell}
key={key}
padding={
!!expand || hasBulkActions ? 'none' : undefined
}
>
<Placeholder />
</TableCell>
Expand All @@ -87,7 +85,7 @@ const DatagridLoading = ({
)}
{hasBulkActions && (
<TableCell
padding="none"
padding="checkbox"
className={classes.expandIconCell}
>
<Checkbox
Expand All @@ -98,13 +96,7 @@ const DatagridLoading = ({
</TableCell>
)}
{times(nbChildren, key2 => (
<TableCell
padding={
!!expand || hasBulkActions ? 'none' : undefined
}
className={classes.rowCell}
key={key2}
>
<TableCell className={classes.rowCell} key={key2}>
<Placeholder />
</TableCell>
))}
Expand Down
5 changes: 1 addition & 4 deletions packages/ra-ui-materialui/src/list/DatagridRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const DatagridRow = ({
</TableCell>
)}
{hasBulkActions && (
<TableCell padding="none">
<TableCell padding="checkbox">
<Checkbox
color="primary"
className={`select-item ${classes.checkbox}`}
Expand All @@ -152,9 +152,6 @@ const DatagridRow = ({
classes.rowCell
)}
record={record}
padding={
!!expand || hasBulkActions ? 'none' : undefined
}
{...{ field, basePath, resource }}
/>
) : null
Expand Down
11 changes: 8 additions & 3 deletions packages/ra-ui-materialui/src/list/SingleFieldList.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ import { linkToRecord } from 'ra-core';

import Link from '../Link';

const useStyles = makeStyles({
root: { display: 'flex', flexWrap: 'wrap' },
});
const useStyles = makeStyles(theme => ({
root: {
display: 'flex',
flexWrap: 'wrap',
marginTop: -theme.spacing(1),
marginBottom: -theme.spacing(1),
},
}));

// useful to prevent click bubbling in a datagrid with rowClick
const stopPropagation = e => e.stopPropagation();
Expand Down
Loading