mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-22 07:40:32 +00:00
feat: add cashflow & vendor ability.
This commit is contained in:
@@ -4,9 +4,13 @@ import intl from 'react-intl-universal';
|
|||||||
import { Intent, Menu, MenuItem, MenuDivider } from '@blueprintjs/core';
|
import { Intent, Menu, MenuItem, MenuDivider } from '@blueprintjs/core';
|
||||||
|
|
||||||
import { MaterialProgressBar } from 'components';
|
import { MaterialProgressBar } from 'components';
|
||||||
import { FormatDateCell, If, Icon } from 'components';
|
import { Can, FormatDateCell, If, Icon } from 'components';
|
||||||
import { useAccountTransactionsContext } from './AccountTransactionsProvider';
|
import { useAccountTransactionsContext } from './AccountTransactionsProvider';
|
||||||
import { TRANSACRIONS_TYPE } from 'common/cashflowOptions';
|
import { TRANSACRIONS_TYPE } from 'common/cashflowOptions';
|
||||||
|
import {
|
||||||
|
AbilitySubject,
|
||||||
|
Cashflow_Abilities,
|
||||||
|
} from '../../../common/abilityOption';
|
||||||
import { safeCallback } from 'utils';
|
import { safeCallback } from 'utils';
|
||||||
|
|
||||||
export function ActionsMenu({
|
export function ActionsMenu({
|
||||||
@@ -20,6 +24,7 @@ export function ActionsMenu({
|
|||||||
text={intl.get('view_details')}
|
text={intl.get('view_details')}
|
||||||
onClick={safeCallback(onViewDetails, original)}
|
onClick={safeCallback(onViewDetails, original)}
|
||||||
/>
|
/>
|
||||||
|
<Can I={Cashflow_Abilities.Delete} a={AbilitySubject.Cashflow}>
|
||||||
<If condition={TRANSACRIONS_TYPE.includes(original.reference_type)}>
|
<If condition={TRANSACRIONS_TYPE.includes(original.reference_type)}>
|
||||||
<MenuDivider />
|
<MenuDivider />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
@@ -29,6 +34,7 @@ export function ActionsMenu({
|
|||||||
icon={<Icon icon="trash-16" iconSize={16} />}
|
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||||
/>
|
/>
|
||||||
</If>
|
</If>
|
||||||
|
</Can>
|
||||||
</Menu>
|
</Menu>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -83,7 +89,7 @@ export function useAccountTransactionsColumns() {
|
|||||||
className: 'deposit',
|
className: 'deposit',
|
||||||
textOverview: true,
|
textOverview: true,
|
||||||
align: 'right',
|
align: 'right',
|
||||||
clickable: true
|
clickable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'withdrawal',
|
id: 'withdrawal',
|
||||||
@@ -93,7 +99,7 @@ export function useAccountTransactionsColumns() {
|
|||||||
width: 150,
|
width: 150,
|
||||||
textOverview: true,
|
textOverview: true,
|
||||||
align: 'right',
|
align: 'right',
|
||||||
clickable: true
|
clickable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'running_balance',
|
id: 'running_balance',
|
||||||
@@ -103,7 +109,7 @@ export function useAccountTransactionsColumns() {
|
|||||||
width: 150,
|
width: 150,
|
||||||
textOverview: true,
|
textOverview: true,
|
||||||
align: 'right',
|
align: 'right',
|
||||||
clickable: true
|
clickable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'balance',
|
id: 'balance',
|
||||||
|
|||||||
@@ -7,8 +7,12 @@ import {
|
|||||||
Alignment,
|
Alignment,
|
||||||
Switch,
|
Switch,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import { Icon, FormattedMessage as T } from 'components';
|
import { Can, Icon, FormattedMessage as T } from 'components';
|
||||||
import { useRefreshCashflowAccounts } from 'hooks/query';
|
import { useRefreshCashflowAccounts } from 'hooks/query';
|
||||||
|
import {
|
||||||
|
Cashflow_Abilities,
|
||||||
|
AbilitySubject,
|
||||||
|
} from '../../../common/abilityOption';
|
||||||
|
|
||||||
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
||||||
|
|
||||||
@@ -56,12 +60,14 @@ function CashFlowAccountsActionsBar({
|
|||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
|
<Can I={Cashflow_Abilities.Create} a={AbilitySubject.Cashflow}>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon={'plus-24'} iconSize={20} />}
|
icon={<Icon icon={'plus-24'} iconSize={20} />}
|
||||||
text={<T id={'cash_flow.label.add_cash_account'} />}
|
text={<T id={'cash_flow.label.add_cash_account'} />}
|
||||||
onClick={handleAddBankAccount}
|
onClick={handleAddBankAccount}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon={'plus-24'} iconSize={20} />}
|
icon={<Icon icon={'plus-24'} iconSize={20} />}
|
||||||
@@ -69,6 +75,7 @@ function CashFlowAccountsActionsBar({
|
|||||||
onClick={handleAddCashAccount}
|
onClick={handleAddCashAccount}
|
||||||
/>
|
/>
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
|
</Can>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon="print-16" iconSize={16} />}
|
icon={<Icon icon="print-16" iconSize={16} />}
|
||||||
@@ -85,13 +92,15 @@ function CashFlowAccountsActionsBar({
|
|||||||
text={<T id={'import'} />}
|
text={<T id={'import'} />}
|
||||||
/>
|
/>
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
|
<Can I={Cashflow_Abilities.Edit} a={AbilitySubject.Cashflow}>
|
||||||
<Switch
|
<Switch
|
||||||
labelElement={<T id={'inactive'} />}
|
labelElement={<T id={'inactive'} />}
|
||||||
defaultChecked={false}
|
defaultChecked={false}
|
||||||
onChange={handleInactiveSwitchChange}
|
onChange={handleInactiveSwitchChange}
|
||||||
/>
|
/>
|
||||||
|
</Can>
|
||||||
</NavbarGroup>
|
</NavbarGroup>
|
||||||
|
|
||||||
<NavbarGroup align={Alignment.RIGHT}>
|
<NavbarGroup align={Alignment.RIGHT}>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
|
|||||||
@@ -13,7 +13,13 @@ import {
|
|||||||
If,
|
If,
|
||||||
Icon,
|
Icon,
|
||||||
T,
|
T,
|
||||||
|
Can,
|
||||||
} from '../../../components';
|
} from '../../../components';
|
||||||
|
import {
|
||||||
|
Account_Abilities,
|
||||||
|
Cashflow_Abilities,
|
||||||
|
AbilitySubject,
|
||||||
|
} from '../../../common/abilityOption';
|
||||||
|
|
||||||
import { useCashFlowAccountsContext } from './CashFlowAccountsProvider';
|
import { useCashFlowAccountsContext } from './CashFlowAccountsProvider';
|
||||||
|
|
||||||
@@ -222,6 +228,7 @@ function CashflowAccountContextMenu({
|
|||||||
text={intl.get('view_details')}
|
text={intl.get('view_details')}
|
||||||
onClick={safeCallback(onViewClick)}
|
onClick={safeCallback(onViewClick)}
|
||||||
/>
|
/>
|
||||||
|
<Can I={Cashflow_Abilities.Create} a={AbilitySubject.Cashflow}>
|
||||||
<MenuDivider />
|
<MenuDivider />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
text={<T id={'cash_flow_money_in'} />}
|
text={<T id={'cash_flow_money_in'} />}
|
||||||
@@ -236,6 +243,8 @@ function CashflowAccountContextMenu({
|
|||||||
>
|
>
|
||||||
<CashflowAccountMoneyOutContextMenu onClick={onMoneyOutClick} />
|
<CashflowAccountMoneyOutContextMenu onClick={onMoneyOutClick} />
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
</Can>
|
||||||
|
<Can I={Cashflow_Abilities.Edit} a={AbilitySubject.Cashflow}>
|
||||||
<MenuDivider />
|
<MenuDivider />
|
||||||
|
|
||||||
<MenuItem
|
<MenuItem
|
||||||
@@ -243,6 +252,8 @@ function CashflowAccountContextMenu({
|
|||||||
text={intl.get('edit_account')}
|
text={intl.get('edit_account')}
|
||||||
onClick={safeCallback(onEditClick)}
|
onClick={safeCallback(onEditClick)}
|
||||||
/>
|
/>
|
||||||
|
</Can>
|
||||||
|
<Can I={Account_Abilities.Edit} a={AbilitySubject.Account}>
|
||||||
<MenuDivider />
|
<MenuDivider />
|
||||||
<If condition={account.active}>
|
<If condition={account.active}>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
@@ -258,12 +269,15 @@ function CashflowAccountContextMenu({
|
|||||||
onClick={safeCallback(onActivateClick)}
|
onClick={safeCallback(onActivateClick)}
|
||||||
/>
|
/>
|
||||||
</If>
|
</If>
|
||||||
|
</Can>
|
||||||
|
<Can I={Cashflow_Abilities.Delete} a={AbilitySubject.Cashflow}>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
text={intl.get('delete_account')}
|
text={intl.get('delete_account')}
|
||||||
icon={<Icon icon="trash-16" iconSize={16} />}
|
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||||
intent={Intent.DANGER}
|
intent={Intent.DANGER}
|
||||||
onClick={safeCallback(onDeleteClick)}
|
onClick={safeCallback(onDeleteClick)}
|
||||||
/>
|
/>
|
||||||
|
</Can>
|
||||||
</Menu>
|
</Menu>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Icon from 'components/Icon';
|
import Icon from 'components/Icon';
|
||||||
import { Button, Classes, NavbarGroup, Intent } from '@blueprintjs/core';
|
import { Button, Classes, NavbarGroup, Intent } from '@blueprintjs/core';
|
||||||
import { FormattedMessage as T } from 'components';
|
import { Can, FormattedMessage as T } from 'components';
|
||||||
|
|
||||||
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
||||||
import { useCashflowTransactionDrawerContext } from './CashflowTransactionDrawerProvider';
|
import { useCashflowTransactionDrawerContext } from './CashflowTransactionDrawerProvider';
|
||||||
import withAlertsActions from 'containers/Alert/withAlertActions';
|
import withAlertsActions from 'containers/Alert/withAlertActions';
|
||||||
|
import {
|
||||||
|
AbilitySubject,
|
||||||
|
Cashflow_Abilities,
|
||||||
|
} from '../../../common/abilityOption';
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,6 +27,7 @@ function CashflowTransactionDrawerActionBar({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<Can I={Cashflow_Abilities.Delete} a={AbilitySubject.Cashflow}>
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
<Button
|
<Button
|
||||||
@@ -35,6 +39,7 @@ function CashflowTransactionDrawerActionBar({
|
|||||||
/>
|
/>
|
||||||
</NavbarGroup>
|
</NavbarGroup>
|
||||||
</DashboardActionsBar>
|
</DashboardActionsBar>
|
||||||
|
</Can>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
export default compose(withAlertsActions)(CashflowTransactionDrawerActionBar);
|
export default compose(withAlertsActions)(CashflowTransactionDrawerActionBar);
|
||||||
|
|||||||
@@ -142,12 +142,15 @@ function VendorActionsBar({
|
|||||||
onChange={handleTableRowSizeChange}
|
onChange={handleTableRowSizeChange}
|
||||||
/>
|
/>
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
|
<Can I={Vendor_Abilities.Edit} a={AbilitySubject.Vendor}>
|
||||||
<Switch
|
<Switch
|
||||||
labelElement={<T id={'inactive'} />}
|
labelElement={<T id={'inactive'} />}
|
||||||
defaultChecked={vendorsInactiveMode}
|
defaultChecked={vendorsInactiveMode}
|
||||||
onChange={handleInactiveSwitchChange}
|
onChange={handleInactiveSwitchChange}
|
||||||
/>
|
/>
|
||||||
|
</Can>
|
||||||
</NavbarGroup>
|
</NavbarGroup>
|
||||||
|
|
||||||
<NavbarGroup align={Alignment.RIGHT}>
|
<NavbarGroup align={Alignment.RIGHT}>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
|
|||||||
Reference in New Issue
Block a user