feat: financial report numbers format dropdown.

This commit is contained in:
a.bouhuolia
2021-01-18 20:08:08 +02:00
parent 10ab8f4711
commit 1fb523b5ff
36 changed files with 550 additions and 373 deletions

View File

@@ -94,9 +94,19 @@ function ReceivableAgingSummarySheet({
[refreshARAgingSummary, toggleFilterARAgingSummary],
);
const handleNumberFormatSubmit = (numberFormat) => {
setQuery({
...query,
numberFormat
});
refreshARAgingSummary(true);
};
return (
<DashboardInsider>
<ARAgingSummaryActionsBar />
<ARAgingSummaryActionsBar
numberFormat={query.numberFormat}
onNumberFormatSubmit={handleNumberFormatSubmit}/>
<DashboardPageContent>
<FinancialStatement>

View File

@@ -13,11 +13,13 @@ import classNames from 'classnames';
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
import Icon from 'components/Icon';
import NumberFormatDropdown from 'components/NumberFormatDropdown';
import withARAgingSummary from './withARAgingSummary';
import withARAgingSummaryActions from './withARAgingSummaryActions';
import { compose } from 'utils';
import { safeInvoke } from '@blueprintjs/core/lib/esm/common/utils';
/**
* AR Aging summary sheet - Actions bar.
@@ -25,10 +27,15 @@ import { compose } from 'utils';
function ARAgingSummaryActionsBar({
// #withReceivableAging
receivableAgingFilter,
ARAgingSummaryLoading,
// #withReceivableAgingActions
toggleFilterARAgingSummary,
refreshARAgingSummary,
// #ownProps
numberFormat,
onNumberFormatSubmit,
}) {
const handleFilterToggleClick = () => {
toggleFilterARAgingSummary();
@@ -37,6 +44,10 @@ function ARAgingSummaryActionsBar({
const handleRecalcReport = () => {
refreshARAgingSummary(true);
};
// Handle number format submit.
const handleNumberFormatSubmit = (numberFormat) => {
safeInvoke(onNumberFormatSubmit, numberFormat);
};
return (
<DashboardActionsBar>
@@ -64,6 +75,25 @@ function ARAgingSummaryActionsBar({
/>
<NavbarDivider />
<Popover
content={
<NumberFormatDropdown
numberFormat={numberFormat}
onSubmit={handleNumberFormatSubmit}
submitDisabled={ARAgingSummaryLoading}
/>
}
minimal={true}
interactionKind={PopoverInteractionKind.CLICK}
position={Position.BOTTOM_LEFT}
>
<Button
className={classNames(Classes.MINIMAL, 'button--filter')}
text={<T id={'format'} />}
icon={<Icon icon="numbers" width={23} height={16} />}
/>
</Popover>
<Button
className={Classes.MINIMAL}
text={<T id={'filter'} />}
@@ -88,7 +118,7 @@ function ARAgingSummaryActionsBar({
export default compose(
withARAgingSummaryActions,
withARAgingSummary(({ receivableAgingSummaryFilter }) => ({
receivableAgingFilter: receivableAgingSummaryFilter,
withARAgingSummary(({ receivableAgingSummaryLoading }) => ({
ARAgingSummaryLoading: receivableAgingSummaryLoading,
})),
)(ARAgingSummaryActionsBar);

View File

@@ -1,5 +1,5 @@
import { mapKeys, snakeCase } from 'lodash';
import { transformToCamelCase, flatObject } from 'utils';
export const transfromFilterFormToQuery = (form) => {
return mapKeys(form, (v, k) => snakeCase(k));
return flatObject(transformToCamelCase(form));
};