mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-22 07:40:32 +00:00
feat(cashflow & journal sheet): add branch multi select.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import intl from 'react-intl-universal';
|
||||||
import { MenuItem } from '@blueprintjs/core';
|
import { MenuItem } from '@blueprintjs/core';
|
||||||
import { FMultiSelect } from '../Forms';
|
import { FMultiSelect } from '../Forms';
|
||||||
|
|
||||||
@@ -32,15 +33,13 @@ const branchItemRenderer = (
|
|||||||
{ handleClick, modifiers, query },
|
{ handleClick, modifiers, query },
|
||||||
{ isSelected },
|
{ isSelected },
|
||||||
) => {
|
) => {
|
||||||
// const text = `${branch.name}.${isSelected ? 'selected' : 'not-selected'}`;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
active={modifiers.active}
|
active={modifiers.active}
|
||||||
disabled={modifiers.disabled}
|
disabled={modifiers.disabled}
|
||||||
icon={isSelected ? 'tick' : 'blank'}
|
icon={isSelected ? 'tick' : 'blank'}
|
||||||
text={branch.name.toString()}
|
text={branch.name.toString()}
|
||||||
label={branch.name.toString()}
|
label={branch.code.toString()}
|
||||||
key={branch.id}
|
key={branch.id}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
/>
|
/>
|
||||||
@@ -61,5 +60,13 @@ const branchSelectProps = {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function BranchMultiSelect({ branches, ...rest }) {
|
export function BranchMultiSelect({ branches, ...rest }) {
|
||||||
return <FMultiSelect items={branches} {...branchSelectProps} {...rest} />;
|
return (
|
||||||
|
<FMultiSelect
|
||||||
|
items={branches}
|
||||||
|
placeholder={intl.get('branches_multi_select.placeholder')}
|
||||||
|
popoverProps={{ minimal: true }}
|
||||||
|
{...branchSelectProps}
|
||||||
|
{...rest}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import intl from 'react-intl-universal';
|
||||||
import { FormGroup, Classes } from '@blueprintjs/core';
|
import { FormGroup, Classes } from '@blueprintjs/core';
|
||||||
import { BranchMultiSelect, FieldHint, Row, Col } from 'components';
|
import { BranchMultiSelect, Row, Col } from 'components';
|
||||||
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
||||||
import { useBranches } from 'hooks/query';
|
import { useBranches } from 'hooks/query';
|
||||||
|
|
||||||
@@ -16,15 +18,10 @@ function BalanceSheetHeaderDimensionsPanel() {
|
|||||||
<Row>
|
<Row>
|
||||||
<Col xs={4}>
|
<Col xs={4}>
|
||||||
<FormGroup
|
<FormGroup
|
||||||
label={'Branches'}
|
label={intl.get('branches_multi_select.label')}
|
||||||
labelInfo={<FieldHint />}
|
|
||||||
className={Classes.FILL}
|
className={Classes.FILL}
|
||||||
>
|
>
|
||||||
<BranchMultiSelect
|
<BranchMultiSelect name={'branchesIds'} branches={branches} />
|
||||||
name={'branchesIds'}
|
|
||||||
branches={branches}
|
|
||||||
popoverProps={{ minimal: true }}
|
|
||||||
/>
|
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
@@ -32,3 +29,9 @@ function BalanceSheetHeaderDimensionsPanel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default BalanceSheetHeaderDimensionsPanel;
|
export default BalanceSheetHeaderDimensionsPanel;
|
||||||
|
|
||||||
|
const BalanceMulitSelectRoot = styled.div`
|
||||||
|
.bp3-tag-input {
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import intl from 'react-intl-universal';
|
||||||
|
import { FormGroup, Classes } from '@blueprintjs/core';
|
||||||
|
import { BranchMultiSelect, Row, Col } from 'components';
|
||||||
|
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
||||||
|
import { useBranches } from 'hooks/query';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cash flow statement dismension panel.
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export default function CashFlowStatementDimensionsPanel() {
|
||||||
|
// Fetches the branches list.
|
||||||
|
const { isLoading: isBranchesLoading, data: branches } = useBranches();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Row>
|
||||||
|
<Col xs={4}>
|
||||||
|
<FormGroup
|
||||||
|
label={intl.get('branches_multi_select.label')}
|
||||||
|
className={Classes.FILL}
|
||||||
|
>
|
||||||
|
<BranchMultiSelect name={'branchesIds'} branches={branches} />
|
||||||
|
</FormGroup>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@ import withCashFlowStatementActions from './withCashFlowStatementActions';
|
|||||||
|
|
||||||
import { getDefaultCashFlowSheetQuery } from './utils';
|
import { getDefaultCashFlowSheetQuery } from './utils';
|
||||||
import { compose, transformToForm } from 'utils';
|
import { compose, transformToForm } from 'utils';
|
||||||
|
import CashFlowStatementDimensionsPanel from './CashFlowStatementDimensionsPanel';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cash flow statement header.
|
* Cash flow statement header.
|
||||||
@@ -33,18 +34,19 @@ function CashFlowStatementHeader({
|
|||||||
const defaultValues = getDefaultCashFlowSheetQuery();
|
const defaultValues = getDefaultCashFlowSheetQuery();
|
||||||
|
|
||||||
// Initial form values.
|
// Initial form values.
|
||||||
const initialValues = transformToForm({
|
const initialValues = transformToForm(
|
||||||
...pageFilter,
|
{
|
||||||
fromDate: moment(pageFilter.fromDate).toDate(),
|
...pageFilter,
|
||||||
toDate: moment(pageFilter.toDate).toDate(),
|
fromDate: moment(pageFilter.fromDate).toDate(),
|
||||||
}, defaultValues);
|
toDate: moment(pageFilter.toDate).toDate(),
|
||||||
|
},
|
||||||
|
defaultValues,
|
||||||
|
);
|
||||||
|
|
||||||
// Validation schema.
|
// Validation schema.
|
||||||
const validationSchema = Yup.object().shape({
|
const validationSchema = Yup.object().shape({
|
||||||
dateRange: Yup.string().optional(),
|
dateRange: Yup.string().optional(),
|
||||||
fromDate: Yup.date()
|
fromDate: Yup.date().required().label(intl.get('fromDate')),
|
||||||
.required()
|
|
||||||
.label(intl.get('fromDate')),
|
|
||||||
toDate: Yup.date()
|
toDate: Yup.date()
|
||||||
.min(Yup.ref('fromDate'))
|
.min(Yup.ref('fromDate'))
|
||||||
.required()
|
.required()
|
||||||
@@ -81,6 +83,11 @@ function CashFlowStatementHeader({
|
|||||||
title={<T id={'general'} />}
|
title={<T id={'general'} />}
|
||||||
panel={<CashFlowStatementGeneralPanel />}
|
panel={<CashFlowStatementGeneralPanel />}
|
||||||
/>
|
/>
|
||||||
|
<Tab
|
||||||
|
id="dimensions"
|
||||||
|
title={<T id={'dimensions'} />}
|
||||||
|
panel={<CashFlowStatementDimensionsPanel />}
|
||||||
|
/>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
<div class="financial-header-drawer__footer">
|
<div class="financial-header-drawer__footer">
|
||||||
|
|||||||
@@ -10,5 +10,6 @@ export const getDefaultCashFlowSheetQuery = () => {
|
|||||||
basis: 'cash',
|
basis: 'cash',
|
||||||
displayColumnsType: 'total',
|
displayColumnsType: 'total',
|
||||||
filterByOption: 'with-transactions',
|
filterByOption: 'with-transactions',
|
||||||
|
branchesIds: [],
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import withJournal from './withJournal';
|
|||||||
import withJournalActions from './withJournalActions';
|
import withJournalActions from './withJournalActions';
|
||||||
|
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
import JournalSheetHeaderDimension from './JournalSheetHeaderDimensions';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Journal sheet header.
|
* Journal sheet header.
|
||||||
@@ -71,6 +72,11 @@ function JournalHeader({
|
|||||||
title={<T id={'general'} />}
|
title={<T id={'general'} />}
|
||||||
panel={<JournalSheetHeaderGeneral />}
|
panel={<JournalSheetHeaderGeneral />}
|
||||||
/>
|
/>
|
||||||
|
<Tab
|
||||||
|
id="dimensions"
|
||||||
|
title={<T id={'dimensions'} />}
|
||||||
|
panel={<JournalSheetHeaderDimension />}
|
||||||
|
/>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
<div class="financial-header-drawer__footer">
|
<div class="financial-header-drawer__footer">
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import intl from 'react-intl-universal';
|
||||||
|
import { FormGroup, Classes } from '@blueprintjs/core';
|
||||||
|
import { BranchMultiSelect, Row, Col } from 'components';
|
||||||
|
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
||||||
|
import { useBranches } from 'hooks/query';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Journal sheet header dismension panel.
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export default function JournalSheetHeaderDimensions() {
|
||||||
|
// Fetches the branches list.
|
||||||
|
const { isLoading: isBranchesLoading, data: branches } = useBranches();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Row>
|
||||||
|
<Col xs={4}>
|
||||||
|
<FormGroup
|
||||||
|
label={intl.get('branches_multi_select.label')}
|
||||||
|
className={Classes.FILL}
|
||||||
|
>
|
||||||
|
<BranchMultiSelect name={'branchesIds'} branches={branches} />
|
||||||
|
</FormGroup>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -8,5 +8,6 @@ export const getDefaultJournalQuery = () => {
|
|||||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||||
basis: 'accural',
|
basis: 'accural',
|
||||||
}
|
branchesIds: [],
|
||||||
}
|
};
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user