fix(Datatable): actions cell align center.

This commit is contained in:
a.bouhuolia
2022-03-21 13:27:59 +02:00
parent 2f36594459
commit a533c3cb76
4 changed files with 15 additions and 17 deletions

View File

@@ -67,6 +67,7 @@ export default function TableCell({ cell, row, index }) {
'is-text-overview': cell.column.textOverview, 'is-text-overview': cell.column.textOverview,
clickable: cell.column.clickable, clickable: cell.column.clickable,
'align-right': cell.column.align === 'right', 'align-right': cell.column.align === 'right',
'align-center': cell.column.align === 'center',
[`td-${cell.column.id}`]: cell.column.id, [`td-${cell.column.id}`]: cell.column.id,
[`td-${cellType}-type`]: !!cellType, [`td-${cellType}-type`]: !!cellType,
}), }),

View File

@@ -67,11 +67,6 @@ export function TotalCell({ payload: { currencyCode }, value }) {
return <span>{formattedAmount(value, currencyCode, { noZero: true })}</span>; return <span>{formattedAmount(value, currencyCode, { noZero: true })}</span>;
} }
// Index table cell.
export function IndexTableCell({ row: { index } }) {
return <span>{index + 1}</span>;
}
/** /**
* Landed cost header cell. * Landed cost header cell.
*/ */
@@ -161,6 +156,7 @@ export function useEditableItemsEntriesColumns({ landedCost }) {
disableSortBy: true, disableSortBy: true,
disableResizing: true, disableResizing: true,
width: 45, width: 45,
align: Align.Center,
}, },
], ],
[], [],

View File

@@ -16,7 +16,7 @@ import {
AccountsListFieldCell, AccountsListFieldCell,
CheckBoxFieldCell, CheckBoxFieldCell,
} from 'components/DataTableCells'; } from 'components/DataTableCells';
import { CellType } from 'common'; import { CellType, Align } from 'common';
import { useCurrentOrganization } from 'hooks/state'; import { useCurrentOrganization } from 'hooks/state';
import { useExpensesIsForeign } from './utils'; import { useExpensesIsForeign } from './utils';
@@ -106,14 +106,13 @@ export function useExpenseFormTableColumns({ landedCost }) {
Cell: MoneyFieldCell, Cell: MoneyFieldCell,
disableSortBy: true, disableSortBy: true,
width: 40, width: 40,
className: 'amount', align: Align.Right,
}, },
{ {
Header: intl.get('description'), Header: intl.get('description'),
accessor: 'description', accessor: 'description',
Cell: InputGroupCell, Cell: InputGroupCell,
disableSortBy: true, disableSortBy: true,
className: 'description',
width: 100, width: 100,
}, },
...(landedCost ...(landedCost
@@ -125,7 +124,7 @@ export function useExpenseFormTableColumns({ landedCost }) {
disableSortBy: true, disableSortBy: true,
disableResizing: true, disableResizing: true,
width: 100, width: 100,
className: 'landed-cost', align: Align.Center,
}, },
] ]
: []), : []),
@@ -136,6 +135,7 @@ export function useExpenseFormTableColumns({ landedCost }) {
disableSortBy: true, disableSortBy: true,
disableResizing: true, disableResizing: true,
width: 45, width: 45,
align: Align.Center,
}, },
], ],
[], [],
@@ -163,3 +163,4 @@ export function ExpensesExchangeRateInputField({ ...props }) {
/> />
); );
} }
ExpensesExchangeRateInputField.cellType = CellType.Field;

View File

@@ -4,6 +4,7 @@ import { find, get } from 'lodash';
import { Button, Menu, MenuItem } from '@blueprintjs/core'; import { Button, Menu, MenuItem } from '@blueprintjs/core';
import { Popover2 } from '@blueprintjs/popover2'; import { Popover2 } from '@blueprintjs/popover2';
import { Align, CellType } from 'common';
import { MoneyFieldCell, Icon, T } from 'components'; import { MoneyFieldCell, Icon, T } from 'components';
import { InputGroupCell, ItemsListCell } from 'components/DataTableCells'; import { InputGroupCell, ItemsListCell } from 'components/DataTableCells';
@@ -17,9 +18,6 @@ export function IndexTableCell({ row: { index } }) {
*/ */
export function ActionsCellRenderer({ export function ActionsCellRenderer({
row: { index }, row: { index },
column: { id },
cell: { value },
data,
payload: { removeRow }, payload: { removeRow },
}) { }) {
const onRemoveRole = () => { const onRemoveRole = () => {
@@ -43,6 +41,7 @@ export function ActionsCellRenderer({
</Popover2> </Popover2>
); );
} }
ActionsCellRenderer.cellType = CellType.Button;
function SourceWarehouseAccessorCell({ row: { original }, payload }) { function SourceWarehouseAccessorCell({ row: { original }, payload }) {
// Ignore display zero if the item not selected yet. // Ignore display zero if the item not selected yet.
@@ -97,7 +96,7 @@ export const useWarehouseTransferTableColumns = () => {
accessor: 'source_warehouse', accessor: 'source_warehouse',
disableSortBy: true, disableSortBy: true,
Cell: SourceWarehouseAccessorCell, Cell: SourceWarehouseAccessorCell,
align: 'right', align: Align.Right,
width: 100, width: 100,
}, },
{ {
@@ -106,7 +105,7 @@ export const useWarehouseTransferTableColumns = () => {
accessor: 'destination_warehouse', accessor: 'destination_warehouse',
Cell: DistentionWarehouseAccessorCell, Cell: DistentionWarehouseAccessorCell,
disableSortBy: true, disableSortBy: true,
align: 'right', align: Align.Right,
width: 100, width: 100,
}, },
{ {
@@ -114,14 +113,14 @@ export const useWarehouseTransferTableColumns = () => {
accessor: 'quantity', accessor: 'quantity',
Cell: MoneyFieldCell, Cell: MoneyFieldCell,
disableSortBy: true, disableSortBy: true,
align: 'right', align: Align.Right,
width: 100, width: 100,
}, },
{ {
Header: intl.get('warehouse_transfer.column.cost_price'), Header: intl.get('warehouse_transfer.column.cost_price'),
accessor: 'cost', accessor: 'cost',
disableSortBy: true, disableSortBy: true,
align: 'right', align: Align.Right,
width: 80, width: 80,
}, },
{ {
@@ -131,6 +130,7 @@ export const useWarehouseTransferTableColumns = () => {
disableSortBy: true, disableSortBy: true,
disableResizing: true, disableResizing: true,
width: 45, width: 45,
align: Align.Center,
}, },
], ],
[], [],