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