feat: money in & out Hotkeys.
This commit is contained in:
@@ -3,11 +3,16 @@ import { useHotkeys } from 'react-hotkeys-hook';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { getDashboardRoutes } from 'routes/dashboard';
|
||||
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
function GlobalHotkeys({
|
||||
// #withDashboardActions
|
||||
toggleSidebarExpend,
|
||||
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
}) {
|
||||
const history = useHistory();
|
||||
const routes = getDashboardRoutes();
|
||||
@@ -16,8 +21,8 @@ function GlobalHotkeys({
|
||||
.filter(({ hotkey }) => hotkey)
|
||||
.map(({ hotkey }) => hotkey)
|
||||
.toString();
|
||||
|
||||
const handleSidebarToggleBtn = () => {
|
||||
|
||||
const handleSidebarToggleBtn = () => {
|
||||
toggleSidebarExpend();
|
||||
};
|
||||
useHotkeys(
|
||||
@@ -32,7 +37,9 @@ function GlobalHotkeys({
|
||||
[history],
|
||||
);
|
||||
useHotkeys('ctrl+/', (event, handle) => handleSidebarToggleBtn());
|
||||
useHotkeys('shift+q', (event, handle) => openDialog('money-in', {}));
|
||||
useHotkeys('shift+d', (event, handle) => openDialog('money-out', {}));
|
||||
return <div></div>;
|
||||
}
|
||||
|
||||
export default compose(withDashboardActions)(GlobalHotkeys);
|
||||
export default compose(withDashboardActions, withDialogActions)(GlobalHotkeys);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React from 'react';
|
||||
import { useFormikContext } from 'formik';
|
||||
import { Classes } from '@blueprintjs/core';
|
||||
|
||||
import { If } from 'components';
|
||||
@@ -11,15 +12,17 @@ import { useMoneyInDailogContext } from './MoneyInDialogProvider';
|
||||
* Money in form fields.
|
||||
*/
|
||||
function MoneyInFormFields() {
|
||||
const { values } = useFormikContext();
|
||||
|
||||
// Money in dialog context.
|
||||
const { accountId, accountType } = useMoneyInDailogContext();
|
||||
const { accountId } = useMoneyInDailogContext();
|
||||
|
||||
return (
|
||||
<div className={Classes.DIALOG_BODY}>
|
||||
<If condition={!accountId}>
|
||||
<TransactionTypeFields />
|
||||
</If>
|
||||
<MoneyInContentFields accountType={accountType} />
|
||||
<MoneyInContentFields accountType={values.transaction_type} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { FastField, ErrorMessage } from 'formik';
|
||||
import { FastField, Field, ErrorMessage } from 'formik';
|
||||
import { Classes, FormGroup } from '@blueprintjs/core';
|
||||
import classNames from 'classnames';
|
||||
import {
|
||||
@@ -32,7 +32,7 @@ export default function TransactionTypeFields() {
|
||||
<FastField name={'cashflow_account_id'}>
|
||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||
<FormGroup
|
||||
label={'Current account'}
|
||||
label={<T id={'cash_flow_transaction.label_current_account'} />}
|
||||
labelInfo={<FieldRequiredHint />}
|
||||
intent={inputIntent({ error, touched })}
|
||||
helperText={<ErrorMessage name="cashflow_account_id" />}
|
||||
@@ -57,7 +57,7 @@ export default function TransactionTypeFields() {
|
||||
{/*------------ Transaction type -----------*/}
|
||||
</Col>
|
||||
<Col xs={5}>
|
||||
<FastField name={'transaction_type'}>
|
||||
<Field name={'transaction_type'}>
|
||||
{({
|
||||
form: { values, setFieldValue },
|
||||
field: { value },
|
||||
@@ -86,7 +86,7 @@ export default function TransactionTypeFields() {
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
</Field>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
|
||||
@@ -2,6 +2,7 @@ import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Dialog, DialogSuspense } from 'components';
|
||||
import withDialogRedux from 'components/DialogReduxConnect';
|
||||
|
||||
import { compose } from 'redux';
|
||||
|
||||
const MoneyInDialogContent = React.lazy(() => import('./MoneyInDialogContent'));
|
||||
@@ -14,6 +15,7 @@ function MoneyInDialog({
|
||||
payload = { account_type: null, account_id: null },
|
||||
isOpen,
|
||||
}) {
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
name={dialogName}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React from 'react';
|
||||
import { useFormikContext } from 'formik';
|
||||
import { Classes } from '@blueprintjs/core';
|
||||
|
||||
import { If } from 'components';
|
||||
@@ -12,14 +13,15 @@ import { useMoneyOutDialogContext } from './MoneyOutDialogProvider';
|
||||
*/
|
||||
function MoneyOutFormFields() {
|
||||
// Money in dialog context.
|
||||
const { accountId, accountType } = useMoneyOutDialogContext();
|
||||
const { accountId } = useMoneyOutDialogContext();
|
||||
|
||||
const { values } = useFormikContext();
|
||||
return (
|
||||
<div className={Classes.DIALOG_BODY}>
|
||||
<If condition={!accountId}>
|
||||
<TransactionTypeFields />
|
||||
</If>
|
||||
<MoneyOutContentFields accountType={accountType} />
|
||||
<MoneyOutContentFields accountType={values.transaction_type} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { FastField, ErrorMessage } from 'formik';
|
||||
import { FastField, Field, ErrorMessage } from 'formik';
|
||||
import { FormGroup } from '@blueprintjs/core';
|
||||
import classNames from 'classnames';
|
||||
import {
|
||||
@@ -32,7 +32,7 @@ function TransactionTypeFields() {
|
||||
<FastField name={'cashflow_account_id'}>
|
||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||
<FormGroup
|
||||
label={'Current account'}
|
||||
label={<T id={'cash_flow_transaction.label_current_account'} />}
|
||||
labelInfo={<FieldRequiredHint />}
|
||||
intent={inputIntent({ error, touched })}
|
||||
helperText={<ErrorMessage name="cashflow_account_id" />}
|
||||
@@ -57,7 +57,7 @@ function TransactionTypeFields() {
|
||||
{/*------------ Transaction type -----------*/}
|
||||
</Col>
|
||||
<Col xs={5}>
|
||||
<FastField name={'transaction_type'}>
|
||||
<Field name={'transaction_type'}>
|
||||
{({
|
||||
form: { values, setFieldValue },
|
||||
field: { value },
|
||||
@@ -86,7 +86,7 @@ function TransactionTypeFields() {
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
</Field>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
|
||||
@@ -1388,7 +1388,8 @@
|
||||
"cash_flow_transaction.other_expense_account":"Other expense account",
|
||||
"save_and_publish": "Save & Publish",
|
||||
"cash_flow_transaction.label_transfer_from_account":"Transfer from account",
|
||||
"cash_flow_transaction.label_transfer_to_account":"Transfer to account"
|
||||
"cash_flow_transaction.label_transfer_to_account":"Transfer to account",
|
||||
"cash_flow_transaction.label_current_account":"Current account"
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user