mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
Merge branch 'develop' of https://github.com/bigcapitalhq/client into develop
This commit is contained in:
@@ -0,0 +1,82 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import intl from 'react-intl-universal';
|
||||||
|
import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
|
||||||
|
import { Intent, Alert } from '@blueprintjs/core';
|
||||||
|
import { AppToaster } from 'components';
|
||||||
|
|
||||||
|
import { useCancelUnlockingPartialTransactions } from 'hooks/query';
|
||||||
|
|
||||||
|
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
|
||||||
|
import withAlertActions from 'containers/Alert/withAlertActions';
|
||||||
|
|
||||||
|
import { compose } from 'utils';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel Unlocking partial transactions alerts.
|
||||||
|
*/
|
||||||
|
function CancelUnlockingPartialTarnsactions({
|
||||||
|
name,
|
||||||
|
|
||||||
|
// #withAlertStoreConnect
|
||||||
|
isOpen,
|
||||||
|
payload: { module },
|
||||||
|
|
||||||
|
// #withAlertActions
|
||||||
|
closeAlert,
|
||||||
|
}) {
|
||||||
|
const { mutateAsync: cancelUnlockingPartial, isLoading } =
|
||||||
|
useCancelUnlockingPartialTransactions();
|
||||||
|
|
||||||
|
// Handle cancel.
|
||||||
|
const handleCancel = () => {
|
||||||
|
closeAlert(name);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Handle confirm.
|
||||||
|
const handleConfirm = () => {
|
||||||
|
const values = {
|
||||||
|
module: module,
|
||||||
|
};
|
||||||
|
cancelUnlockingPartial(values)
|
||||||
|
.then(() => {
|
||||||
|
AppToaster.show({
|
||||||
|
message: intl.get(
|
||||||
|
'unlocking_partial_transactions.alert.success_message',
|
||||||
|
),
|
||||||
|
intent: Intent.SUCCESS,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(
|
||||||
|
({
|
||||||
|
response: {
|
||||||
|
data: { errors },
|
||||||
|
},
|
||||||
|
}) => {},
|
||||||
|
)
|
||||||
|
.finally(() => {
|
||||||
|
closeAlert(name);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Alert
|
||||||
|
cancelButtonText={<T id={'cancel'} />}
|
||||||
|
confirmButtonText={<T id={'save'} />}
|
||||||
|
icon="trash"
|
||||||
|
intent={Intent.WARNING}
|
||||||
|
isOpen={isOpen}
|
||||||
|
onCancel={handleCancel}
|
||||||
|
onConfirm={handleConfirm}
|
||||||
|
loading={isLoading}
|
||||||
|
>
|
||||||
|
<p>
|
||||||
|
<T id={'unlocking_partial_transactions.alert.message'} />
|
||||||
|
</p>
|
||||||
|
</Alert>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default compose(
|
||||||
|
withAlertStoreConnect(),
|
||||||
|
withAlertActions,
|
||||||
|
)(CancelUnlockingPartialTarnsactions);
|
||||||
@@ -19,6 +19,7 @@ import CurrenciesAlerts from '../Preferences/Currencies/CurrenciesAlerts';
|
|||||||
import RolesAlerts from '../Preferences/Users/Roles/RolesAlerts';
|
import RolesAlerts from '../Preferences/Users/Roles/RolesAlerts';
|
||||||
import CreditNotesAlerts from '../Sales/CreditNotes/CreditNotesAlerts';
|
import CreditNotesAlerts from '../Sales/CreditNotes/CreditNotesAlerts';
|
||||||
import VendorCreditNotesAlerts from '../Purchases/CreditNotes/VendorCreditNotesAlerts';
|
import VendorCreditNotesAlerts from '../Purchases/CreditNotes/VendorCreditNotesAlerts';
|
||||||
|
import TransactionsLockingAlerts from '../TransactionsLocking/TransactionsLockingAlerts'
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
...AccountsAlerts,
|
...AccountsAlerts,
|
||||||
@@ -42,4 +43,5 @@ export default [
|
|||||||
...RolesAlerts,
|
...RolesAlerts,
|
||||||
...CreditNotesAlerts,
|
...CreditNotesAlerts,
|
||||||
...VendorCreditNotesAlerts,
|
...VendorCreditNotesAlerts,
|
||||||
|
...TransactionsLockingAlerts
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,30 +1,26 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { DialogContent } from 'components';
|
import { DialogContent } from 'components';
|
||||||
import {
|
import { useCancelLockingTransaction } from 'hooks/query';
|
||||||
useCancelLockingTransaction,
|
|
||||||
useCancelUnlockingPartialTransactions,
|
|
||||||
} from 'hooks/query';
|
|
||||||
|
|
||||||
const UnlockingTransactionsContext = React.createContext();
|
const UnlockingTransactionsContext = React.createContext();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unlocking transactions form provider.
|
* Unlocking transactions form provider.
|
||||||
*/
|
*/
|
||||||
function UnlockingTransactionsFormProvider({ moduleName, dialogName, ...props }) {
|
function UnlockingTransactionsFormProvider({
|
||||||
|
moduleName,
|
||||||
|
dialogName,
|
||||||
|
...props
|
||||||
|
}) {
|
||||||
// Cancle locking transactions mutations.
|
// Cancle locking transactions mutations.
|
||||||
const { mutateAsync: cancelLockingTransactionMutate } =
|
const { mutateAsync: cancelLockingTransactionMutate } =
|
||||||
useCancelLockingTransaction();
|
useCancelLockingTransaction();
|
||||||
|
|
||||||
// Cancel unlocking partial transactions mutations.
|
|
||||||
const { mutateAsync: cancelUnLockingPartialTransactionMutate } =
|
|
||||||
useCancelUnlockingPartialTransactions();
|
|
||||||
|
|
||||||
// State provider.
|
// State provider.
|
||||||
const provider = {
|
const provider = {
|
||||||
dialogName,
|
dialogName,
|
||||||
moduleName,
|
moduleName,
|
||||||
cancelLockingTransactionMutate,
|
cancelLockingTransactionMutate,
|
||||||
cancelUnLockingPartialTransactionMutate,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ const ItemBulkDeleteAlert = React.lazy(() =>
|
|||||||
import('containers/Alerts/Items/ItemBulkDeleteAlert'),
|
import('containers/Alerts/Items/ItemBulkDeleteAlert'),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const cancelUnlockingPartialAlert = React.lazy(() =>
|
||||||
|
import('../Alerts/TransactionLocking/cancelUnlockingPartialAlert'),
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Items alert.
|
* Items alert.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
const cancelUnlockingPartialAlert = React.lazy(() =>
|
||||||
|
import('../Alerts/TransactionLocking/cancelUnlockingPartialAlert'),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transactions alerts.
|
||||||
|
*/
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
name: 'cancel-unlocking-partail',
|
||||||
|
component: cancelUnlockingPartialAlert,
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -12,6 +12,8 @@ import {
|
|||||||
} from './components';
|
} from './components';
|
||||||
import { useTransactionsLockingContext } from './TransactionsLockingProvider';
|
import { useTransactionsLockingContext } from './TransactionsLockingProvider';
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
|
import withAlertsActions from 'containers/Alert/withAlertActions';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
validateMoveToFullLocking,
|
validateMoveToFullLocking,
|
||||||
validateMoveToPartialLocking,
|
validateMoveToPartialLocking,
|
||||||
@@ -21,18 +23,35 @@ function Paragraph({ className, children }) {
|
|||||||
return <p className={clsx('paragraph', className)}>{children}</p>;
|
return <p className={clsx('paragraph', className)}>{children}</p>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function TransactionsLockingList({ items, onlock, onUnlock, onUnlockPartial }) {
|
function TransactionsLockingList({
|
||||||
return items.map(({ is_enabled, module, formatted_module, description }) => (
|
items,
|
||||||
<TransactionLockingContent
|
onLock,
|
||||||
name={formatted_module}
|
onUnlock,
|
||||||
module={module}
|
onUnlockPartial,
|
||||||
description={description}
|
onCancel,
|
||||||
isEnabled={is_enabled}
|
}) {
|
||||||
onLock={onlock}
|
return items.map(
|
||||||
onUnlockPartial={onUnlockPartial}
|
({
|
||||||
onEditLock={onlock}
|
is_enabled,
|
||||||
/>
|
is_partial_unlock,
|
||||||
));
|
module,
|
||||||
|
formatted_module,
|
||||||
|
description,
|
||||||
|
}) => (
|
||||||
|
<TransactionLockingContent
|
||||||
|
name={formatted_module}
|
||||||
|
module={module}
|
||||||
|
description={description}
|
||||||
|
isEnabled={is_enabled}
|
||||||
|
isPartialUnlock={is_partial_unlock}
|
||||||
|
onLock={onLock}
|
||||||
|
onUnlockFull={onUnlock}
|
||||||
|
onUnlockPartial={onUnlockPartial}
|
||||||
|
onEditLock={onLock}
|
||||||
|
onCancle={onCancel}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function TransactionsLockingFull({ onLock, onUnlock, onUnlockPartial }) {
|
function TransactionsLockingFull({ onLock, onUnlock, onUnlockPartial }) {
|
||||||
@@ -137,11 +156,13 @@ function TransactionsLockingAlert() {
|
|||||||
function TransactionsLockingBodyJsx({
|
function TransactionsLockingBodyJsx({
|
||||||
// #withDialogActions
|
// #withDialogActions
|
||||||
openDialog,
|
openDialog,
|
||||||
|
|
||||||
|
// #withAlertsActions
|
||||||
|
openAlert,
|
||||||
}) {
|
}) {
|
||||||
const {
|
const {
|
||||||
transactionsLocking: { modules },
|
transactionsLocking: { modules },
|
||||||
isTransactionLockingLoading,
|
isTransactionLockingLoading,
|
||||||
|
|
||||||
transactionLockingType,
|
transactionLockingType,
|
||||||
} = useTransactionsLockingContext();
|
} = useTransactionsLockingContext();
|
||||||
|
|
||||||
@@ -159,25 +180,35 @@ function TransactionsLockingBodyJsx({
|
|||||||
openDialog('unlocking-partial-transactions', { module: module });
|
openDialog('unlocking-partial-transactions', { module: module });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle cancel.
|
||||||
|
const handleCancelUnlockingPartail = (module) => {
|
||||||
|
openAlert('cancel-unlocking-partail', { module: module });
|
||||||
|
};
|
||||||
|
|
||||||
return !isTransactionLockingLoading ? (
|
return !isTransactionLockingLoading ? (
|
||||||
transactionLockingType === 'partial' ? (
|
transactionLockingType === 'partial' ? (
|
||||||
<TransactionsLockingList
|
<TransactionsLockingList
|
||||||
items={modules}
|
items={modules}
|
||||||
onlock={handleLockingTransactions}
|
onLock={handleLockingTransactions}
|
||||||
onUnlock={handleUnlockTransactions}
|
onUnlock={handleUnlockTransactions}
|
||||||
onUnlockPartial={handleUnlockingPartial}
|
onUnlockPartial={handleUnlockingPartial}
|
||||||
|
onCancel={handleCancelUnlockingPartail}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<TransactionsLockingFull />
|
<TransactionsLockingFull
|
||||||
|
onLock={handleLockingTransactions}
|
||||||
|
onUnlockPartial={handleUnlockingPartial}
|
||||||
|
/>
|
||||||
)
|
)
|
||||||
) : (
|
) : (
|
||||||
<TransactionLockingSkeletonList />
|
<TransactionLockingSkeletonList />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TransactionsLockingBody = R.compose(withDialogActions)(
|
const TransactionsLockingBody = R.compose(
|
||||||
TransactionsLockingBodyJsx,
|
withAlertsActions,
|
||||||
);
|
withDialogActions,
|
||||||
|
)(TransactionsLockingBodyJsx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transactions locking list.
|
* Transactions locking list.
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ export const TransactionLockingContent = ({
|
|||||||
onEditLock,
|
onEditLock,
|
||||||
onUnlockFull,
|
onUnlockFull,
|
||||||
onUnlockPartial,
|
onUnlockPartial,
|
||||||
|
onCancle,
|
||||||
}) => {
|
}) => {
|
||||||
const handleLockClick = (event) => {
|
const handleLockClick = (event) => {
|
||||||
safeInvoke(onLock, module, event);
|
safeInvoke(onLock, module, event);
|
||||||
@@ -60,6 +61,9 @@ export const TransactionLockingContent = ({
|
|||||||
const handleUnlockFull = (event) => {
|
const handleUnlockFull = (event) => {
|
||||||
safeInvoke(onUnlockFull, module, event);
|
safeInvoke(onUnlockFull, module, event);
|
||||||
};
|
};
|
||||||
|
const handleCanclel = (event) => {
|
||||||
|
safeInvoke(onCancle, module, event);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TransactionLockingWrapp isEnabled={isEnabled}>
|
<TransactionLockingWrapp isEnabled={isEnabled}>
|
||||||
@@ -85,7 +89,7 @@ export const TransactionLockingContent = ({
|
|||||||
</TransLockingContent>
|
</TransLockingContent>
|
||||||
|
|
||||||
<TransLockingActions>
|
<TransLockingActions>
|
||||||
<If condition={!isEnabled}>
|
<If condition={!isEnabled && !isPartialUnlock}>
|
||||||
<Button
|
<Button
|
||||||
small={true}
|
small={true}
|
||||||
minimal={true}
|
minimal={true}
|
||||||
@@ -96,7 +100,7 @@ export const TransactionLockingContent = ({
|
|||||||
</Button>
|
</Button>
|
||||||
</If>
|
</If>
|
||||||
|
|
||||||
<If condition={isEnabled}>
|
<If condition={isEnabled && !isPartialUnlock}>
|
||||||
<Button
|
<Button
|
||||||
small={true}
|
small={true}
|
||||||
minimal={true}
|
minimal={true}
|
||||||
@@ -110,6 +114,7 @@ export const TransactionLockingContent = ({
|
|||||||
content={
|
content={
|
||||||
<Menu>
|
<Menu>
|
||||||
<MenuItem text="Full unlock" onClick={handleUnlockFull} />
|
<MenuItem text="Full unlock" onClick={handleUnlockFull} />
|
||||||
|
|
||||||
<MenuItem
|
<MenuItem
|
||||||
text="Partial unlock"
|
text="Partial unlock"
|
||||||
onClick={handleUnlockPartial}
|
onClick={handleUnlockPartial}
|
||||||
@@ -124,6 +129,17 @@ export const TransactionLockingContent = ({
|
|||||||
</Button>
|
</Button>
|
||||||
</Popover2>
|
</Popover2>
|
||||||
</If>
|
</If>
|
||||||
|
|
||||||
|
<If condition={isPartialUnlock}>
|
||||||
|
<Button
|
||||||
|
small={true}
|
||||||
|
minimal={true}
|
||||||
|
intent={Intent.PRIMARY}
|
||||||
|
onClick={handleCanclel}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
</If>
|
||||||
</TransLockingActions>
|
</TransLockingActions>
|
||||||
</TransLockingInner>
|
</TransLockingInner>
|
||||||
</TransactionLockingWrapp>
|
</TransactionLockingWrapp>
|
||||||
|
|||||||
@@ -1618,5 +1618,8 @@
|
|||||||
"unlocking_partial_transactions.dialog.success_message": "Transactions locking haas been unlocked partially successfully.",
|
"unlocking_partial_transactions.dialog.success_message": "Transactions locking haas been unlocked partially successfully.",
|
||||||
"unlocking_full_transactions.dialog.label": "Full unlocking transactions",
|
"unlocking_full_transactions.dialog.label": "Full unlocking transactions",
|
||||||
"unlocking_full_transactions.dialog.reason": "Unlocking reason",
|
"unlocking_full_transactions.dialog.reason": "Unlocking reason",
|
||||||
"unlocking_full_transactions.dialog.success_message": "Partial transaction unlocking has been canceled successfully."
|
"unlocking_partial_transactions.alert.success_message": "Partial transaction unlocking has been canceled successfully.",
|
||||||
|
"unlocking_partial_transactions.alert.message": "Are you sure you want to cancel this ?"
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user