mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
feat(balance sheet): add branch multi select.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { MenuItem } from '@blueprintjs/core';
|
import { MenuItem } from '@blueprintjs/core';
|
||||||
import { MultiSelect as FMultiSelect } from 'blueprint-formik';
|
import { FMultiSelect } from '../Forms';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -17,7 +17,7 @@ const branchItemPredicate = (query, branch, _index, exactMatch) => {
|
|||||||
if (exactMatch) {
|
if (exactMatch) {
|
||||||
return normalizedTitle === normalizedQuery;
|
return normalizedTitle === normalizedQuery;
|
||||||
} else {
|
} else {
|
||||||
return `${branch.name}. ${normalizedTitle}`.indexOf(normalizedQuery) >= 0;
|
return `${branch.code}. ${normalizedTitle}`.indexOf(normalizedQuery) >= 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -32,17 +32,17 @@ const branchItemRenderer = (
|
|||||||
{ handleClick, modifiers, query },
|
{ handleClick, modifiers, query },
|
||||||
{ isSelected },
|
{ isSelected },
|
||||||
) => {
|
) => {
|
||||||
const text = `${branch.name}.${isSelected ? 'selected' : 'not-selected'}`;
|
// 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={modifiers.selected ? 'tick' : 'blank'}
|
icon={isSelected ? 'tick' : 'blank'}
|
||||||
|
text={branch.name.toString()}
|
||||||
label={branch.name.toString()}
|
label={branch.name.toString()}
|
||||||
key={branch.id}
|
key={branch.id}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
text={text}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -55,6 +55,11 @@ const branchSelectProps = {
|
|||||||
tagRenderer: (item) => item.name,
|
tagRenderer: (item) => item.name,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function BranchesMultiSelect({ branches, ...rest }) {
|
/**
|
||||||
|
* branches mulit select.
|
||||||
|
* @param {*} param0
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function BranchMultiSelect({ branches, ...rest }) {
|
||||||
return <FMultiSelect items={branches} {...branchSelectProps} {...rest} />;
|
return <FMultiSelect items={branches} {...branchSelectProps} {...rest} />;
|
||||||
}
|
}
|
||||||
@@ -1 +1,2 @@
|
|||||||
export * from './BranchSelect';
|
export * from './BranchSelect';
|
||||||
|
export * from './BranchMultiSelect'
|
||||||
@@ -1 +0,0 @@
|
|||||||
export * from './BranchesMultiSelect';
|
|
||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
Checkbox,
|
Checkbox,
|
||||||
RadioGroup,
|
RadioGroup,
|
||||||
Select,
|
Select,
|
||||||
|
MultiSelect
|
||||||
} from 'blueprint-formik';
|
} from 'blueprint-formik';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
@@ -14,4 +15,5 @@ export {
|
|||||||
Checkbox as FCheckbox,
|
Checkbox as FCheckbox,
|
||||||
RadioGroup as FRadioGroup,
|
RadioGroup as FRadioGroup,
|
||||||
Select as FSelect,
|
Select as FSelect,
|
||||||
|
MultiSelect as FMultiSelect
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -101,7 +101,6 @@ export * from './FeatureGuard';
|
|||||||
export * from './ExchangeRate';
|
export * from './ExchangeRate';
|
||||||
export * from './Branches';
|
export * from './Branches';
|
||||||
export * from './Warehouses';
|
export * from './Warehouses';
|
||||||
export * from './FMultiSelect'
|
|
||||||
|
|
||||||
const Hint = FieldHint;
|
const Hint = FieldHint;
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ function BalanceSheetHeader({
|
|||||||
/>
|
/>
|
||||||
<Tab
|
<Tab
|
||||||
id="dimensions"
|
id="dimensions"
|
||||||
title={'dimensions'}
|
title={'Dimensions'}
|
||||||
panel={<BalanceSheetHeaderDimensionsPanel />}
|
panel={<BalanceSheetHeaderDimensionsPanel />}
|
||||||
/>
|
/>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|||||||
@@ -1,24 +1,33 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Button } from '@blueprintjs/core';
|
import { FormGroup, Classes } from '@blueprintjs/core';
|
||||||
import { BranchesMultiSelect } from 'components';
|
import { BranchMultiSelect, FieldHint, Row, Col } from 'components';
|
||||||
|
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
||||||
import { useBranches } from 'hooks/query';
|
import { useBranches } from 'hooks/query';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Balance sheet header dismension panel.
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
function BalanceSheetHeaderDimensionsPanel() {
|
function BalanceSheetHeaderDimensionsPanel() {
|
||||||
// Fetches the branches list.
|
// Fetches the branches list.
|
||||||
const {
|
const { isLoading: isBranchesLoading, data: branches } = useBranches();
|
||||||
isLoading: isBranchesLoading,
|
|
||||||
isFetching: isBranchesFetching,
|
|
||||||
data: branches,
|
|
||||||
} = useBranches();
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<Row>
|
||||||
<BranchesMultiSelect
|
<Col xs={4}>
|
||||||
name={'branchesIds'}
|
<FormGroup
|
||||||
branches={branches}
|
label={'Branches'}
|
||||||
popoverProps={{ minimal: true }}
|
labelInfo={<FieldHint />}
|
||||||
/>
|
className={Classes.FILL}
|
||||||
</div>
|
>
|
||||||
|
<BranchMultiSelect
|
||||||
|
name={'branchesIds'}
|
||||||
|
branches={branches}
|
||||||
|
popoverProps={{ minimal: true }}
|
||||||
|
/>
|
||||||
|
</FormGroup>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user