fix(account-form): BIG-401 Edit account form initial values do not fill up automatically.

This commit is contained in:
a.bouhuolia
2023-01-26 22:11:26 +02:00
parent 21199c45fa
commit dc99b1f128
7 changed files with 34 additions and 16 deletions

View File

@@ -8,7 +8,9 @@ import * as R from 'ramda';
import { MenuItemNestedText, FormattedMessage as T } from '@/components';
import { nestedArrayToflatten, filterAccountsByQuery } from '@/utils';
import { CLASSES } from '@/constants/classes';
import { DialogsName } from '@/constants/dialogs';
import withDialogActions from '@/containers/Dialog/withDialogActions';
@@ -129,7 +131,7 @@ function AccountsSelectListRoot({
setSelectedAccount({ ...account });
onAccountSelected && onAccountSelected(account);
} else {
openDialog('account-form');
openDialog(DialogsName.AccountForm);
}
},
[setSelectedAccount, onAccountSelected, openDialog],

View File

@@ -7,6 +7,8 @@ import { MenuItem } from '@blueprintjs/core';
import { Suggest } from '@blueprintjs/select';
import { CLASSES } from '@/constants/classes';
import { DialogsName } from '@/constants/dialogs';
import { MenuItemNestedText, FormattedMessage as T } from '@/components';
import { nestedArrayToflatten, filterAccountsByQuery } from '@/utils';
@@ -134,7 +136,7 @@ function AccountsSuggestFieldRoot({
setSelectedAccount({ ...account });
onAccountSelected && onAccountSelected(account);
} else {
openDialog('account-form');
openDialog(DialogsName.AccountForm);
}
},
[setSelectedAccount, onAccountSelected, openDialog],

View File

@@ -24,8 +24,11 @@ import {
} from '@/components';
import { AccountAction, AbilitySubject } from '@/constants/abilityOption';
import { DialogsName } from '@/constants/dialogs';
import { useRefreshAccounts } from '@/hooks/query/accounts';
import { useAccountsChartContext } from './AccountsChartProvider';
import withAccounts from './withAccounts';
import withAccountsTableActions from './withAccountsTableActions';
import withDialogActions from '@/containers/Dialog/withDialogActions';
@@ -65,7 +68,7 @@ function AccountsActionsBar({
const { resourceViews, fields } = useAccountsChartContext();
const onClickNewAccount = () => {
openDialog('account-form', {});
openDialog(DialogsName.AccountForm, {});
};
// Accounts refresh action.

View File

@@ -8,13 +8,15 @@ import {
TableSkeletonHeader,
TableVirtualizedListRows,
} from '@/components';
import { TABLES } from '@/constants/tables';
import { useAccountsTableColumns, rowClassNames } from './utils';
import { ActionsMenu } from './components';
import { AccountDialogAction } from '@/containers/Dialogs/AccountDialog/utils';
import { useAccountsChartContext } from './AccountsChartProvider';
import { useMemorizedColumnsWidths } from '@/hooks';
import { AccountDialogAction } from '@/containers/Dialogs/AccountDialog/utils';
import { TABLES } from '@/constants/tables';
import { DialogsName } from '@/constants/dialogs';
import withSettings from '@/containers/Settings/withSettings';
import withAlertsActions from '@/containers/Alert/withAlertActions';
@@ -61,9 +63,9 @@ function AccountsDataTable({
// Handle edit account action.
const handleEditAccount = (account) => {
openDialog('account-form', {
openDialog(DialogsName.AccountForm, {
action: AccountDialogAction.Edit,
id: account.id,
accountId: account.id,
});
};
@@ -74,7 +76,7 @@ function AccountsDataTable({
// Handle new child button click.
const handleNewChildAccount = (account) => {
openDialog('account-form', {
openDialog(DialogsName.AccountForm, {
action: AccountDialogAction.NewChild,
parentAccountId: account.id,
accountType: account.account_type,

View File

@@ -21,7 +21,9 @@ import withDialogActions from '@/containers/Dialog/withDialogActions';
import withCashflowAccountsTableActions from '../AccountTransactions/withCashflowAccountsTableActions';
import { AccountDialogAction } from '@/containers/Dialogs/AccountDialog/utils';
import { ACCOUNT_TYPE } from '@/constants';
import { DialogsName } from '@/constants/dialogs';
import { compose } from '@/utils';
@@ -43,14 +45,14 @@ function CashFlowAccountsActionsBar({
};
// Handle add bank account.
const handleAddBankAccount = () => {
openDialog('account-form', {
openDialog(DialogsName.AccountForm, {
action: AccountDialogAction.NewDefinedType,
accountType: ACCOUNT_TYPE.CASH,
});
};
// Handle add cash account.
const handleAddCashAccount = () => {
openDialog('account-form', {
openDialog(DialogsName.AccountForm, {
action: AccountDialogAction.NewDefinedType,
accountType: ACCOUNT_TYPE.BANK,
});

View File

@@ -8,13 +8,15 @@ import { Link } from 'react-router-dom';
import { ContextMenu2 } from '@blueprintjs/popover2';
import { Menu, MenuItem, MenuDivider, Intent } from '@blueprintjs/core';
import { BankAccountsList, BankAccount, If, Icon, T, Can } from '@/components';
import {
AccountAction,
CashflowAction,
AbilitySubject,
} from '@/constants/abilityOption';
import { DialogsName } from '@/constants/dialogs';
import { addMoneyIn, addMoneyOut } from '@/constants/cashflowOptions';
import { BankAccountsList, BankAccount, If, Icon, T, Can } from '@/components';
import { useCashFlowAccountsContext } from './CashFlowAccountsProvider';
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
@@ -22,7 +24,7 @@ import withAlertsActions from '@/containers/Alert/withAlertActions';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import { safeCallback } from '@/utils';
import { addMoneyIn, addMoneyOut } from '@/constants/cashflowOptions';
import { AccountDialogAction } from '@/containers/Dialogs/AccountDialog/utils';
const CASHFLOW_SKELETON_N = 4;
@@ -74,7 +76,10 @@ function CashflowBankAccount({
};
// Handle edit account action.
const handleEditAccount = () => {
openDialog('account-form', { action: 'edit', id: account.id });
openDialog(DialogsName.AccountForm, {
action: AccountDialogAction.Edit,
id: account.id,
});
};
// Handle money in menu item actions.
const handleMoneyInClick = (transactionType) => {

View File

@@ -13,7 +13,9 @@ import {
Can,
FormattedMessage as T,
} from '@/components';
import { AccountAction, AbilitySubject } from '@/constants/abilityOption';
import { DialogsName } from '@/constants/dialogs';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import withAlertsActions from '@/containers/Alert/withAlertActions';
@@ -37,7 +39,7 @@ function AccountDrawerActionBar({
// Handle new child button click.
const onNewChildAccount = () => {
openDialog('account-form', {
openDialog(DialogsName.AccountForm, {
action: AccountDialogAction.NewChild,
parentAccountId: account.id,
accountType: account.account_type,
@@ -45,9 +47,9 @@ function AccountDrawerActionBar({
};
// Handle edit account action.
const onEditAccount = () => {
openDialog('account-form', {
openDialog(DialogsName.AccountForm, {
action: AccountDialogAction.Edit,
id: account.id,
accountId: account.id,
});
};
// Handle delete action account.