mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 14:50:32 +00:00
fix: tables with custom views.
This commit is contained in:
@@ -24,17 +24,15 @@ export default function DashboardActionViewsList({
|
|||||||
onChange && onChange(view);
|
onChange && onChange(view);
|
||||||
};
|
};
|
||||||
|
|
||||||
const viewsMenuItems = views.map((view) => {
|
const viewsMenuItems = views.map((view) => (
|
||||||
return (
|
<MenuItem onClick={() => handleClickViewItem(view)} text={view.name} />
|
||||||
<MenuItem onClick={() => handleClickViewItem(view)} text={view.name} />
|
));
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover
|
<Popover
|
||||||
content={<Menu>{viewsMenuItems}</Menu>}
|
content={<Menu>{viewsMenuItems}</Menu>}
|
||||||
minimal={true}
|
minimal={true}
|
||||||
interactionKind={PopoverInteractionKind.HOVER}
|
interactionKind={PopoverInteractionKind.CLICK}
|
||||||
position={Position.BOTTOM_LEFT}
|
position={Position.BOTTOM_LEFT}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -47,10 +47,8 @@ function ManualJournalActionsBar({
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Handle tab change.
|
// Handle tab change.
|
||||||
const handleTabChange = (viewId) => {
|
const handleTabChange = (customView) => {
|
||||||
setManualJournalsTableState({
|
setManualJournalsTableState({ customViewId: customView.id || null });
|
||||||
customViewid: viewId.id || null,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ function ManualJournalsViewTabs({
|
|||||||
<NavbarGroup align={Alignment.LEFT}>
|
<NavbarGroup align={Alignment.LEFT}>
|
||||||
<DashboardViewsTabs
|
<DashboardViewsTabs
|
||||||
resourceName={'manual-journals'}
|
resourceName={'manual-journals'}
|
||||||
customViewId={journalsTableState.customViewId}
|
currentViewId={journalsTableState.customViewId}
|
||||||
tabs={tabs}
|
tabs={tabs}
|
||||||
onChange={handleTabChange}
|
onChange={handleTabChange}
|
||||||
onNewViewTabClick={handleClickNewView}
|
onNewViewTabClick={handleClickNewView}
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ function AccountsActionsBar({
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Handle tab changing.
|
// Handle tab changing.
|
||||||
const handleTabChange = (viewId) => {
|
const handleTabChange = (customView) => {
|
||||||
setAccountsTableState({ customViewId: viewId.id || null });
|
setAccountsTableState({ customViewId: customView.id || null });
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -34,16 +34,14 @@ function CustomersViewsTabs({
|
|||||||
|
|
||||||
// Handle tabs change.
|
// Handle tabs change.
|
||||||
const handleTabsChange = (viewId) => {
|
const handleTabsChange = (viewId) => {
|
||||||
setCustomersTableState({
|
setCustomersTableState({ customViewId: viewId || null });
|
||||||
customViewId: viewId || null,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Navbar className="navbar--dashboard-views">
|
<Navbar className="navbar--dashboard-views">
|
||||||
<NavbarGroup align={Alignment.LEFT}>
|
<NavbarGroup align={Alignment.LEFT}>
|
||||||
<DashboardViewsTabs
|
<DashboardViewsTabs
|
||||||
customViewId={customersTableState.customViewId}
|
currentViewId={customersTableState.customViewId}
|
||||||
resourceName={'customers'}
|
resourceName={'customers'}
|
||||||
tabs={tabs}
|
tabs={tabs}
|
||||||
onChange={handleTabsChange}
|
onChange={handleTabsChange}
|
||||||
|
|||||||
@@ -3,11 +3,6 @@ import { setItemsTableState }from 'store/items/items.actions';
|
|||||||
|
|
||||||
export const mapDispatchToProps = (dispatch) => ({
|
export const mapDispatchToProps = (dispatch) => ({
|
||||||
setItemsTableState: (queries) => dispatch(setItemsTableState(queries)),
|
setItemsTableState: (queries) => dispatch(setItemsTableState(queries)),
|
||||||
// setSelectedRowsItems: (selectedRows) =>
|
|
||||||
// dispatch({
|
|
||||||
// type: t.ITEM_SELECTED_ROWS_SET,
|
|
||||||
// payload: { selectedRows },
|
|
||||||
// }),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(null, mapDispatchToProps);
|
export default connect(null, mapDispatchToProps);
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { Alignment, Navbar, NavbarGroup } from '@blueprintjs/core';
|
import { Alignment, Navbar, NavbarGroup } from '@blueprintjs/core';
|
||||||
import { useParams } from 'react-router-dom';
|
|
||||||
import { pick } from 'lodash';
|
import { pick } from 'lodash';
|
||||||
|
|
||||||
import { DashboardViewsTabs } from 'components';
|
import { DashboardViewsTabs } from 'components';
|
||||||
|
|
||||||
import { useBillsListContext } from './BillsListProvider';
|
import { useBillsListContext } from './BillsListProvider';
|
||||||
import withBillActions from './withBillsActions';
|
import withBillActions from './withBillsActions';
|
||||||
|
import withBills from './withBills';
|
||||||
|
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
@@ -15,11 +15,12 @@ import { compose } from 'utils';
|
|||||||
* Bills view tabs.
|
* Bills view tabs.
|
||||||
*/
|
*/
|
||||||
function BillViewTabs({
|
function BillViewTabs({
|
||||||
//#withBillActions
|
// #withBillActions
|
||||||
setBillsTableState,
|
setBillsTableState,
|
||||||
}) {
|
|
||||||
const { custom_view_id: customViewId = null } = useParams();
|
|
||||||
|
|
||||||
|
// #withBills
|
||||||
|
billsTableState
|
||||||
|
}) {
|
||||||
// Bills list context.
|
// Bills list context.
|
||||||
const { billsViews } = useBillsListContext();
|
const { billsViews } = useBillsListContext();
|
||||||
|
|
||||||
@@ -38,7 +39,7 @@ function BillViewTabs({
|
|||||||
<Navbar className={'navbar--dashboard-views'}>
|
<Navbar className={'navbar--dashboard-views'}>
|
||||||
<NavbarGroup align={Alignment.LEFT}>
|
<NavbarGroup align={Alignment.LEFT}>
|
||||||
<DashboardViewsTabs
|
<DashboardViewsTabs
|
||||||
initialViewId={customViewId}
|
currentViewId={billsTableState.customViewId}
|
||||||
resourceName={'bills'}
|
resourceName={'bills'}
|
||||||
tabs={tabs}
|
tabs={tabs}
|
||||||
onChange={handleTabsChange}
|
onChange={handleTabsChange}
|
||||||
@@ -48,4 +49,7 @@ function BillViewTabs({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default compose(withBillActions)(BillViewTabs);
|
export default compose(
|
||||||
|
withBillActions,
|
||||||
|
withBills(({ billsTableState }) => ({ billsTableState }))
|
||||||
|
)(BillViewTabs);
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ function EstimateActionsBar({
|
|||||||
history.push('/estimates/new');
|
history.push('/estimates/new');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle tab change.
|
||||||
const handleTabChange = (customView) => {
|
const handleTabChange = (customView) => {
|
||||||
setEstimatesTableState({
|
setEstimatesTableState({
|
||||||
customViewId: customView.id || null,
|
customViewId: customView.id || null,
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import React, { useCallback } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import classNames from 'classnames';
|
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
|
|
||||||
import { CLASSES } from 'common/classes';
|
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
import { DataTable } from 'components';
|
import { DataTable } from 'components';
|
||||||
|
|||||||
@@ -23,21 +23,21 @@ function EstimateViewTabs({
|
|||||||
// Estimates list context.
|
// Estimates list context.
|
||||||
const { estimatesViews } = useEstimatesListContext();
|
const { estimatesViews } = useEstimatesListContext();
|
||||||
|
|
||||||
|
// Estimates views.
|
||||||
const tabs = estimatesViews.map((view) => ({
|
const tabs = estimatesViews.map((view) => ({
|
||||||
...pick(view, ['name', 'id']),
|
...pick(view, ['name', 'id']),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const handleTabsChange = (viewId) => {
|
// Handle tab change.
|
||||||
setEstimatesTableState({
|
const handleTabsChange = (customViewId) => {
|
||||||
customViewId: viewId || null,
|
setEstimatesTableState({ customViewId: customViewId || null });
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Navbar className={'navbar--dashboard-views'}>
|
<Navbar className={'navbar--dashboard-views'}>
|
||||||
<NavbarGroup align={Alignment.LEFT}>
|
<NavbarGroup align={Alignment.LEFT}>
|
||||||
<DashboardViewsTabs
|
<DashboardViewsTabs
|
||||||
customViewId={estimatesTableState.customViewId}
|
currentViewId={estimatesTableState.customViewId}
|
||||||
resourceName={'estimates'}
|
resourceName={'estimates'}
|
||||||
tabs={tabs}
|
tabs={tabs}
|
||||||
onChange={handleTabsChange}
|
onChange={handleTabsChange}
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ function InvoiceViewTabs({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// Handle tab change.
|
// Handle tab change.
|
||||||
const handleTabsChange = (customView) => {
|
const handleTabsChange = (customViewId) => {
|
||||||
setInvoicesTableState({
|
setInvoicesTableState({
|
||||||
customViewId: customView.id || null,
|
customViewId: customViewId || null,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ function InvoiceViewTabs({
|
|||||||
<Navbar className={'navbar--dashboard-views'}>
|
<Navbar className={'navbar--dashboard-views'}>
|
||||||
<NavbarGroup align={Alignment.LEFT}>
|
<NavbarGroup align={Alignment.LEFT}>
|
||||||
<DashboardViewsTabs
|
<DashboardViewsTabs
|
||||||
customViewId={invoicesTableState.customViewId}
|
currentViewId={invoicesTableState.customViewId}
|
||||||
resourceName={'invoices'}
|
resourceName={'invoices'}
|
||||||
tabs={tabs}
|
tabs={tabs}
|
||||||
onNewViewTabClick={handleClickNewView}
|
onNewViewTabClick={handleClickNewView}
|
||||||
|
|||||||
@@ -46,9 +46,7 @@ function InvoiceActionsBar({
|
|||||||
|
|
||||||
// Handle views tab change.
|
// Handle views tab change.
|
||||||
const handleTabChange = (customView) => {
|
const handleTabChange = (customView) => {
|
||||||
setInvoicesTableState({
|
setInvoicesTableState({ customViewId: customView.id || null });
|
||||||
customViewId: customView.id || null,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
import React, { useCallback } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import classNames from 'classnames';
|
|
||||||
|
|
||||||
import InvoicesEmptyStatus from './InvoicesEmptyStatus';
|
import InvoicesEmptyStatus from './InvoicesEmptyStatus';
|
||||||
import { CLASSES } from 'common/classes';
|
|
||||||
|
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
import { DataTable } from 'components';
|
import { DataTable } from 'components';
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import React from 'react';
|
|||||||
import 'style/pages/SaleInvoice/List.scss';
|
import 'style/pages/SaleInvoice/List.scss';
|
||||||
|
|
||||||
import { DashboardContentTable, DashboardPageContent } from 'components';
|
import { DashboardContentTable, DashboardPageContent } from 'components';
|
||||||
import InvoiceActionsBar from './InvoiceActionsBar';
|
import InvoicesActionsBar from './InvoicesActionsBar';
|
||||||
import { InvoicesListProvider } from './InvoicesListProvider';
|
import { InvoicesListProvider } from './InvoicesListProvider';
|
||||||
|
|
||||||
import InvoiceViewTabs from './InvoiceViewTabs';
|
import InvoiceViewTabs from './InvoiceViewTabs';
|
||||||
@@ -26,7 +26,7 @@ function InvoicesList({
|
|||||||
<InvoicesListProvider
|
<InvoicesListProvider
|
||||||
query={transformTableStateToQuery(invoicesTableState)}
|
query={transformTableStateToQuery(invoicesTableState)}
|
||||||
>
|
>
|
||||||
<InvoiceActionsBar />
|
<InvoicesActionsBar />
|
||||||
|
|
||||||
<DashboardPageContent>
|
<DashboardPageContent>
|
||||||
<InvoiceViewTabs />
|
<InvoiceViewTabs />
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const InvoicesListContext = createContext();
|
|||||||
/**
|
/**
|
||||||
* Accounts chart data provider.
|
* Accounts chart data provider.
|
||||||
*/
|
*/
|
||||||
function InvoicesListProvider({ accountsTableQuery, ...props }) {
|
function InvoicesListProvider({ query, ...props }) {
|
||||||
// Fetch accounts resource views and fields.
|
// Fetch accounts resource views and fields.
|
||||||
const { data: invoicesViews, isFetching: isViewsLoading } = useResourceViews(
|
const { data: invoicesViews, isFetching: isViewsLoading } = useResourceViews(
|
||||||
'sale_invoices',
|
'sale_invoices',
|
||||||
@@ -25,7 +25,7 @@ function InvoicesListProvider({ accountsTableQuery, ...props }) {
|
|||||||
data: { invoices, pagination, filterMeta },
|
data: { invoices, pagination, filterMeta },
|
||||||
isFetching: isInvoicesFetching,
|
isFetching: isInvoicesFetching,
|
||||||
isLoading: isInvoicesLoading,
|
isLoading: isInvoicesLoading,
|
||||||
} = useInvoices(accountsTableQuery, { keepPreviousData: true });
|
} = useInvoices(query, { keepPreviousData: true });
|
||||||
|
|
||||||
// Detarmines the datatable empty status.
|
// Detarmines the datatable empty status.
|
||||||
const isEmptyStatus =
|
const isEmptyStatus =
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
} from 'store/Invoice/invoices.actions';
|
} from 'store/Invoice/invoices.actions';
|
||||||
|
|
||||||
const mapDipatchToProps = (dispatch) => ({
|
const mapDipatchToProps = (dispatch) => ({
|
||||||
setInvoicesTableState: (query) => setInvoicesTableState(query),
|
setInvoicesTableState: (queries) => dispatch(setInvoicesTableState(queries)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(null, mapDipatchToProps);
|
export default connect(null, mapDipatchToProps);
|
||||||
|
|||||||
@@ -44,9 +44,9 @@ function ReceiptActionsBar({
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Handle the active tab change.
|
// Handle the active tab change.
|
||||||
const handleTabChange = (viewId) => {
|
const handleTabChange = (customView) => {
|
||||||
setReceiptsTableState({
|
setReceiptsTableState({
|
||||||
csutomViewId: viewId.id || null,
|
customViewId: customView.id || null,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ function ReceiptViewTabs({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// Handles the active tab chaning.
|
// Handles the active tab chaning.
|
||||||
const handleTabsChange = (customView) => {
|
const handleTabsChange = (customViewId) => {
|
||||||
setReceiptsTableState({
|
setReceiptsTableState({
|
||||||
customViewId: customView.id || null,
|
customViewId: customViewId || null,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ function ReceiptViewTabs({
|
|||||||
<Navbar className={'navbar--dashboard-views'}>
|
<Navbar className={'navbar--dashboard-views'}>
|
||||||
<NavbarGroup align={Alignment.LEFT}>
|
<NavbarGroup align={Alignment.LEFT}>
|
||||||
<DashboardViewsTabs
|
<DashboardViewsTabs
|
||||||
initialViewId={receiptTableState.customViewId}
|
currentViewId={receiptTableState.customViewId}
|
||||||
tabs={tabs}
|
tabs={tabs}
|
||||||
resourceName={'receipts'}
|
resourceName={'receipts'}
|
||||||
onChange={handleTabsChange}
|
onChange={handleTabsChange}
|
||||||
|
|||||||
@@ -42,10 +42,8 @@ function VendorActionsBar({
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Handle the active tab change.
|
// Handle the active tab change.
|
||||||
const handleTabChange = (viewId) => {
|
const handleTabChange = (customView) => {
|
||||||
setVendorsTableState({
|
setVendorsTableState({ customViewId: customView.id || null });
|
||||||
customViewId: viewId.id || null,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ function VendorViewsTabs({
|
|||||||
<Navbar className="navbar--dashboard-views">
|
<Navbar className="navbar--dashboard-views">
|
||||||
<NavbarGroup align={Alignment.LEFT}>
|
<NavbarGroup align={Alignment.LEFT}>
|
||||||
<DashboardViewsTabs
|
<DashboardViewsTabs
|
||||||
customViewId={vendorsTableState.customViewId}
|
currentViewId={vendorsTableState.customViewId}
|
||||||
resourceName={'vendors'}
|
resourceName={'vendors'}
|
||||||
tabs={tabs}
|
tabs={tabs}
|
||||||
onChange={handleTabsChange}
|
onChange={handleTabsChange}
|
||||||
|
|||||||
Reference in New Issue
Block a user