feat: add onCell Click.

This commit is contained in:
elforjani13
2021-10-26 16:49:06 +02:00
parent 2fd78ca1c4
commit a71ae1813b
3 changed files with 42 additions and 33 deletions

View File

@@ -15,6 +15,7 @@ import withDrawerActions from 'containers/Drawer/withDrawerActions';
import { useMemorizedColumnsWidths } from '../../../hooks'; import { useMemorizedColumnsWidths } from '../../../hooks';
import { useAccountTransactionsColumns, ActionsMenu } from './components'; import { useAccountTransactionsColumns, ActionsMenu } from './components';
import { useAccountTransactionsContext } from './AccountTransactionsProvider'; import { useAccountTransactionsContext } from './AccountTransactionsProvider';
import { handleCashFlowTransactionType } from './utils';
import { compose } from 'utils'; import { compose } from 'utils';
/** /**
@@ -46,37 +47,14 @@ function AccountTransactionsDataTable({
openAlert('account-transaction-delete', { referenceId: reference_id }); openAlert('account-transaction-delete', { referenceId: reference_id });
}; };
const handleViewDetailCashflowTransaction = ({ const handleViewDetailCashflowTransaction = (referenceType) => {
reference_id, handleCashFlowTransactionType(referenceType, openDrawer);
reference_type, };
}) => {
switch (reference_type) {
case 'SaleReceipt':
return openDrawer('receipt-detail-drawer', {
receiptId: reference_id,
});
case 'Journal':
return openDrawer('journal-drawer', {
manualJournalId: reference_id,
});
case 'Expense':
return openDrawer('expense-drawer', {
expenseId: reference_id,
});
case 'PaymentReceive':
return openDrawer('payment-receive-detail-drawer', {
paymentReceiveId: reference_id,
});
case 'BillPayment':
return openDrawer('payment-made-detail-drawer', {
paymentMadeId: reference_id,
});
default: // Handle cell click.
return openDrawer('cashflow-transaction-drawer', { const handleCellClick = (cell, event) => {
referenceId: reference_id, const referenceType = cell.row.original;
}); handleCashFlowTransactionType(referenceType, openDrawer);
}
}; };
return ( return (
@@ -95,6 +73,7 @@ function AccountTransactionsDataTable({
TableRowsRenderer={TableVirtualizedListRows} TableRowsRenderer={TableVirtualizedListRows}
TableHeaderSkeletonRenderer={TableSkeletonHeader} TableHeaderSkeletonRenderer={TableSkeletonHeader}
ContextMenu={ActionsMenu} ContextMenu={ActionsMenu}
onCellClick={handleCellClick}
// #TableVirtualizedListRows props. // #TableVirtualizedListRows props.
vListrowHeight={cashflowTansactionsTableSize == 'small' ? 32 : 40} vListrowHeight={cashflowTansactionsTableSize == 'small' ? 32 : 40}
vListOverscanRowCount={0} vListOverscanRowCount={0}

View File

@@ -48,3 +48,33 @@ export const CashFlowMenuItems = ({
</Select> </Select>
); );
}; };
export const handleCashFlowTransactionType = (reference, openDrawer) => {
switch (reference.reference_type) {
case 'SaleReceipt':
return openDrawer('receipt-detail-drawer', {
receiptId: reference.reference_id,
});
case 'Journal':
return openDrawer('journal-drawer', {
manualJournalId: reference.reference_id,
});
case 'Expense':
return openDrawer('expense-drawer', {
expenseId: reference.reference_id,
});
case 'PaymentReceive':
return openDrawer('payment-receive-detail-drawer', {
paymentReceiveId: reference.reference_id,
});
case 'BillPayment':
return openDrawer('payment-made-detail-drawer', {
paymentMadeId: reference.reference_id,
});
default:
return openDrawer('cashflow-transaction-drawer', {
referenceId: reference.reference_id,
});
}
};

View File

@@ -7,7 +7,7 @@ import {
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import { DateInput } from '@blueprintjs/datetime'; import { DateInput } from '@blueprintjs/datetime';
import { FormattedMessage as T } from 'components'; import { FormattedMessage as T } from 'components';
import { FastField, ErrorMessage } from 'formik'; import { FastField, Field, ErrorMessage } from 'formik';
import { import {
momentFormatter, momentFormatter,
compose, compose,
@@ -152,7 +152,7 @@ function EstimateFormHeader({
</FastField> </FastField>
{/* ----------- Estimate number ----------- */} {/* ----------- Estimate number ----------- */}
<FastField name={'estimate_number'}> <Field name={'estimate_number'}>
{({ form, field, meta: { error, touched } }) => ( {({ form, field, meta: { error, touched } }) => (
<FormGroup <FormGroup
label={<T id={'estimate'} />} label={<T id={'estimate'} />}
@@ -185,7 +185,7 @@ function EstimateFormHeader({
</ControlGroup> </ControlGroup>
</FormGroup> </FormGroup>
)} )}
</FastField> </Field>
{/* ----------- Reference ----------- */} {/* ----------- Reference ----------- */}
<FastField name={'reference'}> <FastField name={'reference'}>