Fix exploding table layout
This commit is contained in:
parent
4cecf238d6
commit
e13086fef3
19 changed files with 210 additions and 97 deletions
|
@ -51,7 +51,7 @@ interface CollectionListProps
|
||||||
collections: CollectionList_collections_edges_node[];
|
collections: CollectionList_collections_edges_node[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const numberOfColumns = 5;
|
const numberOfColumns = 4;
|
||||||
|
|
||||||
const CollectionList: React.FC<CollectionListProps> = props => {
|
const CollectionList: React.FC<CollectionListProps> = props => {
|
||||||
const {
|
const {
|
||||||
|
|
|
@ -32,11 +32,16 @@ export interface FormData {
|
||||||
const useStyles = makeStyles(
|
const useStyles = makeStyles(
|
||||||
{
|
{
|
||||||
avatar: {
|
avatar: {
|
||||||
"&:first-child": {
|
"&&:first-child": {
|
||||||
paddingLeft: 0
|
paddingLeft: 0
|
||||||
}
|
},
|
||||||
|
width: 72
|
||||||
},
|
},
|
||||||
checkboxCell: {
|
checkboxCell: {
|
||||||
|
paddingLeft: 0,
|
||||||
|
width: 88
|
||||||
|
},
|
||||||
|
colName: {
|
||||||
paddingLeft: 0
|
paddingLeft: 0
|
||||||
},
|
},
|
||||||
overflow: {
|
overflow: {
|
||||||
|
@ -44,10 +49,6 @@ const useStyles = makeStyles(
|
||||||
},
|
},
|
||||||
scrollArea: {
|
scrollArea: {
|
||||||
overflowY: "scroll"
|
overflowY: "scroll"
|
||||||
},
|
|
||||||
wideCell: {
|
|
||||||
paddingLeft: 0,
|
|
||||||
width: "100%"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ name: "AssignProductDialog" }
|
{ name: "AssignProductDialog" }
|
||||||
|
@ -148,7 +149,7 @@ const AssignProductDialog: React.FC<AssignProductDialogProps> = props => {
|
||||||
className={classes.avatar}
|
className={classes.avatar}
|
||||||
thumbnail={maybe(() => product.thumbnail.url)}
|
thumbnail={maybe(() => product.thumbnail.url)}
|
||||||
/>
|
/>
|
||||||
<TableCell className={classes.wideCell}>
|
<TableCell className={classes.colName}>
|
||||||
{product.name}
|
{product.name}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell
|
<TableCell
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import Avatar from "@material-ui/core/Avatar";
|
import Avatar from "@material-ui/core/Avatar";
|
||||||
import { makeStyles } from "@material-ui/core/styles";
|
import { makeStyles } from "@material-ui/core/styles";
|
||||||
import TableCell from "@material-ui/core/TableCell";
|
import TableCell, { TableCellProps } from "@material-ui/core/TableCell";
|
||||||
import Cached from "@material-ui/icons/Cached";
|
import Cached from "@material-ui/icons/Cached";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
@ -11,6 +11,9 @@ export const AVATAR_MARGIN = 32;
|
||||||
|
|
||||||
const useStyles = makeStyles(
|
const useStyles = makeStyles(
|
||||||
theme => ({
|
theme => ({
|
||||||
|
alignRight: {
|
||||||
|
justifyContent: "flex-end"
|
||||||
|
},
|
||||||
avatar: {
|
avatar: {
|
||||||
background: "none",
|
background: "none",
|
||||||
border: `1px solid ${theme.palette.divider}`,
|
border: `1px solid ${theme.palette.divider}`,
|
||||||
|
@ -39,21 +42,33 @@ const useStyles = makeStyles(
|
||||||
{ name: "TableCellAvatar" }
|
{ name: "TableCellAvatar" }
|
||||||
);
|
);
|
||||||
|
|
||||||
interface TableCellAvatarProps {
|
interface TableCellAvatarProps extends TableCellProps {
|
||||||
className?: string;
|
className?: string;
|
||||||
thumbnail?: string;
|
thumbnail?: string;
|
||||||
|
alignRight?: boolean;
|
||||||
avatarProps?: string;
|
avatarProps?: string;
|
||||||
children?: React.ReactNode | React.ReactNodeArray;
|
children?: React.ReactNode | React.ReactNodeArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TableCellAvatar: React.FC<TableCellAvatarProps> = props => {
|
const TableCellAvatar: React.FC<TableCellAvatarProps> = props => {
|
||||||
const { children, className, thumbnail, avatarProps, ...rest } = props;
|
const {
|
||||||
|
children,
|
||||||
|
className,
|
||||||
|
alignRight,
|
||||||
|
thumbnail,
|
||||||
|
avatarProps,
|
||||||
|
...rest
|
||||||
|
} = props;
|
||||||
|
|
||||||
const classes = useStyles(props);
|
const classes = useStyles(props);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableCell className={classNames(classes.root, className)} {...rest}>
|
<TableCell className={classNames(classes.root, className)} {...rest}>
|
||||||
<div className={classes.content}>
|
<div
|
||||||
|
className={classNames(classes.content, {
|
||||||
|
[classes.alignRight]: alignRight
|
||||||
|
})}
|
||||||
|
>
|
||||||
{thumbnail === undefined ? (
|
{thumbnail === undefined ? (
|
||||||
<Avatar className={classNames(classes.avatar, avatarProps)}>
|
<Avatar className={classNames(classes.avatar, avatarProps)}>
|
||||||
<Cached color="primary" />
|
<Cached color="primary" />
|
||||||
|
@ -68,7 +83,7 @@ const TableCellAvatar: React.FC<TableCellAvatarProps> = props => {
|
||||||
src={thumbnail}
|
src={thumbnail}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<div className={classes.children}>{children}</div>
|
{!alignRight && <div className={classes.children}>{children}</div>}
|
||||||
</div>
|
</div>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
);
|
);
|
||||||
|
|
|
@ -63,6 +63,14 @@ const useStyles = makeStyles(
|
||||||
{ name: "TableHead" }
|
{ name: "TableHead" }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function getColSpan(colSpan: number, dragRows: boolean): number {
|
||||||
|
if (dragRows) {
|
||||||
|
return colSpan - 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return colSpan - 1;
|
||||||
|
}
|
||||||
|
|
||||||
const TableHead: React.FC<TableHeadProps> = props => {
|
const TableHead: React.FC<TableHeadProps> = props => {
|
||||||
const {
|
const {
|
||||||
children,
|
children,
|
||||||
|
@ -107,7 +115,7 @@ const TableHead: React.FC<TableHeadProps> = props => {
|
||||||
<>
|
<>
|
||||||
<TableCell
|
<TableCell
|
||||||
className={classNames(classes.root)}
|
className={classNames(classes.root)}
|
||||||
colSpan={colSpan - 1}
|
colSpan={getColSpan(colSpan, dragRows)}
|
||||||
>
|
>
|
||||||
<div className={classes.container}>
|
<div className={classes.container}>
|
||||||
{selected && (
|
{selected && (
|
||||||
|
|
|
@ -28,23 +28,24 @@ export interface DiscountCategoriesProps extends ListProps, ListActions {
|
||||||
}
|
}
|
||||||
|
|
||||||
const useStyles = makeStyles(
|
const useStyles = makeStyles(
|
||||||
theme => ({
|
{
|
||||||
iconCell: {
|
colActions: {
|
||||||
"&:last-child": {
|
"&:last-child": {
|
||||||
paddingRight: 0
|
paddingRight: 0
|
||||||
},
|
},
|
||||||
width: 48 + theme.spacing(0.5)
|
width: 80
|
||||||
|
},
|
||||||
|
colName: {
|
||||||
|
width: "auto"
|
||||||
|
},
|
||||||
|
colProducts: {
|
||||||
|
textAlign: "right",
|
||||||
|
width: 140
|
||||||
},
|
},
|
||||||
tableRow: {
|
tableRow: {
|
||||||
cursor: "pointer"
|
cursor: "pointer"
|
||||||
},
|
|
||||||
textRight: {
|
|
||||||
textAlign: "right"
|
|
||||||
},
|
|
||||||
wideColumn: {
|
|
||||||
width: "60%"
|
|
||||||
}
|
}
|
||||||
}),
|
},
|
||||||
{ name: "DiscountCategories" }
|
{ name: "DiscountCategories" }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -52,8 +53,7 @@ const numberOfColumns = 4;
|
||||||
|
|
||||||
const DiscountCategories: React.FC<DiscountCategoriesProps> = props => {
|
const DiscountCategories: React.FC<DiscountCategoriesProps> = props => {
|
||||||
const {
|
const {
|
||||||
discount: sale,
|
discount,
|
||||||
|
|
||||||
disabled,
|
disabled,
|
||||||
pageInfo,
|
pageInfo,
|
||||||
onCategoryAssign,
|
onCategoryAssign,
|
||||||
|
@ -88,19 +88,25 @@ const DiscountCategories: React.FC<DiscountCategoriesProps> = props => {
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<ResponsiveTable>
|
<ResponsiveTable>
|
||||||
|
<colgroup>
|
||||||
|
<col />
|
||||||
|
<col className={classes.colName} />
|
||||||
|
<col className={classes.colProducts} />
|
||||||
|
<col className={classes.colActions} />
|
||||||
|
</colgroup>
|
||||||
<TableHead
|
<TableHead
|
||||||
colSpan={numberOfColumns}
|
colSpan={numberOfColumns}
|
||||||
selected={selected}
|
selected={selected}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
items={maybe(() => sale.categories.edges.map(edge => edge.node))}
|
items={maybe(() => discount.categories.edges.map(edge => edge.node))}
|
||||||
toggleAll={toggleAll}
|
toggleAll={toggleAll}
|
||||||
toolbar={toolbar}
|
toolbar={toolbar}
|
||||||
>
|
>
|
||||||
<>
|
<>
|
||||||
<TableCell className={classes.wideColumn}>
|
<TableCell className={classes.colName}>
|
||||||
<FormattedMessage defaultMessage="Category name" />
|
<FormattedMessage defaultMessage="Category name" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className={classes.textRight}>
|
<TableCell className={classes.colProducts}>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
defaultMessage="Products"
|
defaultMessage="Products"
|
||||||
description="number of products"
|
description="number of products"
|
||||||
|
@ -124,7 +130,7 @@ const DiscountCategories: React.FC<DiscountCategoriesProps> = props => {
|
||||||
</TableFooter>
|
</TableFooter>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{renderCollection(
|
{renderCollection(
|
||||||
maybe(() => sale.categories.edges.map(edge => edge.node)),
|
maybe(() => discount.categories.edges.map(edge => edge.node)),
|
||||||
category => {
|
category => {
|
||||||
const isSelected = category ? isChecked(category.id) : false;
|
const isSelected = category ? isChecked(category.id) : false;
|
||||||
|
|
||||||
|
@ -147,13 +153,13 @@ const DiscountCategories: React.FC<DiscountCategoriesProps> = props => {
|
||||||
<TableCell>
|
<TableCell>
|
||||||
{maybe<React.ReactNode>(() => category.name, <Skeleton />)}
|
{maybe<React.ReactNode>(() => category.name, <Skeleton />)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className={classes.textRight}>
|
<TableCell className={classes.colProducts}>
|
||||||
{maybe<React.ReactNode>(
|
{maybe<React.ReactNode>(
|
||||||
() => category.products.totalCount,
|
() => category.products.totalCount,
|
||||||
<Skeleton />
|
<Skeleton />
|
||||||
)}
|
)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className={classes.iconCell}>
|
<TableCell className={classes.colActions}>
|
||||||
<IconButton
|
<IconButton
|
||||||
disabled={!category || disabled}
|
disabled={!category || disabled}
|
||||||
onClick={event => {
|
onClick={event => {
|
||||||
|
|
|
@ -28,23 +28,25 @@ export interface DiscountCollectionsProps extends ListProps, ListActions {
|
||||||
}
|
}
|
||||||
|
|
||||||
const useStyles = makeStyles(
|
const useStyles = makeStyles(
|
||||||
theme => ({
|
{
|
||||||
iconCell: {
|
colActions: {
|
||||||
"&:last-child": {
|
"&:last-child": {
|
||||||
paddingRight: 0
|
paddingRight: 0
|
||||||
},
|
},
|
||||||
width: 48 + theme.spacing(0.5)
|
width: 80
|
||||||
|
},
|
||||||
|
colName: {
|
||||||
|
width: "auto"
|
||||||
|
},
|
||||||
|
colProducts: {
|
||||||
|
textAlign: "right",
|
||||||
|
width: 140
|
||||||
},
|
},
|
||||||
tableRow: {
|
tableRow: {
|
||||||
cursor: "pointer"
|
cursor: "pointer"
|
||||||
},
|
},
|
||||||
textRight: {
|
textRight: {}
|
||||||
textAlign: "right"
|
},
|
||||||
},
|
|
||||||
wideColumn: {
|
|
||||||
width: "60%"
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
{ name: "DiscountCollections" }
|
{ name: "DiscountCollections" }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -88,6 +90,12 @@ const DiscountCollections: React.FC<DiscountCollectionsProps> = props => {
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<ResponsiveTable>
|
<ResponsiveTable>
|
||||||
|
<colgroup>
|
||||||
|
<col />
|
||||||
|
<col className={classes.colName} />
|
||||||
|
<col className={classes.colProducts} />
|
||||||
|
<col className={classes.colActions} />
|
||||||
|
</colgroup>
|
||||||
<TableHead
|
<TableHead
|
||||||
colSpan={numberOfColumns}
|
colSpan={numberOfColumns}
|
||||||
selected={selected}
|
selected={selected}
|
||||||
|
@ -96,7 +104,7 @@ const DiscountCollections: React.FC<DiscountCollectionsProps> = props => {
|
||||||
toggleAll={toggleAll}
|
toggleAll={toggleAll}
|
||||||
toolbar={toolbar}
|
toolbar={toolbar}
|
||||||
>
|
>
|
||||||
<TableCell className={classes.wideColumn}>
|
<TableCell className={classes.colName}>
|
||||||
<FormattedMessage defaultMessage="Collection name" />
|
<FormattedMessage defaultMessage="Collection name" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className={classes.textRight}>
|
<TableCell className={classes.textRight}>
|
||||||
|
@ -141,19 +149,19 @@ const DiscountCollections: React.FC<DiscountCollectionsProps> = props => {
|
||||||
onChange={() => toggle(collection.id)}
|
onChange={() => toggle(collection.id)}
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell className={classes.colName}>
|
||||||
{maybe<React.ReactNode>(
|
{maybe<React.ReactNode>(
|
||||||
() => collection.name,
|
() => collection.name,
|
||||||
<Skeleton />
|
<Skeleton />
|
||||||
)}
|
)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className={classes.textRight}>
|
<TableCell className={classes.colProducts}>
|
||||||
{maybe<React.ReactNode>(
|
{maybe<React.ReactNode>(
|
||||||
() => collection.products.totalCount,
|
() => collection.products.totalCount,
|
||||||
<Skeleton />
|
<Skeleton />
|
||||||
)}
|
)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className={classes.iconCell}>
|
<TableCell className={classes.colActions}>
|
||||||
<IconButton
|
<IconButton
|
||||||
disabled={!collection || disabled}
|
disabled={!collection || disabled}
|
||||||
onClick={event => {
|
onClick={event => {
|
||||||
|
|
|
@ -44,7 +44,7 @@ const useStyles = makeStyles(
|
||||||
width: "auto"
|
width: "auto"
|
||||||
},
|
},
|
||||||
colNameLabel: {
|
colNameLabel: {
|
||||||
marginLeft: AVATAR_MARGIN
|
marginLeft: AVATAR_MARGIN + theme.spacing(3)
|
||||||
},
|
},
|
||||||
colPublished: {
|
colPublished: {
|
||||||
width: 150
|
width: 150
|
||||||
|
@ -102,6 +102,13 @@ const DiscountProducts: React.FC<SaleProductsProps> = props => {
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<ResponsiveTable>
|
<ResponsiveTable>
|
||||||
|
<colgroup>
|
||||||
|
<col />
|
||||||
|
<col className={classes.colName} />
|
||||||
|
<col className={classes.colType} />
|
||||||
|
<col className={classes.colPublished} />
|
||||||
|
<col className={classes.colActions} />
|
||||||
|
</colgroup>
|
||||||
<TableHead
|
<TableHead
|
||||||
colSpan={numberOfColumns}
|
colSpan={numberOfColumns}
|
||||||
selected={selected}
|
selected={selected}
|
||||||
|
@ -124,7 +131,7 @@ const DiscountProducts: React.FC<SaleProductsProps> = props => {
|
||||||
description="product is published"
|
description="product is published"
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell />
|
<TableCell className={classes.colActions} />
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableFooter>
|
<TableFooter>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
|
|
@ -17,6 +17,7 @@ import { maybe, renderCollection } from "@saleor/misc";
|
||||||
import { ListActions, ListProps, SortPage } from "@saleor/types";
|
import { ListActions, ListProps, SortPage } from "@saleor/types";
|
||||||
import { DiscountValueTypeEnum } from "@saleor/types/globalTypes";
|
import { DiscountValueTypeEnum } from "@saleor/types/globalTypes";
|
||||||
import { getArrowDirection } from "@saleor/utils/sort";
|
import { getArrowDirection } from "@saleor/utils/sort";
|
||||||
|
import { getFooterColSpanWithBulkActions } from "@saleor/utils/tables";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { FormattedMessage } from "react-intl";
|
import { FormattedMessage } from "react-intl";
|
||||||
|
|
||||||
|
@ -78,7 +79,7 @@ const useStyles = makeStyles(
|
||||||
{ name: "VoucherList" }
|
{ name: "VoucherList" }
|
||||||
);
|
);
|
||||||
|
|
||||||
const numberOfColumns = 7;
|
const numberOfColumns = 6;
|
||||||
|
|
||||||
const VoucherList: React.FC<VoucherListProps> = props => {
|
const VoucherList: React.FC<VoucherListProps> = props => {
|
||||||
const {
|
const {
|
||||||
|
@ -130,6 +131,7 @@ const VoucherList: React.FC<VoucherListProps> = props => {
|
||||||
? getArrowDirection(sort.asc)
|
? getArrowDirection(sort.asc)
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
textAlign="right"
|
||||||
onClick={() => onSort(VoucherListUrlSortField.minSpent)}
|
onClick={() => onSort(VoucherListUrlSortField.minSpent)}
|
||||||
className={classes.colMinSpent}
|
className={classes.colMinSpent}
|
||||||
>
|
>
|
||||||
|
@ -144,6 +146,7 @@ const VoucherList: React.FC<VoucherListProps> = props => {
|
||||||
? getArrowDirection(sort.asc)
|
? getArrowDirection(sort.asc)
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
textAlign="right"
|
||||||
onClick={() => onSort(VoucherListUrlSortField.startDate)}
|
onClick={() => onSort(VoucherListUrlSortField.startDate)}
|
||||||
className={classes.colStart}
|
className={classes.colStart}
|
||||||
>
|
>
|
||||||
|
@ -158,6 +161,7 @@ const VoucherList: React.FC<VoucherListProps> = props => {
|
||||||
? getArrowDirection(sort.asc)
|
? getArrowDirection(sort.asc)
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
textAlign="right"
|
||||||
onClick={() => onSort(VoucherListUrlSortField.endDate)}
|
onClick={() => onSort(VoucherListUrlSortField.endDate)}
|
||||||
className={classes.colEnd}
|
className={classes.colEnd}
|
||||||
>
|
>
|
||||||
|
@ -172,6 +176,7 @@ const VoucherList: React.FC<VoucherListProps> = props => {
|
||||||
? getArrowDirection(sort.asc)
|
? getArrowDirection(sort.asc)
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
textAlign="right"
|
||||||
onClick={() => onSort(VoucherListUrlSortField.value)}
|
onClick={() => onSort(VoucherListUrlSortField.value)}
|
||||||
className={classes.colValue}
|
className={classes.colValue}
|
||||||
>
|
>
|
||||||
|
@ -186,6 +191,7 @@ const VoucherList: React.FC<VoucherListProps> = props => {
|
||||||
? getArrowDirection(sort.asc)
|
? getArrowDirection(sort.asc)
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
textAlign="right"
|
||||||
onClick={() => onSort(VoucherListUrlSortField.limit)}
|
onClick={() => onSort(VoucherListUrlSortField.limit)}
|
||||||
className={classes.colUses}
|
className={classes.colUses}
|
||||||
>
|
>
|
||||||
|
@ -195,7 +201,7 @@ const VoucherList: React.FC<VoucherListProps> = props => {
|
||||||
<TableFooter>
|
<TableFooter>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TablePagination
|
<TablePagination
|
||||||
colSpan={numberOfColumns}
|
colSpan={getFooterColSpanWithBulkActions(vouchers, numberOfColumns)}
|
||||||
settings={settings}
|
settings={settings}
|
||||||
hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}
|
hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}
|
||||||
onNextPage={onNextPage}
|
onNextPage={onNextPage}
|
||||||
|
|
|
@ -22,10 +22,14 @@ const useStyles = makeStyles(
|
||||||
height: 64,
|
height: 64,
|
||||||
width: 64
|
width: 64
|
||||||
},
|
},
|
||||||
avatarSpacing: {
|
colAvatar: {
|
||||||
paddingBottom: theme.spacing(2),
|
paddingBottom: theme.spacing(2),
|
||||||
paddingRight: theme.spacing(),
|
paddingRight: theme.spacing(),
|
||||||
paddingTop: theme.spacing(2)
|
paddingTop: theme.spacing(2),
|
||||||
|
width: 112
|
||||||
|
},
|
||||||
|
colName: {
|
||||||
|
width: "auto"
|
||||||
},
|
},
|
||||||
label: {
|
label: {
|
||||||
paddingLeft: 0
|
paddingLeft: 0
|
||||||
|
@ -62,6 +66,11 @@ export const HomeProductList: React.FC<HomeProductListProps> = props => {
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<ResponsiveTable>
|
<ResponsiveTable>
|
||||||
|
<colgroup>
|
||||||
|
<col className={classes.colAvatar} />
|
||||||
|
<col className={classes.colName} />
|
||||||
|
<col />
|
||||||
|
</colgroup>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{renderCollection(
|
{renderCollection(
|
||||||
topProducts,
|
topProducts,
|
||||||
|
@ -79,7 +88,7 @@ export const HomeProductList: React.FC<HomeProductListProps> = props => {
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<TableCellAvatar
|
<TableCellAvatar
|
||||||
className={classes.avatarSpacing}
|
className={classes.colAvatar}
|
||||||
thumbnail={maybe(() => variant.product.thumbnail.url)}
|
thumbnail={maybe(() => variant.product.thumbnail.url)}
|
||||||
avatarProps={classes.avatarProps}
|
avatarProps={classes.avatarProps}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -16,6 +16,7 @@ import { maybe, renderCollection } from "@saleor/misc";
|
||||||
import { MenuListUrlSortField } from "@saleor/navigation/urls";
|
import { MenuListUrlSortField } from "@saleor/navigation/urls";
|
||||||
import { ListActions, ListProps, SortPage } from "@saleor/types";
|
import { ListActions, ListProps, SortPage } from "@saleor/types";
|
||||||
import { getArrowDirection } from "@saleor/utils/sort";
|
import { getArrowDirection } from "@saleor/utils/sort";
|
||||||
|
import { getFooterColSpanWithBulkActions } from "@saleor/utils/tables";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { FormattedMessage } from "react-intl";
|
import { FormattedMessage } from "react-intl";
|
||||||
|
|
||||||
|
@ -37,6 +38,9 @@ const useStyles = makeStyles(
|
||||||
},
|
},
|
||||||
colTitle: {}
|
colTitle: {}
|
||||||
},
|
},
|
||||||
|
colAction: {
|
||||||
|
width: 80
|
||||||
|
},
|
||||||
colItems: {
|
colItems: {
|
||||||
textAlign: "right"
|
textAlign: "right"
|
||||||
},
|
},
|
||||||
|
@ -50,7 +54,7 @@ const useStyles = makeStyles(
|
||||||
{ name: "MenuList" }
|
{ name: "MenuList" }
|
||||||
);
|
);
|
||||||
|
|
||||||
const numberOfColumns = 4;
|
const numberOfColumns = 3;
|
||||||
|
|
||||||
const MenuList: React.FC<MenuListProps> = props => {
|
const MenuList: React.FC<MenuListProps> = props => {
|
||||||
const {
|
const {
|
||||||
|
@ -116,12 +120,12 @@ const MenuList: React.FC<MenuListProps> = props => {
|
||||||
id="menuListItems"
|
id="menuListItems"
|
||||||
/>
|
/>
|
||||||
</TableCellHeader>
|
</TableCellHeader>
|
||||||
<TableCell />
|
<TableCell className={classes.colAction} />
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableFooter>
|
<TableFooter>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TablePagination
|
<TablePagination
|
||||||
colSpan={numberOfColumns}
|
colSpan={getFooterColSpanWithBulkActions(menus, numberOfColumns)}
|
||||||
settings={settings}
|
settings={settings}
|
||||||
hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}
|
hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}
|
||||||
onNextPage={onNextPage}
|
onNextPage={onNextPage}
|
||||||
|
@ -165,6 +169,7 @@ const MenuList: React.FC<MenuListProps> = props => {
|
||||||
)}
|
)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<IconButtonTableCell
|
<IconButtonTableCell
|
||||||
|
className={classes.colAction}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onClick={() => onDelete(menu.id)}
|
onClick={() => onDelete(menu.id)}
|
||||||
>
|
>
|
||||||
|
|
|
@ -82,7 +82,7 @@ interface OrderFulfillmentProps {
|
||||||
onTrackingCodeAdd: () => void;
|
onTrackingCodeAdd: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const numberOfColumns = 4;
|
const numberOfColumns = 5;
|
||||||
|
|
||||||
const OrderFulfillment: React.FC<OrderFulfillmentProps> = props => {
|
const OrderFulfillment: React.FC<OrderFulfillmentProps> = props => {
|
||||||
const {
|
const {
|
||||||
|
|
|
@ -38,7 +38,8 @@ import {
|
||||||
const useStyles = makeStyles(
|
const useStyles = makeStyles(
|
||||||
theme => ({
|
theme => ({
|
||||||
avatar: {
|
avatar: {
|
||||||
paddingLeft: 0
|
paddingLeft: 0,
|
||||||
|
width: 64
|
||||||
},
|
},
|
||||||
colName: {
|
colName: {
|
||||||
paddingLeft: 0
|
paddingLeft: 0
|
||||||
|
|
|
@ -28,18 +28,16 @@ export interface PluginListProps
|
||||||
|
|
||||||
const useStyles = makeStyles(
|
const useStyles = makeStyles(
|
||||||
theme => ({
|
theme => ({
|
||||||
[theme.breakpoints.up("lg")]: {
|
colAction: {
|
||||||
colAction: {
|
"& svg": {
|
||||||
"& svg": {
|
color: theme.palette.primary.main
|
||||||
color: theme.palette.primary.main
|
|
||||||
},
|
|
||||||
textAlign: "right" as "right"
|
|
||||||
},
|
},
|
||||||
colActive: {},
|
textAlign: "right",
|
||||||
colName: {}
|
width: 200
|
||||||
|
},
|
||||||
|
colActive: {
|
||||||
|
width: 200
|
||||||
},
|
},
|
||||||
colAction: {},
|
|
||||||
colActive: {},
|
|
||||||
colName: {},
|
colName: {},
|
||||||
link: {
|
link: {
|
||||||
cursor: "pointer"
|
cursor: "pointer"
|
||||||
|
@ -48,7 +46,7 @@ const useStyles = makeStyles(
|
||||||
{ name: "PluginsList" }
|
{ name: "PluginsList" }
|
||||||
);
|
);
|
||||||
|
|
||||||
const numberOfColumns = 4;
|
const numberOfColumns = 3;
|
||||||
|
|
||||||
const PluginList: React.FC<PluginListProps> = props => {
|
const PluginList: React.FC<PluginListProps> = props => {
|
||||||
const {
|
const {
|
||||||
|
|
|
@ -26,16 +26,19 @@ import {
|
||||||
} from "../../types/ProductTypeDetails";
|
} from "../../types/ProductTypeDetails";
|
||||||
|
|
||||||
const useStyles = makeStyles(
|
const useStyles = makeStyles(
|
||||||
theme => ({
|
{
|
||||||
colName: {},
|
colAction: {
|
||||||
colSlug: {
|
|
||||||
width: 300
|
|
||||||
},
|
|
||||||
iconCell: {
|
|
||||||
"&:last-child": {
|
"&:last-child": {
|
||||||
paddingRight: 0
|
paddingRight: 0
|
||||||
},
|
},
|
||||||
width: 48 + theme.spacing(1.5)
|
width: 80
|
||||||
|
},
|
||||||
|
colGrab: {
|
||||||
|
width: 60
|
||||||
|
},
|
||||||
|
colName: {},
|
||||||
|
colSlug: {
|
||||||
|
width: 300
|
||||||
},
|
},
|
||||||
link: {
|
link: {
|
||||||
cursor: "pointer"
|
cursor: "pointer"
|
||||||
|
@ -43,7 +46,7 @@ const useStyles = makeStyles(
|
||||||
textLeft: {
|
textLeft: {
|
||||||
textAlign: "left"
|
textAlign: "left"
|
||||||
}
|
}
|
||||||
}),
|
},
|
||||||
{ name: "ProductTypeAttributes" }
|
{ name: "ProductTypeAttributes" }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -115,6 +118,13 @@ const ProductTypeAttributes: React.FC<ProductTypeAttributesProps> = props => {
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<ResponsiveTable>
|
<ResponsiveTable>
|
||||||
|
<colgroup>
|
||||||
|
<col className={classes.colGrab} />
|
||||||
|
<col />
|
||||||
|
<col className={classes.colName} />
|
||||||
|
<col className={classes.colSlug} />
|
||||||
|
<col className={classes.colAction} />
|
||||||
|
</colgroup>
|
||||||
<TableHead
|
<TableHead
|
||||||
colSpan={numberOfColumns}
|
colSpan={numberOfColumns}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
|
@ -178,7 +188,7 @@ const ProductTypeAttributes: React.FC<ProductTypeAttributesProps> = props => {
|
||||||
<Skeleton />
|
<Skeleton />
|
||||||
)}
|
)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className={classes.iconCell}>
|
<TableCell className={classes.colAction}>
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={stopPropagation(() =>
|
onClick={stopPropagation(() =>
|
||||||
onAttributeUnassign(attribute.id)
|
onAttributeUnassign(attribute.id)
|
||||||
|
|
|
@ -22,13 +22,18 @@ import { ProductVariantDetails_productVariant } from "../../types/ProductVariant
|
||||||
|
|
||||||
const useStyles = makeStyles(
|
const useStyles = makeStyles(
|
||||||
theme => ({
|
theme => ({
|
||||||
|
colAvatar: {
|
||||||
|
width: 64
|
||||||
|
},
|
||||||
colName: {
|
colName: {
|
||||||
paddingLeft: 0,
|
paddingLeft: 0
|
||||||
textAlign: [["left"], "!important"] as any
|
|
||||||
},
|
},
|
||||||
link: {
|
link: {
|
||||||
cursor: "pointer"
|
cursor: "pointer"
|
||||||
},
|
},
|
||||||
|
noHandle: {
|
||||||
|
textAlign: "right"
|
||||||
|
},
|
||||||
tabActive: {
|
tabActive: {
|
||||||
"& > td:first-child": {
|
"& > td:first-child": {
|
||||||
"&:before": {
|
"&:before": {
|
||||||
|
@ -92,6 +97,7 @@ const ProductVariantNavigation: React.FC<ProductVariantNavigationProps> = props
|
||||||
onClick={variant ? () => onRowClick(variant.id) : undefined}
|
onClick={variant ? () => onRowClick(variant.id) : undefined}
|
||||||
>
|
>
|
||||||
<TableCellAvatar
|
<TableCellAvatar
|
||||||
|
className={classes.colAvatar}
|
||||||
thumbnail={maybe(
|
thumbnail={maybe(
|
||||||
() => variant.images[0].url,
|
() => variant.images[0].url,
|
||||||
fallbackThumbnail
|
fallbackThumbnail
|
||||||
|
@ -115,8 +121,17 @@ const ProductVariantNavigation: React.FC<ProductVariantNavigationProps> = props
|
||||||
</TableRow>
|
</TableRow>
|
||||||
) : (
|
) : (
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCellAvatar className={classes.tabActive} thumbnail={null} />
|
<TableCellAvatar
|
||||||
<TableCell className={classes.colName} colSpan={2}>
|
alignRight
|
||||||
|
className={classNames(
|
||||||
|
classes.colAvatar,
|
||||||
|
classes.tabActive,
|
||||||
|
classes.noHandle
|
||||||
|
)}
|
||||||
|
thumbnail={null}
|
||||||
|
colSpan={2}
|
||||||
|
/>
|
||||||
|
<TableCell className={classes.colName}>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
defaultMessage="New Variant"
|
defaultMessage="New Variant"
|
||||||
description="variant name"
|
description="variant name"
|
||||||
|
|
|
@ -73,16 +73,19 @@ const useStyles = makeStyles(
|
||||||
width: 30
|
width: 30
|
||||||
},
|
},
|
||||||
colInventory: {
|
colInventory: {
|
||||||
width: 270
|
width: 200
|
||||||
},
|
},
|
||||||
colName: {},
|
colName: {},
|
||||||
colPrice: {
|
colPrice: {
|
||||||
width: 150
|
width: 135
|
||||||
},
|
},
|
||||||
colSku: {
|
colSku: {
|
||||||
width: 200
|
width: 200
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
colGrab: {
|
||||||
|
width: 60
|
||||||
|
},
|
||||||
colInventory: {
|
colInventory: {
|
||||||
textAlign: "right"
|
textAlign: "right"
|
||||||
},
|
},
|
||||||
|
@ -278,6 +281,14 @@ export const ProductVariants: React.FC<ProductVariantsProps> = props => {
|
||||||
)}
|
)}
|
||||||
{hasVariants && (
|
{hasVariants && (
|
||||||
<ResponsiveTable className={classes.denseTable}>
|
<ResponsiveTable className={classes.denseTable}>
|
||||||
|
<colgroup>
|
||||||
|
<col className={classes.colGrab} />
|
||||||
|
<col />
|
||||||
|
<col className={classes.colName} />
|
||||||
|
<col className={classes.colSku} />
|
||||||
|
<col className={classes.colPrice} />
|
||||||
|
<col className={classes.colInventory} />
|
||||||
|
</colgroup>
|
||||||
<TableHead
|
<TableHead
|
||||||
colSpan={numberOfColumns}
|
colSpan={numberOfColumns}
|
||||||
selected={selected}
|
selected={selected}
|
||||||
|
|
|
@ -15,8 +15,8 @@ import TableHead from "@saleor/components/TableHead";
|
||||||
import TablePagination from "@saleor/components/TablePagination";
|
import TablePagination from "@saleor/components/TablePagination";
|
||||||
import { ShippingZoneFragment } from "@saleor/fragments/types/ShippingZoneFragment";
|
import { ShippingZoneFragment } from "@saleor/fragments/types/ShippingZoneFragment";
|
||||||
import { maybe, renderCollection } from "@saleor/misc";
|
import { maybe, renderCollection } from "@saleor/misc";
|
||||||
import { ICONBUTTON_SIZE } from "@saleor/theme";
|
|
||||||
import { ListActions, ListProps } from "@saleor/types";
|
import { ListActions, ListProps } from "@saleor/types";
|
||||||
|
import { getFooterColSpanWithBulkActions } from "@saleor/utils/tables";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { FormattedMessage, useIntl } from "react-intl";
|
import { FormattedMessage, useIntl } from "react-intl";
|
||||||
|
|
||||||
|
@ -28,17 +28,15 @@ export interface ShippingZonesListProps extends ListProps, ListActions {
|
||||||
|
|
||||||
const useStyles = makeStyles(
|
const useStyles = makeStyles(
|
||||||
theme => ({
|
theme => ({
|
||||||
[theme.breakpoints.up("lg")]: {
|
colAction: {
|
||||||
colCountries: {},
|
|
||||||
colName: { width: 200 }
|
|
||||||
},
|
|
||||||
alignRight: {
|
|
||||||
"&:last-child": {
|
"&:last-child": {
|
||||||
paddingRight: theme.spacing(1)
|
paddingRight: theme.spacing(1)
|
||||||
},
|
},
|
||||||
width: ICONBUTTON_SIZE + theme.spacing(0.5)
|
width: 80
|
||||||
|
},
|
||||||
|
colCountries: {
|
||||||
|
width: 180
|
||||||
},
|
},
|
||||||
colCountries: {},
|
|
||||||
colName: {
|
colName: {
|
||||||
paddingLeft: 0
|
paddingLeft: 0
|
||||||
},
|
},
|
||||||
|
@ -49,7 +47,7 @@ const useStyles = makeStyles(
|
||||||
{ name: "ShippingZonesList" }
|
{ name: "ShippingZonesList" }
|
||||||
);
|
);
|
||||||
|
|
||||||
const numberOfColumns = 4;
|
const numberOfColumns = 3;
|
||||||
|
|
||||||
const ShippingZonesList: React.FC<ShippingZonesListProps> = props => {
|
const ShippingZonesList: React.FC<ShippingZonesListProps> = props => {
|
||||||
const {
|
const {
|
||||||
|
@ -108,12 +106,15 @@ const ShippingZonesList: React.FC<ShippingZonesListProps> = props => {
|
||||||
<TableCell className={classes.colCountries}>
|
<TableCell className={classes.colCountries}>
|
||||||
<FormattedMessage defaultMessage="Countries" />
|
<FormattedMessage defaultMessage="Countries" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell />
|
<TableCell className={classes.colAction} />
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableFooter>
|
<TableFooter>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TablePagination
|
<TablePagination
|
||||||
colSpan={4}
|
colSpan={getFooterColSpanWithBulkActions(
|
||||||
|
shippingZones,
|
||||||
|
numberOfColumns
|
||||||
|
)}
|
||||||
settings={settings}
|
settings={settings}
|
||||||
hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}
|
hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false}
|
||||||
onNextPage={onNextPage}
|
onNextPage={onNextPage}
|
||||||
|
@ -161,7 +162,7 @@ const ShippingZonesList: React.FC<ShippingZonesListProps> = props => {
|
||||||
<Skeleton />
|
<Skeleton />
|
||||||
)}
|
)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className={classes.alignRight}>
|
<TableCell className={classes.colAction}>
|
||||||
<IconButton
|
<IconButton
|
||||||
color="primary"
|
color="primary"
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
|
|
|
@ -68,6 +68,8 @@ interface StaffListProps extends ListProps, SortPage<StaffListUrlSortField> {
|
||||||
staffMembers: StaffList_staffUsers_edges_node[];
|
staffMembers: StaffList_staffUsers_edges_node[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const numberOfColumns = 2;
|
||||||
|
|
||||||
const StaffList: React.FC<StaffListProps> = props => {
|
const StaffList: React.FC<StaffListProps> = props => {
|
||||||
const {
|
const {
|
||||||
settings,
|
settings,
|
||||||
|
@ -119,7 +121,7 @@ const StaffList: React.FC<StaffListProps> = props => {
|
||||||
<TableFooter>
|
<TableFooter>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TablePagination
|
<TablePagination
|
||||||
colSpan={3}
|
colSpan={numberOfColumns}
|
||||||
settings={settings}
|
settings={settings}
|
||||||
hasNextPage={
|
hasNextPage={
|
||||||
pageInfo && !disabled ? pageInfo.hasNextPage : undefined
|
pageInfo && !disabled ? pageInfo.hasNextPage : undefined
|
||||||
|
|
10
src/utils/tables.ts
Normal file
10
src/utils/tables.ts
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
export function getFooterColSpanWithBulkActions(
|
||||||
|
arr: any[],
|
||||||
|
numberOfColumns: number
|
||||||
|
): number {
|
||||||
|
if (arr === undefined || arr.length > 0) {
|
||||||
|
return numberOfColumns + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return numberOfColumns;
|
||||||
|
}
|
Loading…
Reference in a new issue