fix(FinancialStatements): Hide filtering by branches/warehouses if the feature is not enabled.

This commit is contained in:
a.bouhuolia
2023-01-23 22:52:45 +02:00
parent 49f3465265
commit 806e4fb54c
21 changed files with 298 additions and 149 deletions

View File

@@ -71,7 +71,6 @@ function CashFlowAccountsActionsBar({
text={<T id={'cash_flow.label.add_cash_account'} />} text={<T id={'cash_flow.label.add_cash_account'} />}
onClick={handleAddBankAccount} onClick={handleAddBankAccount}
/> />
<Button <Button
className={Classes.MINIMAL} className={Classes.MINIMAL}
icon={<Icon icon={'plus-24'} iconSize={20} />} icon={<Icon icon={'plus-24'} iconSize={20} />}

View File

@@ -15,6 +15,8 @@ import withAPAgingSummary from './withAPAgingSummary';
import withAPAgingSummaryActions from './withAPAgingSummaryActions'; import withAPAgingSummaryActions from './withAPAgingSummaryActions';
import { transformToForm, compose } from '@/utils'; import { transformToForm, compose } from '@/utils';
import { useFeatureCan } from '@/hooks/state';
import { Features } from '@/constants';
/** /**
* AP Aging Summary Report - Drawer Header. * AP Aging Summary Report - Drawer Header.
@@ -68,11 +70,14 @@ function APAgingSummaryHeader({
const handleCancelClick = () => { const handleCancelClick = () => {
toggleFilterDrawerDisplay(false); toggleFilterDrawerDisplay(false);
}; };
// Handle the drawer closing. // Handle the drawer closing.
const handleDrawerClose = () => { const handleDrawerClose = () => {
toggleFilterDrawerDisplay(false); toggleFilterDrawerDisplay(false);
}; };
// Detarmines the feature whether is enabled.
const { featureCan } = useFeatureCan();
const isBranchesFeatureCan = featureCan(Features.Branches);
return ( return (
<APAgingDrawerHeader <APAgingDrawerHeader
@@ -91,11 +96,13 @@ function APAgingSummaryHeader({
title={<T id={'general'} />} title={<T id={'general'} />}
panel={<APAgingSummaryHeaderGeneral />} panel={<APAgingSummaryHeaderGeneral />}
/> />
<Tab {isBranchesFeatureCan && (
id="dimensions" <Tab
title={<T id={'dimensions'} />} id="dimensions"
panel={<APAgingSummaryHeaderDimensions />} title={<T id={'dimensions'} />}
/> panel={<APAgingSummaryHeaderDimensions />}
/>
)}
</Tabs> </Tabs>
<div className={'financial-header-drawer__footer'}> <div className={'financial-header-drawer__footer'}>
<Button className={'mr1'} intent={Intent.PRIMARY} type={'submit'}> <Button className={'mr1'} intent={Intent.PRIMARY} type={'submit'}>

View File

@@ -7,6 +7,8 @@ import {
APAgingSummaryHeaderDimensionsProvider, APAgingSummaryHeaderDimensionsProvider,
useAPAgingSummaryHeaderDimensonsContext, useAPAgingSummaryHeaderDimensonsContext,
} from './APAgingSummaryHeaderDimensionsProvider'; } from './APAgingSummaryHeaderDimensionsProvider';
import { useFeatureCan } from '@/hooks/state';
import { Features } from '@/constants';
/** /**
* APAging summary header dimensions. * APAging summary header dimensions.
@@ -27,15 +29,22 @@ export default function APAgingSummaryHeaderDimensions() {
function APAgingSummaryHeaderDimensionsContent() { function APAgingSummaryHeaderDimensionsContent() {
const { branches } = useAPAgingSummaryHeaderDimensonsContext(); const { branches } = useAPAgingSummaryHeaderDimensonsContext();
// Detarmines the feature whether is enabled.
const { featureCan } = useFeatureCan();
const isBranchesFeatureCan = featureCan(Features.Branches);
return ( return (
<Row> <Row>
<Col xs={4}> <Col xs={4}>
<FormGroup {isBranchesFeatureCan && (
label={intl.get('branches_multi_select.label')} <FormGroup
className={Classes.FILL} label={intl.get('branches_multi_select.label')}
> className={Classes.FILL}
<BranchMultiSelect name={'branchesIds'} branches={branches} /> >
</FormGroup> <BranchMultiSelect name={'branchesIds'} branches={branches} />
</FormGroup>
)}
</Col> </Col>
</Row> </Row>
); );

View File

@@ -15,6 +15,8 @@ import withARAgingSummary from './withARAgingSummary';
import withARAgingSummaryActions from './withARAgingSummaryActions'; import withARAgingSummaryActions from './withARAgingSummaryActions';
import { compose, transformToForm } from '@/utils'; import { compose, transformToForm } from '@/utils';
import { useFeatureCan } from '@/hooks/state';
import { Features } from '@/constants';
/** /**
* AR Aging Summary Report - Drawer Header. * AR Aging Summary Report - Drawer Header.
@@ -76,6 +78,10 @@ function ARAgingSummaryHeader({
const handleDrawerClose = () => { const handleDrawerClose = () => {
toggleFilterDrawerDisplay(false); toggleFilterDrawerDisplay(false);
}; };
// Detarmines the feature whether is enabled.
const { featureCan } = useFeatureCan();
const isBranchesFeatureCan = featureCan(Features.Branches);
return ( return (
<ARAgingDrawerHeader <ARAgingDrawerHeader
@@ -94,11 +100,13 @@ function ARAgingSummaryHeader({
title={<T id={'general'} />} title={<T id={'general'} />}
panel={<ARAgingSummaryHeaderGeneral />} panel={<ARAgingSummaryHeaderGeneral />}
/> />
<Tab {isBranchesFeatureCan && (
id="dimensions" <Tab
title={<T id={'dimensions'} />} id="dimensions"
panel={<ARAgingSummaryHeaderDimensions />} title={<T id={'dimensions'} />}
/> panel={<ARAgingSummaryHeaderDimensions />}
/>
)}
</Tabs> </Tabs>
<div class="financial-header-drawer__footer"> <div class="financial-header-drawer__footer">

View File

@@ -10,7 +10,7 @@ import {
/** /**
* ARAging summary header dimensions. * ARAging summary header dimensions.
* @returns * @returns {JSX.Element}
*/ */
export default function ARAgingSummaryHeaderDimensions() { export default function ARAgingSummaryHeaderDimensions() {
return ( return (
@@ -22,20 +22,27 @@ export default function ARAgingSummaryHeaderDimensions() {
/** /**
* ARAging summary header dimensions content. * ARAging summary header dimensions content.
* @returns * @returns {JSX.Element}
*/ */
function ARAgingSummaryHeaderDimensionsContent() { function ARAgingSummaryHeaderDimensionsContent() {
const { branches } = useARAgingSummaryHeaderDimensonsContext(); const { branches } = useARAgingSummaryHeaderDimensonsContext();
// Detarmines the feature whether is enabled.
const { featureCan } = useFeatureCan();
const isBranchesFeatureCan = featureCan(Features.Branches);
return ( return (
<Row> <Row>
<Col xs={4}> <Col xs={4}>
<FormGroup {isBranchesFeatureCan && (
label={intl.get('branches_multi_select.label')} <FormGroup
className={Classes.FILL} label={intl.get('branches_multi_select.label')}
> className={Classes.FILL}
<BranchMultiSelect name={'branchesIds'} branches={branches} /> >
</FormGroup> <BranchMultiSelect name={'branchesIds'} branches={branches} />
</FormGroup>
)}
</Col> </Col>
</Row> </Row>
); );

View File

@@ -6,6 +6,8 @@ import { Tabs, Tab, Button, Intent } from '@blueprintjs/core';
import { Formik, Form } from 'formik'; import { Formik, Form } from 'formik';
import { FormattedMessage as T } from '@/components'; import { FormattedMessage as T } from '@/components';
import { useFeatureCan } from '@/hooks/state';
import { Features } from '@/constants';
import withBalanceSheet from './withBalanceSheet'; import withBalanceSheet from './withBalanceSheet';
import withBalanceSheetActions from './withBalanceSheetActions'; import withBalanceSheetActions from './withBalanceSheetActions';
@@ -56,16 +58,18 @@ function BalanceSheetHeader({
toggleFilterDrawer(false); toggleFilterDrawer(false);
actions.setSubmitting(false); actions.setSubmitting(false);
}; };
// Handle cancel button click. // Handle cancel button click.
const handleCancelClick = () => { const handleCancelClick = () => {
toggleFilterDrawer(false); toggleFilterDrawer(false);
}; };
// Handle drawer close action. // Handle drawer close action.
const handleDrawerClose = () => { const handleDrawerClose = () => {
toggleFilterDrawer(false); toggleFilterDrawer(false);
}; };
// Detarmines the given feature whether is enabled.
const { featureCan } = useFeatureCan();
const isBranchesFeatureCan = featureCan(Features.Branches);
return ( return (
<BalanceSheetFinancialHeader <BalanceSheetFinancialHeader
@@ -91,11 +95,13 @@ function BalanceSheetHeader({
title={<T id={'balance_sheet.comparisons'} />} title={<T id={'balance_sheet.comparisons'} />}
panel={<BalanceSheetHeaderComparisonPanal />} panel={<BalanceSheetHeaderComparisonPanal />}
/> />
<Tab {isBranchesFeatureCan && (
id="dimensions" <Tab
title={<T id={'balance_sheet.dimensions'} />} id="dimensions"
panel={<BalanceSheetHeaderDimensionsPanel />} title={<T id={'balance_sheet.dimensions'} />}
/> panel={<BalanceSheetHeaderDimensionsPanel />}
/>
)}
</Tabs> </Tabs>
<div class="financial-header-drawer__footer"> <div class="financial-header-drawer__footer">

View File

@@ -7,6 +7,8 @@ import {
BalanceSheetHeaderDimensionsProvider, BalanceSheetHeaderDimensionsProvider,
useBalanceSheetHeaderDimensionsPanelContext, useBalanceSheetHeaderDimensionsPanelContext,
} from './BalanceSheetHeaderDimensionsProvider'; } from './BalanceSheetHeaderDimensionsProvider';
import { Features } from '@/constants';
import { useFeatureCan } from '@/hooks/state';
/** /**
* Balance sheet header dismension panel. * Balance sheet header dismension panel.
@@ -26,16 +28,21 @@ export default function BalanceSheetHeaderDimensionsPanel() {
*/ */
function BalanceSheetHeaderDimensionsPanelContent() { function BalanceSheetHeaderDimensionsPanelContent() {
const { branches } = useBalanceSheetHeaderDimensionsPanelContext(); const { branches } = useBalanceSheetHeaderDimensionsPanelContext();
const { featureCan } = useFeatureCan();
const isBranchesFeatureCan = featureCan(Features.Branches);
return ( return (
<Row> <Row>
<Col xs={4}> <Col xs={4}>
<FormGroup {isBranchesFeatureCan && (
label={intl.get('branches_multi_select.label')} <FormGroup
className={Classes.FILL} label={intl.get('branches_multi_select.label')}
> className={Classes.FILL}
<BranchMultiSelect name={'branchesIds'} branches={branches} /> >
</FormGroup> <BranchMultiSelect name={'branchesIds'} branches={branches} />
</FormGroup>
)}
</Col> </Col>
</Row> </Row>
); );

View File

@@ -7,6 +7,8 @@ import {
CashFlowStatementDimensionsPanelProvider, CashFlowStatementDimensionsPanelProvider,
useCashFlowStatementDimensionsPanelContext, useCashFlowStatementDimensionsPanelContext,
} from './CashFlowStatementDimensionsPanelProvider'; } from './CashFlowStatementDimensionsPanelProvider';
import { useFeatureCan } from '@/hooks/state';
import { Features } from '@/constants';
/** /**
* Cash flow statement dismension panel. * Cash flow statement dismension panel.
@@ -28,15 +30,21 @@ function CashFlowStatementDimensionsPanelContent() {
// Fetches the branches list. // Fetches the branches list.
const { branches } = useCashFlowStatementDimensionsPanelContext(); const { branches } = useCashFlowStatementDimensionsPanelContext();
const { featureCan } = useFeatureCan();
const isBranchesFeatureCan = featureCan(Features.Branches);
return ( return (
<Row> <Row>
<Col xs={4}> <Col xs={4}>
<FormGroup {isBranchesFeatureCan && (
label={intl.get('branches_multi_select.label')} <FormGroup
className={Classes.FILL} label={intl.get('branches_multi_select.label')}
> className={Classes.FILL}
<BranchMultiSelect name={'branchesIds'} branches={branches} /> >
</FormGroup> <BranchMultiSelect name={'branchesIds'} branches={branches} />
</FormGroup>
)}
</Col> </Col>
</Row> </Row>
); );

View File

@@ -16,6 +16,8 @@ import withCashFlowStatementActions from './withCashFlowStatementActions';
import { getDefaultCashFlowSheetQuery } from './utils'; import { getDefaultCashFlowSheetQuery } from './utils';
import { compose, transformToForm } from '@/utils'; import { compose, transformToForm } from '@/utils';
import { useFeatureCan } from '@/hooks/state';
import { Features } from '@/constants';
/** /**
* Cash flow statement header. * Cash flow statement header.
@@ -43,7 +45,6 @@ function CashFlowStatementHeader({
}, },
defaultValues, defaultValues,
); );
// Validation schema. // Validation schema.
const validationSchema = Yup.object().shape({ const validationSchema = Yup.object().shape({
dateRange: Yup.string().optional(), dateRange: Yup.string().optional(),
@@ -67,6 +68,10 @@ function CashFlowStatementHeader({
toggleCashFlowStatementFilterDrawer(false); toggleCashFlowStatementFilterDrawer(false);
}; };
const { featureCan } = useFeatureCan();
const isBranchesFeatureCan = featureCan(Features.Branches);
return ( return (
<FinancialStatementHeader <FinancialStatementHeader
isOpen={isFilterDrawerOpen} isOpen={isFilterDrawerOpen}
@@ -84,11 +89,13 @@ function CashFlowStatementHeader({
title={<T id={'general'} />} title={<T id={'general'} />}
panel={<CashFlowStatementGeneralPanel />} panel={<CashFlowStatementGeneralPanel />}
/> />
<Tab {isBranchesFeatureCan && (
id="dimensions" <Tab
title={<T id={'dimensions'} />} id="dimensions"
panel={<CashFlowStatementDimensionsPanel />} title={<T id={'dimensions'} />}
/> panel={<CashFlowStatementDimensionsPanel />}
/>
)}
</Tabs> </Tabs>
<div class="financial-header-drawer__footer"> <div class="financial-header-drawer__footer">

View File

@@ -13,16 +13,18 @@ import { ListSelect, MODIFIER, FormattedMessage as T } from '@/components';
import { CLASSES } from '@/constants/classes'; import { CLASSES } from '@/constants/classes';
import { filterAccountsOptions } from './constants'; import { filterAccountsOptions } from './constants';
const SUBMENU_POPOVER_MODIFIERS = {
flip: { boundariesElement: 'viewport', padding: 20 },
offset: { offset: '0, 10' },
preventOverflow: { boundariesElement: 'viewport', padding: 40 },
};
export default function FinancialStatementsFilter({ export default function FinancialStatementsFilter({
items = filterAccountsOptions, items = filterAccountsOptions,
label = <T id={'filter_accounts'} />, label = <T id={'filter_accounts'} />,
...restProps ...restProps
}) { }) {
const SUBMENU_POPOVER_MODIFIERS = {
flip: { boundariesElement: 'viewport', padding: 20 },
offset: { offset: '0, 10' },
preventOverflow: { boundariesElement: 'viewport', padding: 40 },
};
const filterRenderer = (item, { handleClick, modifiers, query }) => { const filterRenderer = (item, { handleClick, modifiers, query }) => {
return ( return (

View File

@@ -16,6 +16,8 @@ import GeneralLedgerHeaderDimensionsPanel from './GeneralLedgerHeaderDimensionsP
import withGeneralLedger from './withGeneralLedger'; import withGeneralLedger from './withGeneralLedger';
import withGeneralLedgerActions from './withGeneralLedgerActions'; import withGeneralLedgerActions from './withGeneralLedgerActions';
import { useFeatureCan } from '@/hooks/state';
import { Features } from '@/constants';
/** /**
* Geenral Ledger (GL) - Header. * Geenral Ledger (GL) - Header.
@@ -63,6 +65,10 @@ function GeneralLedgerHeader({
const handleDrawerClose = () => { const handleDrawerClose = () => {
toggleDisplayFilterDrawer(false); toggleDisplayFilterDrawer(false);
}; };
// Detarmines the feature whether is enabled.
const { featureCan } = useFeatureCan();
const isBranchesFeatureCan = featureCan(Features.Branches);
return ( return (
<GeneralLedgerDrawerHeader <GeneralLedgerDrawerHeader
@@ -81,11 +87,13 @@ function GeneralLedgerHeader({
title={<T id={'general'} />} title={<T id={'general'} />}
panel={<GeneralLedgerHeaderGeneralPane />} panel={<GeneralLedgerHeaderGeneralPane />}
/> />
<Tab {isBranchesFeatureCan && (
id="dimensions" <Tab
title={<T id={'dimensions'} />} id="dimensions"
panel={<GeneralLedgerHeaderDimensionsPanel />} title={<T id={'dimensions'} />}
/> panel={<GeneralLedgerHeaderDimensionsPanel />}
/>
)}
</Tabs> </Tabs>
<div class="financial-header-drawer__footer"> <div class="financial-header-drawer__footer">

View File

@@ -7,6 +7,8 @@ import {
GeneralLedgerHeaderDimensionsPanelProvider, GeneralLedgerHeaderDimensionsPanelProvider,
useGeneralLedgerHeaderDimensionsContext, useGeneralLedgerHeaderDimensionsContext,
} from './GeneralLedgerHeaderDimensionsPanelProvider'; } from './GeneralLedgerHeaderDimensionsPanelProvider';
import { useFeatureCan } from '@/hooks/state';
import { Features } from '@/constants';
/** /**
* Gereral ledger sheet header dismension panel. * Gereral ledger sheet header dismension panel.
@@ -27,15 +29,22 @@ export default function GeneralLedgerHeaderDimensionsPanel() {
function GeneralLedgerHeaderDimensionsPanelContent() { function GeneralLedgerHeaderDimensionsPanelContent() {
const { branches } = useGeneralLedgerHeaderDimensionsContext(); const { branches } = useGeneralLedgerHeaderDimensionsContext();
// Detarmines the feature whether is enabled.
const { featureCan } = useFeatureCan();
const isBranchesFeatureCan = featureCan(Features.Branches);
return ( return (
<Row> <Row>
<Col xs={4}> <Col xs={4}>
<FormGroup {isBranchesFeatureCan && (
label={intl.get('branches_multi_select.label')} <FormGroup
className={Classes.FILL} label={intl.get('branches_multi_select.label')}
> className={Classes.FILL}
<BranchMultiSelect name={'branchesIds'} branches={branches} /> >
</FormGroup> <BranchMultiSelect name={'branchesIds'} branches={branches} />
</FormGroup>
)}
</Col> </Col>
</Row> </Row>
); );

View File

@@ -18,6 +18,8 @@ import withInventoryItemDetailsActions from './withInventoryItemDetailsActions';
import { getInventoryItemDetailsDefaultQuery } from './utils2'; import { getInventoryItemDetailsDefaultQuery } from './utils2';
import { compose, transformToForm } from '@/utils'; import { compose, transformToForm } from '@/utils';
import { useFeatureCan } from '@/hooks/state';
import { Features } from '@/constants';
/** /**
* Inventory item details header. * Inventory item details header.
@@ -58,11 +60,15 @@ function InventoryItemDetailsHeader({
toggleFilterDrawer(false); toggleFilterDrawer(false);
setSubmitting(false); setSubmitting(false);
}; };
// Handle drawer close action. // Handle drawer close action.
const handleDrawerClose = () => { const handleDrawerClose = () => {
toggleFilterDrawer(false); toggleFilterDrawer(false);
}; };
// Detarmines the given feature whether is enabled.
const { featureCan } = useFeatureCan();
const isBranchesFeatureCan = featureCan(Features.Branches);
const isWarehousesFeatureCan = featureCan(Features.Warehouses);
return ( return (
<InventoryItemDetailsDrawerHeader <InventoryItemDetailsDrawerHeader
@@ -81,11 +87,13 @@ function InventoryItemDetailsHeader({
title={<T id={'general'} />} title={<T id={'general'} />}
panel={<InventoryItemDetailsHeaderGeneralPanel />} panel={<InventoryItemDetailsHeaderGeneralPanel />}
/> />
<Tab {(isBranchesFeatureCan || isWarehousesFeatureCan) && (
id="dimensions" <Tab
title={<T id={'dimensions'} />} id="dimensions"
panel={<InventoryItemDetailsHeaderDimensionsPanel />} title={<T id={'dimensions'} />}
/> panel={<InventoryItemDetailsHeaderDimensionsPanel />}
/>
)}
</Tabs> </Tabs>
<div class="financial-header-drawer__footer"> <div class="financial-header-drawer__footer">
<Button className={'mr1'} intent={Intent.PRIMARY} type={'submit'}> <Button className={'mr1'} intent={Intent.PRIMARY} type={'submit'}>

View File

@@ -2,7 +2,12 @@
import React from 'react'; import React from 'react';
import intl from 'react-intl-universal'; import intl from 'react-intl-universal';
import { FormGroup, Classes } from '@blueprintjs/core'; import { FormGroup, Classes } from '@blueprintjs/core';
import { BranchMultiSelect, WarehouseMultiSelect, Row, Col } from '@/components'; import {
BranchMultiSelect,
WarehouseMultiSelect,
Row,
Col,
} from '@/components';
import { import {
InventoryItemDetailsHeaderDimensionsProvider, InventoryItemDetailsHeaderDimensionsProvider,
useInventoryItemDetailsHeaderDimensionsPanelContext, useInventoryItemDetailsHeaderDimensionsPanelContext,
@@ -10,7 +15,7 @@ import {
/** /**
* Inventory Item deatil header dismension panel. * Inventory Item deatil header dismension panel.
* @returns * @returns {JSX.Element}
*/ */
export default function InventoryItemDetailsHeaderDimensionsPanel() { export default function InventoryItemDetailsHeaderDimensionsPanel() {
return ( return (
@@ -22,31 +27,40 @@ export default function InventoryItemDetailsHeaderDimensionsPanel() {
/** /**
* Inventory Valuation header dismension panel content. * Inventory Valuation header dismension panel content.
* @returns * @returns {JSX.Element}
*/ */
function InventoryItemDetailsHeaderDimensionsPanelContent() { function InventoryItemDetailsHeaderDimensionsPanelContent() {
const { warehouses, branches } = const { warehouses, branches } =
useInventoryItemDetailsHeaderDimensionsPanelContext(); useInventoryItemDetailsHeaderDimensionsPanelContext();
// Detarmines the given feature whether is enabled.
const { featureCan } = useFeatureCan();
const isBranchesFeatureCan = featureCan(Features.Branches);
const isWarehousesFeatureCan = featureCan(Features.warehouses);
return ( return (
<Row> <Row>
<Col xs={4}> <Col xs={4}>
<FormGroup {isBranchesFeatureCan && (
label={intl.get('branches_multi_select.label')} <FormGroup
className={Classes.FILL} label={intl.get('branches_multi_select.label')}
> className={Classes.FILL}
<BranchMultiSelect name={'branchesIds'} branches={branches} /> >
</FormGroup> <BranchMultiSelect name={'branchesIds'} branches={branches} />
</FormGroup>
<FormGroup )}
label={intl.get('warehouses_multi_select.label')} {isWarehousesFeatureCan && (
className={Classes.FILL} <FormGroup
> label={intl.get('warehouses_multi_select.label')}
<WarehouseMultiSelect className={Classes.FILL}
name={'warehousesIds'} >
warehouses={warehouses} <WarehouseMultiSelect
/> name={'warehousesIds'}
</FormGroup> warehouses={warehouses}
/>
</FormGroup>
)}
</Col> </Col>
</Row> </Row>
); );

View File

@@ -15,6 +15,8 @@ import withInventoryValuation from './withInventoryValuation';
import withInventoryValuationActions from './withInventoryValuationActions'; import withInventoryValuationActions from './withInventoryValuationActions';
import { compose, transformToForm } from '@/utils'; import { compose, transformToForm } from '@/utils';
import { useFeatureCan } from '@/hooks/state';
import { Features } from '@/constants';
/** /**
* inventory valuation header. * inventory valuation header.
@@ -58,16 +60,19 @@ function InventoryValuationHeader({
toggleInventoryValuationFilterDrawer(false); toggleInventoryValuationFilterDrawer(false);
setSubmitting(false); setSubmitting(false);
}; };
// Handle drawer close action. // Handle drawer close action.
const handleDrawerClose = () => { const handleDrawerClose = () => {
toggleInventoryValuationFilterDrawer(false); toggleInventoryValuationFilterDrawer(false);
}; };
// Handle cancel button click. // Handle cancel button click.
const handleCancelClick = () => { const handleCancelClick = () => {
toggleInventoryValuationFilterDrawer(false); toggleInventoryValuationFilterDrawer(false);
}; };
// Detarmines the given feature whether is enabled.
const { featureCan } = useFeatureCan();
const isBranchesFeatureCan = featureCan(Features.Branches);
const isWarehousesFeatureCan = featureCan(Features.Warehouses);
return ( return (
<InventoryValuationDrawerHeader <InventoryValuationDrawerHeader
@@ -86,11 +91,13 @@ function InventoryValuationHeader({
title={<T id={'general'} />} title={<T id={'general'} />}
panel={<InventoryValuationHeaderGeneralPanel />} panel={<InventoryValuationHeaderGeneralPanel />}
/> />
<Tab {(isBranchesFeatureCan || isWarehousesFeatureCan) && (
id="dimensions" <Tab
title={<T id={'dimensions'} />} id="dimensions"
panel={<InventoryValuationHeaderDimensionsPanel />} title={<T id={'dimensions'} />}
/> panel={<InventoryValuationHeaderDimensionsPanel />}
/>
)}
</Tabs> </Tabs>
<div class="financial-header-drawer__footer"> <div class="financial-header-drawer__footer">
<Button className={'mr1'} intent={Intent.PRIMARY} type={'submit'}> <Button className={'mr1'} intent={Intent.PRIMARY} type={'submit'}>

View File

@@ -2,11 +2,18 @@
import React from 'react'; import React from 'react';
import intl from 'react-intl-universal'; import intl from 'react-intl-universal';
import { FormGroup, Classes } from '@blueprintjs/core'; import { FormGroup, Classes } from '@blueprintjs/core';
import { BranchMultiSelect, WarehouseMultiSelect, Row, Col } from '@/components'; import {
BranchMultiSelect,
WarehouseMultiSelect,
Row,
Col,
} from '@/components';
import { import {
InventoryValuationHeaderDimensionsProvider, InventoryValuationHeaderDimensionsProvider,
useInventoryValuationHeaderDimensionsPanelContext, useInventoryValuationHeaderDimensionsPanelContext,
} from './InventoryValuationHeaderDimensionsPanelProvider'; } from './InventoryValuationHeaderDimensionsPanelProvider';
import { useFeatureCan } from '@/hooks/state';
import { Features } from '@/constants';
/** /**
* Inventory Valuation header dismension panel. * Inventory Valuation header dismension panel.
@@ -28,25 +35,34 @@ function InventoryValuationHeaderDimensionsPanelContent() {
const { warehouses, branches } = const { warehouses, branches } =
useInventoryValuationHeaderDimensionsPanelContext(); useInventoryValuationHeaderDimensionsPanelContext();
// Detarmines the given feature whether is enabled.
const { featureCan } = useFeatureCan();
const isBranchesFeatureCan = featureCan(Features.Branches);
const isWarehousesFeatureCan = featureCan(Features.Warehouses);
return ( return (
<Row> <Row>
<Col xs={4}> <Col xs={4}>
<FormGroup {isBranchesFeatureCan && (
label={intl.get('branches_multi_select.label')} <FormGroup
className={Classes.FILL} label={intl.get('branches_multi_select.label')}
> className={Classes.FILL}
<BranchMultiSelect name={'branchesIds'} branches={branches} /> >
</FormGroup> <BranchMultiSelect name={'branchesIds'} branches={branches} />
</FormGroup>
<FormGroup )}
label={intl.get('warehouses_multi_select.label')} {isWarehousesFeatureCan && (
className={Classes.FILL} <FormGroup
> label={intl.get('warehouses_multi_select.label')}
<WarehouseMultiSelect className={Classes.FILL}
name={'warehousesIds'} >
warehouses={warehouses} <WarehouseMultiSelect
/> name={'warehousesIds'}
</FormGroup> warehouses={warehouses}
/>
</FormGroup>
)}
</Col> </Col>
</Row> </Row>
); );

View File

@@ -16,6 +16,8 @@ import withProfitLoss from './withProfitLoss';
import withProfitLossActions from './withProfitLossActions'; import withProfitLossActions from './withProfitLossActions';
import { useProfitLossHeaderValidationSchema } from './utils'; import { useProfitLossHeaderValidationSchema } from './utils';
import { useFeatureCan } from '@/hooks/state';
import { Features } from '@/constants';
/** /**
* Profit/loss header. * Profit/loss header.
@@ -55,6 +57,10 @@ function ProfitLossHeader({
toggleFilterDrawer(false); toggleFilterDrawer(false);
}; };
const { featureCan } = useFeatureCan();
const isBranchesFeatureCan = featureCan(Features.Branches);
return ( return (
<ProfitLossSheetHeader <ProfitLossSheetHeader
isOpen={profitLossDrawerFilter} isOpen={profitLossDrawerFilter}
@@ -77,11 +83,13 @@ function ProfitLossHeader({
title={<T id={'profit_loss_sheet.comparisons'} />} title={<T id={'profit_loss_sheet.comparisons'} />}
panel={<ProfitLossSheetHeaderComparisonPanel />} panel={<ProfitLossSheetHeaderComparisonPanel />}
/> />
<Tab {isBranchesFeatureCan && (
id="dimensions" <Tab
title={<T id={'profit_loss_sheet.dimensions'} />} id="dimensions"
panel={<ProfitLossSheetHeaderDimensionsPanel />} title={<T id={'profit_loss_sheet.dimensions'} />}
/> panel={<ProfitLossSheetHeaderDimensionsPanel />}
/>
)}
</Tabs> </Tabs>
<div class="financial-header-drawer__footer"> <div class="financial-header-drawer__footer">

View File

@@ -7,10 +7,12 @@ import {
ProfitLossSheetHeaderDimensionsProvider, ProfitLossSheetHeaderDimensionsProvider,
useProfitLossSheetPanelContext, useProfitLossSheetPanelContext,
} from './ProfitLossSheetHeaderDimensionsProvider'; } from './ProfitLossSheetHeaderDimensionsProvider';
import { useFeatureCan } from '@/hooks/state';
import { Features } from '@/constants';
/** /**
* profit loss Sheet Header dimensions panel. * profit loss Sheet Header dimensions panel.
* @returns * @returns {JSX.Element}
*/ */
export default function ProfitLossSheetHeaderDimensionsPanel() { export default function ProfitLossSheetHeaderDimensionsPanel() {
return ( return (
@@ -21,21 +23,26 @@ export default function ProfitLossSheetHeaderDimensionsPanel() {
} }
/** /**
* profit loss Sheet Header dimensions panel content. * Profit/Loss Sheet Header dimensions panel content.
* @returns * @returns {JSX.Element}
*/ */
function ProfitLossSheetHeaderDimensionsPanelContent() { function ProfitLossSheetHeaderDimensionsPanelContent() {
const { branches } = useProfitLossSheetPanelContext(); const { branches } = useProfitLossSheetPanelContext();
const { featureCan } = useFeatureCan();
const isBranchesFeatureCan = featureCan(Features.Branches);
return ( return (
<Row> <Row>
<Col xs={4}> <Col xs={4}>
<FormGroup {isBranchesFeatureCan && (
label={intl.get('branches_multi_select.label')} <FormGroup
className={Classes.FILL} label={intl.get('branches_multi_select.label')}
> className={Classes.FILL}
<BranchMultiSelect name={'branchesIds'} branches={branches} /> >
</FormGroup> <BranchMultiSelect name={'branchesIds'} branches={branches} />
</FormGroup>
)}
</Col> </Col>
</Row> </Row>
); );

View File

@@ -17,6 +17,8 @@ import withTrialBalance from './withTrialBalance';
import withTrialBalanceActions from './withTrialBalanceActions'; import withTrialBalanceActions from './withTrialBalanceActions';
import { compose, transformToForm } from '@/utils'; import { compose, transformToForm } from '@/utils';
import { useFeatureCan } from '@/hooks/state';
import { Features } from '@/constants';
/** /**
* Trial balance sheet header. * Trial balance sheet header.
@@ -40,6 +42,10 @@ function TrialBalanceSheetHeader({
.required() .required()
.label(intl.get('to_date')), .label(intl.get('to_date')),
}); });
// Detarmines whether the feature is enabled.
const { featureCan } = useFeatureCan();
const isBranchesFeatureCan = featureCan(Features.Branches);
// Default values. // Default values.
const defaultValues = { const defaultValues = {
@@ -90,11 +96,13 @@ function TrialBalanceSheetHeader({
title={<T id={'general'} />} title={<T id={'general'} />}
panel={<TrialBalanceSheetHeaderGeneralPanel />} panel={<TrialBalanceSheetHeaderGeneralPanel />}
/> />
<Tab {isBranchesFeatureCan && (
id="dimensions" <Tab
title={<T id={'dimensions'} />} id="dimensions"
panel={<TrialBalanceSheetHeaderDimensionsPanel />} title={<T id={'dimensions'} />}
/> panel={<TrialBalanceSheetHeaderDimensionsPanel />}
/>
)}
</Tabs> </Tabs>
<div class="financial-header-drawer__footer"> <div class="financial-header-drawer__footer">

View File

@@ -7,10 +7,12 @@ import {
TrialBLHeaderDimensionsPanelProvider, TrialBLHeaderDimensionsPanelProvider,
useTrialBalanceSheetPanelContext, useTrialBalanceSheetPanelContext,
} from './TrialBalanceSheetHeaderDimensionsPanelProvider'; } from './TrialBalanceSheetHeaderDimensionsPanelProvider';
import { useFeatureCan } from '@/hooks/state';
import { Features } from '@/constants';
/** /**
* Trial balance sheet header dismension panel. * Trial balance sheet header dismension panel.
* @returns * @returns {JSX.Element}
*/ */
export default function TrialBalanceSheetHeaderDimensionsPanel() { export default function TrialBalanceSheetHeaderDimensionsPanel() {
return ( return (
@@ -21,21 +23,26 @@ export default function TrialBalanceSheetHeaderDimensionsPanel() {
} }
/** /**
* trial balance sheet header dismension panel content. * Trial balance sheet header dismension panel content.
* @returns * @returns {JSX.Element}
*/ */
function TrialBLSheetHeaderDimensionsPanelContent() { function TrialBLSheetHeaderDimensionsPanelContent() {
const { branches } = useTrialBalanceSheetPanelContext(); const { branches } = useTrialBalanceSheetPanelContext();
const { featureCan } = useFeatureCan();
const isBranchesFeatureCan = featureCan(Features.Branches);
return ( return (
<Row> <Row>
<Col xs={4}> <Col xs={4}>
<FormGroup {isBranchesFeatureCan && (
label={intl.get('branches_multi_select.label')} <FormGroup
className={Classes.FILL} label={intl.get('branches_multi_select.label')}
> className={Classes.FILL}
<BranchMultiSelect name={'branchesIds'} branches={branches} /> >
</FormGroup> <BranchMultiSelect name={'branchesIds'} branches={branches} />
</FormGroup>
)}
</Col> </Col>
</Row> </Row>
); );

View File

@@ -14,10 +14,7 @@ import { store, persistor } from '@/store/createStore';
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
const whyDidYouRender = require('@welldone-software/why-did-you-render'); const whyDidYouRender = require('@welldone-software/why-did-you-render');
whyDidYouRender(React, { trackAllPureComponents: false });
whyDidYouRender(React, {
trackAllPureComponents: false,
});
} }
if (process.env.NODE_ENV !== 'development') { if (process.env.NODE_ENV !== 'development') {