mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
fix(DataTable): cells type.
This commit is contained in:
7
src/common/cellTypes.js
Normal file
7
src/common/cellTypes.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
export const CellType = {
|
||||||
|
Text: 'text',
|
||||||
|
Field: 'field',
|
||||||
|
Button: 'button'
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
export * from './TableStyle';
|
export * from './TableStyle';
|
||||||
export * from './features';
|
export * from './features';
|
||||||
|
export * from './cellTypes';
|
||||||
|
|
||||||
export const Align = { Left: 'left', Right: 'right', Center: 'center' };
|
export const Align = { Left: 'left', Right: 'right', Center: 'center' };
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
import React, { useRef, useCallback, useMemo } from 'react';
|
import React, { useRef, useCallback, useMemo } from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { useCellAutoFocus } from 'hooks';
|
import { FormGroup, Classes, Intent } from '@blueprintjs/core';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
|
|
||||||
|
import { CellType } from 'common';
|
||||||
|
import { useCellAutoFocus } from 'hooks';
|
||||||
import AccountsSuggestField from 'components/AccountsSuggestField';
|
import AccountsSuggestField from 'components/AccountsSuggestField';
|
||||||
|
|
||||||
// import AccountsSelectList from 'components/AccountsSelectList';
|
|
||||||
import { FormGroup, Classes, Intent } from '@blueprintjs/core';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account cell renderer.
|
* Account cell renderer.
|
||||||
*/
|
*/
|
||||||
@@ -74,3 +73,4 @@ export default function AccountCellRenderer({
|
|||||||
</FormGroup>
|
</FormGroup>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
AccountCellRenderer.cellType = CellType.Field;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { FormGroup, Intent, Classes } from '@blueprintjs/core';
|
import { FormGroup, Intent, Classes } from '@blueprintjs/core';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
|
import { CellType } from 'common';
|
||||||
import BranchSuggestField from '../BranchSuggestField';
|
import BranchSuggestField from '../BranchSuggestField';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,3 +40,5 @@ export default function BranchesListFieldCell({
|
|||||||
</FormGroup>
|
</FormGroup>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BranchesListFieldCell.cellType = CellType.Field;
|
||||||
@@ -2,6 +2,7 @@ import React from 'react';
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
import { Classes, Checkbox, FormGroup, Intent } from '@blueprintjs/core';
|
import { Classes, Checkbox, FormGroup, Intent } from '@blueprintjs/core';
|
||||||
|
import { CellType } from 'common';
|
||||||
|
|
||||||
const CheckboxEditableCell = ({
|
const CheckboxEditableCell = ({
|
||||||
row: { index, original },
|
row: { index, original },
|
||||||
@@ -45,4 +46,6 @@ const CheckboxEditableCell = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CheckboxEditableCell.cellType = CellType.Field;
|
||||||
|
|
||||||
export default CheckboxEditableCell;
|
export default CheckboxEditableCell;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import React, { useCallback } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import { FormGroup, Intent, Classes } from '@blueprintjs/core';
|
import { FormGroup, Intent, Classes } from '@blueprintjs/core';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { ContactSelecetList } from 'components';
|
|
||||||
import ContactsSuggestField from 'components/ContactsSuggestField';
|
|
||||||
|
|
||||||
|
import { CellType } from 'common';
|
||||||
|
import ContactsSuggestField from 'components/ContactsSuggestField';
|
||||||
export default function ContactsListCellRenderer({
|
export default function ContactsListCellRenderer({
|
||||||
column: { id },
|
column: { id },
|
||||||
row: { index, original },
|
row: { index, original },
|
||||||
@@ -37,3 +37,5 @@ export default function ContactsListCellRenderer({
|
|||||||
</FormGroup>
|
</FormGroup>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ContactsListCellRenderer.cellType = CellType.Field;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { Classes, InputGroup, FormGroup, Intent } from '@blueprintjs/core';
|
import { Classes, InputGroup, FormGroup, Intent } from '@blueprintjs/core';
|
||||||
|
import { CellType } from 'common';
|
||||||
|
|
||||||
const InputEditableCell = ({
|
const InputEditableCell = ({
|
||||||
row: { index },
|
row: { index },
|
||||||
@@ -37,4 +38,6 @@ const InputEditableCell = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
InputEditableCell.cellType = CellType.Field;
|
||||||
|
|
||||||
export default InputEditableCell;
|
export default InputEditableCell;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import classNames from 'classnames';
|
|||||||
import { FormGroup, Classes, Intent } from '@blueprintjs/core';
|
import { FormGroup, Classes, Intent } from '@blueprintjs/core';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
|
|
||||||
|
import { CellType } from 'common';
|
||||||
import ItemsSuggestField from 'components/ItemsSuggestField';
|
import ItemsSuggestField from 'components/ItemsSuggestField';
|
||||||
|
|
||||||
import { useCellAutoFocus } from 'hooks';
|
import { useCellAutoFocus } from 'hooks';
|
||||||
@@ -54,3 +55,5 @@ export default function ItemsListCell({
|
|||||||
</FormGroup>
|
</FormGroup>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ItemsListCell.cellType = CellType.Field;
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import React, { useCallback, useState, useEffect } from 'react';
|
import React, { useCallback, useState, useEffect } from 'react';
|
||||||
import { FormGroup, Intent } from '@blueprintjs/core';
|
import { FormGroup, Intent } from '@blueprintjs/core';
|
||||||
|
|
||||||
import { MoneyInputGroup } from 'components';
|
import { MoneyInputGroup } from 'components';
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
|
import { CellType } from 'common';
|
||||||
|
|
||||||
// Input form cell renderer.
|
// Input form cell renderer.
|
||||||
const MoneyFieldCellRenderer = ({
|
const MoneyFieldCellRenderer = ({
|
||||||
@@ -48,4 +50,6 @@ const MoneyFieldCellRenderer = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MoneyFieldCellRenderer.cellType = CellType.Field;
|
||||||
|
|
||||||
export default MoneyFieldCellRenderer;
|
export default MoneyFieldCellRenderer;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { FormGroup, NumericInput, Intent } from '@blueprintjs/core';
|
import { FormGroup, NumericInput, Intent } from '@blueprintjs/core';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
|
import { CellType } from 'common';
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,8 +38,10 @@ export default function NumericInputCell({
|
|||||||
onValueChange={handleValueChange}
|
onValueChange={handleValueChange}
|
||||||
onBlur={onBlur}
|
onBlur={onBlur}
|
||||||
fill={true}
|
fill={true}
|
||||||
buttonPosition={"none"}
|
buttonPosition={'none'}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NumericInputCell.cellType = CellType.Field;
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
import React, { useCallback } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import PaymentReceiveListField from 'components/PaymentReceiveListField';
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { FormGroup, Classes, Intent } from '@blueprintjs/core';
|
import { FormGroup, Classes, Intent } from '@blueprintjs/core';
|
||||||
|
|
||||||
|
import PaymentReceiveListField from 'components/PaymentReceiveListField';
|
||||||
|
import { CellType } from 'common';
|
||||||
function PaymentReceiveListFieldCell({
|
function PaymentReceiveListFieldCell({
|
||||||
column: { id },
|
column: { id },
|
||||||
row: { index },
|
row: { index },
|
||||||
@@ -32,4 +33,6 @@ function PaymentReceiveListFieldCell({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PaymentReceiveListFieldCell.cellType = CellType.Field;
|
||||||
|
|
||||||
export default PaymentReceiveListFieldCell;
|
export default PaymentReceiveListFieldCell;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import React, { useCallback, useState, useEffect } from 'react';
|
import React, { useCallback, useState, useEffect } from 'react';
|
||||||
import { FormGroup, Intent } from '@blueprintjs/core';
|
import { FormGroup, Intent } from '@blueprintjs/core';
|
||||||
|
|
||||||
import { MoneyInputGroup } from 'components';
|
import { MoneyInputGroup } from 'components';
|
||||||
|
import { CellType } from 'common';
|
||||||
|
|
||||||
const PercentFieldCell = ({
|
const PercentFieldCell = ({
|
||||||
cell: { value: initialValue },
|
cell: { value: initialValue },
|
||||||
@@ -38,4 +40,6 @@ const PercentFieldCell = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PercentFieldCell.cellType = CellType.Field;
|
||||||
|
|
||||||
export default PercentFieldCell;
|
export default PercentFieldCell;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React from 'react';
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { Classes, Switch, FormGroup, Intent } from '@blueprintjs/core';
|
import { Classes, Switch, FormGroup, Intent } from '@blueprintjs/core';
|
||||||
|
|
||||||
|
import { CellType } from 'common';
|
||||||
import { safeInvoke } from 'utils';
|
import { safeInvoke } from 'utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,4 +49,6 @@ const SwitchEditableCell = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SwitchEditableCell;
|
SwitchEditableCell.cellType = CellType.Field;
|
||||||
|
|
||||||
|
export default SwitchEditableCell;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { Classes, TextArea, FormGroup, Intent } from '@blueprintjs/core';
|
import { Classes, TextArea, FormGroup, Intent } from '@blueprintjs/core';
|
||||||
|
import { CellType } from 'common';
|
||||||
|
|
||||||
const TextAreaEditableCell = ({
|
const TextAreaEditableCell = ({
|
||||||
row: { index },
|
row: { index },
|
||||||
@@ -39,4 +40,6 @@ const TextAreaEditableCell = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TextAreaEditableCell.cellType = CellType.Field;
|
||||||
|
|
||||||
export default TextAreaEditableCell;
|
export default TextAreaEditableCell;
|
||||||
|
|||||||
@@ -54,10 +54,15 @@ const DatatableEditableRoot = styled.div`
|
|||||||
}
|
}
|
||||||
.tbody {
|
.tbody {
|
||||||
.tr .td {
|
.tr .td {
|
||||||
padding: 2px;
|
|
||||||
border-bottom: 0;
|
border-bottom: 0;
|
||||||
border-bottom: 1px solid #d8d8d8;
|
border-bottom: 1px solid #d8d8d8;
|
||||||
min-height: 38px;
|
min-height: 38px;
|
||||||
|
padding: 4px 14px;
|
||||||
|
|
||||||
|
&.td-field-type,
|
||||||
|
&.td-button-type{
|
||||||
|
padding: 2px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.tr:last-of-type .td {
|
.tr:last-of-type .td {
|
||||||
border-bottom: 0;
|
border-bottom: 0;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import React, { useContext } from 'react';
|
import React, { useContext } from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { If } from 'components';
|
import { camelCase} from 'lodash';
|
||||||
import { Skeleton } from 'components';
|
|
||||||
|
import { If, Skeleton } from 'components';
|
||||||
import { useAppIntlContext } from 'components/AppIntlProvider';
|
import { useAppIntlContext } from 'components/AppIntlProvider';
|
||||||
import TableContext from './TableContext';
|
import TableContext from './TableContext';
|
||||||
import { saveInvoke, ignoreEventFromSelectors } from 'utils';
|
import { saveInvoke, ignoreEventFromSelectors } from 'utils';
|
||||||
@@ -56,7 +57,8 @@ export default function TableCell({ cell, row, index }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
saveInvoke(onCellClick, cell, event);
|
saveInvoke(onCellClick, cell, event);
|
||||||
};
|
};
|
||||||
|
const cellType = camelCase(cell.column.Cell.cellType) || 'text';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -65,6 +67,8 @@ 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',
|
||||||
|
[`td-${cell.column.id}`]: cell.column.id,
|
||||||
|
[`td-${cellType}-type`]: !!cellType,
|
||||||
}),
|
}),
|
||||||
onClick: handleCellClick,
|
onClick: handleCellClick,
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Checkbox } from '@blueprintjs/core';
|
import { Checkbox } from '@blueprintjs/core';
|
||||||
|
import { CellType } from 'common';
|
||||||
export default function TableIndeterminateCheckboxRow({ row }) {
|
export default function TableIndeterminateCheckboxRow({ row }) {
|
||||||
return (
|
return (
|
||||||
<div class="selection-checkbox">
|
<div class="selection-checkbox">
|
||||||
@@ -8,3 +8,5 @@ export default function TableIndeterminateCheckboxRow({ row }) {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TableIndeterminateCheckboxRow.cellType = CellType.Field;
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Intent, Position, Button, Tooltip } from '@blueprintjs/core';
|
import { Menu, MenuItem, Position, Button } from '@blueprintjs/core';
|
||||||
|
import { Popover2 } from '@blueprintjs/popover2';
|
||||||
|
import { useFormikContext } from 'formik';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import { Icon, Hint, FormattedMessage as T } from 'components';
|
|
||||||
|
import { ExchangeRateInputGroup, Icon, Hint, FormattedMessage as T } from 'components';
|
||||||
import {
|
import {
|
||||||
AccountsListFieldCell,
|
AccountsListFieldCell,
|
||||||
MoneyFieldCell,
|
MoneyFieldCell,
|
||||||
@@ -9,12 +12,12 @@ import {
|
|||||||
ContactsListFieldCell,
|
ContactsListFieldCell,
|
||||||
BranchesListFieldCell,
|
BranchesListFieldCell,
|
||||||
} from 'components/DataTableCells';
|
} from 'components/DataTableCells';
|
||||||
|
|
||||||
|
import { CellType, Features } from 'common';
|
||||||
|
|
||||||
import { useFeatureCan } from 'hooks/state';
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import { useFormikContext } from 'formik';
|
|
||||||
import { ExchangeRateInputGroup } from 'components';
|
|
||||||
import { useCurrentOrganization } from 'hooks/state';
|
import { useCurrentOrganization } from 'hooks/state';
|
||||||
import { useJournalIsForeign } from './utils';
|
import { useJournalIsForeign } from './utils';
|
||||||
import { Features } from 'common';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contact header cell.
|
* Contact header cell.
|
||||||
@@ -55,22 +58,26 @@ export const ActionsCellRenderer = ({
|
|||||||
data,
|
data,
|
||||||
payload,
|
payload,
|
||||||
}) => {
|
}) => {
|
||||||
const onClickRemoveRole = () => {
|
const handleClickRemoveRole = () => {
|
||||||
payload.removeRow(index);
|
payload.removeRow(index);
|
||||||
};
|
};
|
||||||
|
const exampleMenu = (
|
||||||
|
<Menu>
|
||||||
|
<MenuItem onClick={handleClickRemoveRole} text="Remove line" />
|
||||||
|
</Menu>
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<Tooltip content={<T id={'remove_the_line'} />} position={Position.LEFT}>
|
<Popover2 content={exampleMenu} placement="left-start">
|
||||||
<Button
|
<Button
|
||||||
icon={<Icon icon="times-circle" iconSize={14} />}
|
icon={<Icon icon={'more-13'} iconSize={13} />}
|
||||||
iconSize={14}
|
iconSize={14}
|
||||||
className="ml2"
|
className="m12"
|
||||||
minimal={true}
|
minimal={true}
|
||||||
intent={Intent.DANGER}
|
|
||||||
onClick={onClickRemoveRole}
|
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Popover2>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
ActionsCellRenderer.cellType = CellType.Button;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve columns of make journal entries table.
|
* Retrieve columns of make journal entries table.
|
||||||
@@ -140,7 +147,6 @@ export const useJournalTableEntriesColumns = () => {
|
|||||||
Header: '',
|
Header: '',
|
||||||
accessor: 'action',
|
accessor: 'action',
|
||||||
Cell: ActionsCellRenderer,
|
Cell: ActionsCellRenderer,
|
||||||
className: 'actions',
|
|
||||||
disableSortBy: true,
|
disableSortBy: true,
|
||||||
disableResizing: true,
|
disableResizing: true,
|
||||||
width: 45,
|
width: 45,
|
||||||
@@ -154,7 +160,7 @@ export const useJournalTableEntriesColumns = () => {
|
|||||||
* Journal exchange rate input field.
|
* Journal exchange rate input field.
|
||||||
* @returns {JSX.Element}
|
* @returns {JSX.Element}
|
||||||
*/
|
*/
|
||||||
export function JournalExchangeRateInputField({ ...props }) {
|
export function JournalExchangeRateInputField({ ...props }) {
|
||||||
const currentOrganization = useCurrentOrganization();
|
const currentOrganization = useCurrentOrganization();
|
||||||
const { values } = useFormikContext();
|
const { values } = useFormikContext();
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import intl from 'react-intl-universal';
|
|||||||
import { MenuItem, Menu, Button, Position } from '@blueprintjs/core';
|
import { MenuItem, Menu, Button, Position } from '@blueprintjs/core';
|
||||||
import { Popover2 } from '@blueprintjs/popover2';
|
import { Popover2 } from '@blueprintjs/popover2';
|
||||||
|
|
||||||
import { Align } from 'common';
|
import { Align, CellType } from 'common';
|
||||||
import { Hint, Icon, FormattedMessage as T } from 'components';
|
import { Hint, Icon, FormattedMessage as T } from 'components';
|
||||||
import { formattedAmount } from 'utils';
|
import { formattedAmount } from 'utils';
|
||||||
import {
|
import {
|
||||||
@@ -58,6 +58,7 @@ export function ActionsCellRenderer({
|
|||||||
</Popover2>
|
</Popover2>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
ActionsCellRenderer.cellType = CellType.Button;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Total accessor.
|
* Total accessor.
|
||||||
|
|||||||
@@ -1,16 +1,23 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Button, Tooltip, Intent, Position, Checkbox } from '@blueprintjs/core';
|
import { Button, Menu, MenuItem } from '@blueprintjs/core';
|
||||||
import { FormattedMessage as T } from 'components';
|
import { Popover2 } from '@blueprintjs/popover2';
|
||||||
import { Icon, Hint } from 'components';
|
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
|
import { useFormikContext } from 'formik';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Icon,
|
||||||
|
Hint,
|
||||||
|
ExchangeRateInputGroup,
|
||||||
|
FormattedMessage as T,
|
||||||
|
} from 'components';
|
||||||
import {
|
import {
|
||||||
InputGroupCell,
|
InputGroupCell,
|
||||||
MoneyFieldCell,
|
MoneyFieldCell,
|
||||||
AccountsListFieldCell,
|
AccountsListFieldCell,
|
||||||
CheckBoxFieldCell,
|
CheckBoxFieldCell,
|
||||||
} from 'components/DataTableCells';
|
} from 'components/DataTableCells';
|
||||||
import { useFormikContext } from 'formik';
|
import { CellType } from 'common';
|
||||||
import { ExchangeRateInputGroup } from 'components';
|
|
||||||
import { useCurrentOrganization } from 'hooks/state';
|
import { useCurrentOrganization } from 'hooks/state';
|
||||||
import { useExpensesIsForeign } from './utils';
|
import { useExpensesIsForeign } from './utils';
|
||||||
|
|
||||||
@@ -36,22 +43,26 @@ const ActionsCellRenderer = ({
|
|||||||
data,
|
data,
|
||||||
payload,
|
payload,
|
||||||
}) => {
|
}) => {
|
||||||
const onClickRemoveRole = () => {
|
const handleClickRemoveRole = () => {
|
||||||
payload.removeRow(index);
|
payload.removeRow(index);
|
||||||
};
|
};
|
||||||
|
const exampleMenu = (
|
||||||
|
<Menu>
|
||||||
|
<MenuItem onClick={handleClickRemoveRole} text="Remove line" />
|
||||||
|
</Menu>
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<Tooltip content={<T id={'remove_the_line'} />} position={Position.LEFT}>
|
<Popover2 content={exampleMenu} placement="left-start">
|
||||||
<Button
|
<Button
|
||||||
icon={<Icon icon="times-circle" iconSize={14} />}
|
icon={<Icon icon={'more-13'} iconSize={13} />}
|
||||||
iconSize={14}
|
iconSize={14}
|
||||||
className="ml2"
|
className="m12"
|
||||||
minimal={true}
|
minimal={true}
|
||||||
intent={Intent.DANGER}
|
|
||||||
onClick={onClickRemoveRole}
|
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Popover2>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
ActionsCellRenderer.cellType = CellType.Button;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Landed cost header cell.
|
* Landed cost header cell.
|
||||||
@@ -122,7 +133,6 @@ export function useExpenseFormTableColumns({ landedCost }) {
|
|||||||
Header: '',
|
Header: '',
|
||||||
accessor: 'action',
|
accessor: 'action',
|
||||||
Cell: ActionsCellRenderer,
|
Cell: ActionsCellRenderer,
|
||||||
className: 'actions',
|
|
||||||
disableSortBy: true,
|
disableSortBy: true,
|
||||||
disableResizing: true,
|
disableResizing: true,
|
||||||
width: 45,
|
width: 45,
|
||||||
@@ -131,8 +141,6 @@ export function useExpenseFormTableColumns({ landedCost }) {
|
|||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expense exchange rate input field.
|
* Expense exchange rate input field.
|
||||||
* @returns {JSX.Element}
|
* @returns {JSX.Element}
|
||||||
|
|||||||
@@ -29,40 +29,39 @@ export function usePaymentMadeEntriesTableColumns() {
|
|||||||
return React.useMemo(
|
return React.useMemo(
|
||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
Header: intl.get('Date'),
|
Header: 'Bill date',
|
||||||
id: 'bill_date',
|
id: 'bill_date',
|
||||||
accessor: 'bill_date',
|
accessor: 'bill_date',
|
||||||
Cell: BillDateCell,
|
Cell: BillDateCell,
|
||||||
disableSortBy: true,
|
disableSortBy: true,
|
||||||
width: 250,
|
width: 120,
|
||||||
className: 'bill_date',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Header: intl.get('bill_number'),
|
Header: intl.get('bill_number'),
|
||||||
accessor: BillNumberAccessor,
|
accessor: BillNumberAccessor,
|
||||||
disableSortBy: true,
|
disableSortBy: true,
|
||||||
className: 'bill_number',
|
width: 120,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Header: intl.get('bill_amount'),
|
Header: intl.get('bill_amount'),
|
||||||
accessor: 'amount',
|
accessor: 'amount',
|
||||||
Cell: MoneyTableCell,
|
Cell: MoneyTableCell,
|
||||||
disableSortBy: true,
|
disableSortBy: true,
|
||||||
className: 'amount',
|
width: 150,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Header: intl.get('amount_due'),
|
Header: intl.get('amount_due'),
|
||||||
accessor: 'due_amount',
|
accessor: 'due_amount',
|
||||||
Cell: MoneyTableCell,
|
Cell: MoneyTableCell,
|
||||||
disableSortBy: true,
|
disableSortBy: true,
|
||||||
className: 'due_amount',
|
width: 150,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Header: intl.get('payment_amount'),
|
Header: intl.get('payment_amount'),
|
||||||
accessor: 'payment_amount',
|
accessor: 'payment_amount',
|
||||||
Cell: MoneyFieldCell,
|
Cell: MoneyFieldCell,
|
||||||
disableSortBy: true,
|
disableSortBy: true,
|
||||||
className: 'payment_amount',
|
width: 150,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[],
|
[],
|
||||||
|
|||||||
Reference in New Issue
Block a user