mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
wip
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
|||||||
Intent,
|
Intent,
|
||||||
Alignment,
|
Alignment,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
|
import { isEmpty } from 'lodash';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Icon,
|
Icon,
|
||||||
@@ -43,6 +44,7 @@ function ManualJournalActionsBar({
|
|||||||
|
|
||||||
// #withManualJournals
|
// #withManualJournals
|
||||||
manualJournalsFilterConditions,
|
manualJournalsFilterConditions,
|
||||||
|
manualJournalsSelectedRows,
|
||||||
|
|
||||||
// #withSettings
|
// #withSettings
|
||||||
manualJournalsTableSize,
|
manualJournalsTableSize,
|
||||||
@@ -70,7 +72,7 @@ function ManualJournalActionsBar({
|
|||||||
history.push('/make-journal-entry');
|
history.push('/make-journal-entry');
|
||||||
};
|
};
|
||||||
// Handle delete button click.
|
// Handle delete button click.
|
||||||
const handleBulkDelete = () => {};
|
const handleBulkDelete = () => { };
|
||||||
|
|
||||||
// Handle tab change.
|
// Handle tab change.
|
||||||
const handleTabChange = (view) => {
|
const handleTabChange = (view) => {
|
||||||
@@ -100,6 +102,22 @@ function ManualJournalActionsBar({
|
|||||||
downloadExportPdf({ resource: 'ManualJournal' });
|
downloadExportPdf({ resource: 'ManualJournal' });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!isEmpty(manualJournalsSelectedRows)) {
|
||||||
|
return (
|
||||||
|
<DashboardActionsBar>
|
||||||
|
<NavbarGroup>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||||
|
text={<T id={'delete'} />}
|
||||||
|
intent={Intent.DANGER}
|
||||||
|
onClick={handleBulkDelete}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
|
</DashboardActionsBar>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -184,8 +202,9 @@ export default compose(
|
|||||||
withDialogActions,
|
withDialogActions,
|
||||||
withManualJournalsActions,
|
withManualJournalsActions,
|
||||||
withSettingsActions,
|
withSettingsActions,
|
||||||
withManualJournals(({ manualJournalsTableState }) => ({
|
withManualJournals(({ manualJournalsTableState, manualJournalsSelectedRows }) => ({
|
||||||
manualJournalsFilterConditions: manualJournalsTableState.filterRoles,
|
manualJournalsFilterConditions: manualJournalsTableState.filterRoles,
|
||||||
|
manualJournalsSelectedRows,
|
||||||
})),
|
})),
|
||||||
withSettings(({ manualJournalsSettings }) => ({
|
withSettings(({ manualJournalsSettings }) => ({
|
||||||
manualJournalsTableSize: manualJournalsSettings?.tableSize,
|
manualJournalsTableSize: manualJournalsSettings?.tableSize,
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import { DRAWERS } from '@/constants/drawers';
|
|||||||
function ManualJournalsDataTable({
|
function ManualJournalsDataTable({
|
||||||
// #withManualJournalsActions
|
// #withManualJournalsActions
|
||||||
setManualJournalsTableState,
|
setManualJournalsTableState,
|
||||||
|
setManualJournalsSelectedRows,
|
||||||
|
|
||||||
// #withAlertsActions
|
// #withAlertsActions
|
||||||
openAlert,
|
openAlert,
|
||||||
@@ -67,31 +68,26 @@ function ManualJournalsDataTable({
|
|||||||
const handlePublishJournal = ({ id }) => {
|
const handlePublishJournal = ({ id }) => {
|
||||||
openAlert('journal-publish', { manualJournalId: id });
|
openAlert('journal-publish', { manualJournalId: id });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle the journal edit action.
|
// Handle the journal edit action.
|
||||||
const handleEditJournal = ({ id }) => {
|
const handleEditJournal = ({ id }) => {
|
||||||
history.push(`/manual-journals/${id}/edit`);
|
history.push(`/manual-journals/${id}/edit`);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle the journal delete action.
|
// Handle the journal delete action.
|
||||||
const handleDeleteJournal = ({ id }) => {
|
const handleDeleteJournal = ({ id }) => {
|
||||||
openAlert('journal-delete', { manualJournalId: id });
|
openAlert('journal-delete', { manualJournalId: id });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle view detail journal.
|
// Handle view detail journal.
|
||||||
const handleViewDetailJournal = ({ id }) => {
|
const handleViewDetailJournal = ({ id }) => {
|
||||||
openDrawer(DRAWERS.JOURNAL_DETAILS, {
|
openDrawer(DRAWERS.JOURNAL_DETAILS, {
|
||||||
manualJournalId: id,
|
manualJournalId: id,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle cell click.
|
// Handle cell click.
|
||||||
const handleCellClick = (cell, event) => {
|
const handleCellClick = (cell, event) => {
|
||||||
openDrawer(DRAWERS.JOURNAL_DETAILS, {
|
openDrawer(DRAWERS.JOURNAL_DETAILS, {
|
||||||
manualJournalId: cell.row.original.id,
|
manualJournalId: cell.row.original.id,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Local storage memorizing columns widths.
|
// Local storage memorizing columns widths.
|
||||||
const [initialColumnsWidths, , handleColumnResizing] =
|
const [initialColumnsWidths, , handleColumnResizing] =
|
||||||
useMemorizedColumnsWidths(TABLES.MANUAL_JOURNALS);
|
useMemorizedColumnsWidths(TABLES.MANUAL_JOURNALS);
|
||||||
@@ -107,6 +103,12 @@ function ManualJournalsDataTable({
|
|||||||
},
|
},
|
||||||
[setManualJournalsTableState],
|
[setManualJournalsTableState],
|
||||||
);
|
);
|
||||||
|
// Handle selected rows change.
|
||||||
|
const handleSelectedRowsChange = (selectedFlatRows) => {
|
||||||
|
const selectedIds = selectedFlatRows?.map((row) => row.original.id) || [];
|
||||||
|
setManualJournalsSelectedRows(selectedIds);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Display manual journal empty status instead of the table.
|
// Display manual journal empty status instead of the table.
|
||||||
if (isEmptyStatus) {
|
if (isEmptyStatus) {
|
||||||
@@ -130,6 +132,7 @@ function ManualJournalsDataTable({
|
|||||||
pagesCount={pagination.pagesCount}
|
pagesCount={pagination.pagesCount}
|
||||||
autoResetSortBy={false}
|
autoResetSortBy={false}
|
||||||
autoResetPage={false}
|
autoResetPage={false}
|
||||||
|
onSelectedRowsChange={handleSelectedRowsChange}
|
||||||
TableLoadingRenderer={TableSkeletonRows}
|
TableLoadingRenderer={TableSkeletonRows}
|
||||||
TableHeaderSkeletonRenderer={TableSkeletonHeader}
|
TableHeaderSkeletonRenderer={TableSkeletonHeader}
|
||||||
ContextMenu={ActionsMenu}
|
ContextMenu={ActionsMenu}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import {
|
import {
|
||||||
|
getManualJournalsSelectedRowsFactory,
|
||||||
getManualJournalsTableStateFactory,
|
getManualJournalsTableStateFactory,
|
||||||
manualJournalTableStateChangedFactory,
|
manualJournalTableStateChangedFactory,
|
||||||
} from '@/store/manualJournals/manualJournals.selectors';
|
} from '@/store/manualJournals/manualJournals.selectors';
|
||||||
@@ -9,6 +10,7 @@ export default (mapState) => {
|
|||||||
const getJournalsTableQuery = getManualJournalsTableStateFactory();
|
const getJournalsTableQuery = getManualJournalsTableStateFactory();
|
||||||
const manualJournalTableStateChanged =
|
const manualJournalTableStateChanged =
|
||||||
manualJournalTableStateChangedFactory();
|
manualJournalTableStateChangedFactory();
|
||||||
|
const getSelectedRows = getManualJournalsSelectedRowsFactory();
|
||||||
|
|
||||||
const mapStateToProps = (state, props) => {
|
const mapStateToProps = (state, props) => {
|
||||||
const mapped = {
|
const mapped = {
|
||||||
@@ -17,6 +19,7 @@ export default (mapState) => {
|
|||||||
state,
|
state,
|
||||||
props,
|
props,
|
||||||
),
|
),
|
||||||
|
manualJournalsSelectedRows: getSelectedRows(state, props),
|
||||||
};
|
};
|
||||||
return mapState ? mapState(mapped, state, props) : mapped;
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,11 +2,14 @@
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import {
|
import {
|
||||||
setManualJournalsTableState,
|
setManualJournalsTableState,
|
||||||
|
setManualJournalsSelectedRows,
|
||||||
} from '@/store/manualJournals/manualJournals.actions';
|
} from '@/store/manualJournals/manualJournals.actions';
|
||||||
|
|
||||||
const mapActionsToProps = (dispatch) => ({
|
const mapActionsToProps = (dispatch) => ({
|
||||||
setManualJournalsTableState: (queries) =>
|
setManualJournalsTableState: (queries) =>
|
||||||
dispatch(setManualJournalsTableState(queries)),
|
dispatch(setManualJournalsTableState(queries)),
|
||||||
|
setManualJournalsSelectedRows: (selectedRows) =>
|
||||||
|
dispatch(setManualJournalsSelectedRows(selectedRows)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(null, mapActionsToProps);
|
export default connect(null, mapActionsToProps);
|
||||||
|
|||||||
@@ -126,6 +126,34 @@ function AccountsActionsBar({
|
|||||||
openDialog(DialogsName.AccountForm, {});
|
openDialog(DialogsName.AccountForm, {});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!isEmpty(accountsSelectedRows)) {
|
||||||
|
return (
|
||||||
|
<DashboardActionsBar>
|
||||||
|
<NavbarGroup>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="play-16" iconSize={16} />}
|
||||||
|
text={<T id={'activate'} />}
|
||||||
|
onClick={handelBulkActivate}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="pause-16" iconSize={16} />}
|
||||||
|
text={<T id={'inactivate'} />}
|
||||||
|
onClick={handelBulkInactive}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||||
|
text={<T id={'delete'} />}
|
||||||
|
intent={Intent.DANGER}
|
||||||
|
onClick={handleBulkDelete}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
|
</DashboardActionsBar>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -162,29 +190,6 @@ function AccountsActionsBar({
|
|||||||
|
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
|
|
||||||
<If condition={!isEmpty(accountsSelectedRows)}>
|
|
||||||
<Button
|
|
||||||
className={Classes.MINIMAL}
|
|
||||||
icon={<Icon icon="play-16" iconSize={16} />}
|
|
||||||
text={<T id={'activate'} />}
|
|
||||||
onClick={handelBulkActivate}
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
className={Classes.MINIMAL}
|
|
||||||
icon={<Icon icon="pause-16" iconSize={16} />}
|
|
||||||
text={<T id={'inactivate'} />}
|
|
||||||
onClick={handelBulkInactive}
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
className={Classes.MINIMAL}
|
|
||||||
icon={<Icon icon="trash-16" iconSize={16} />}
|
|
||||||
text={<T id={'delete'} />}
|
|
||||||
intent={Intent.DANGER}
|
|
||||||
onClick={handleBulkDelete}
|
|
||||||
/>
|
|
||||||
<NavbarDivider />
|
|
||||||
</If>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon="print-16" iconSize={16} />}
|
icon={<Icon icon="print-16" iconSize={16} />}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import withDialogActions from '@/containers/Dialog/withDialogActions';
|
|||||||
import withSettings from '@/containers/Settings/withSettings';
|
import withSettings from '@/containers/Settings/withSettings';
|
||||||
|
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
|
import { isEmpty } from 'lodash';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expenses actions bar.
|
* Expenses actions bar.
|
||||||
@@ -46,6 +47,7 @@ function ExpensesActionsBar({
|
|||||||
|
|
||||||
// #withExpenses
|
// #withExpenses
|
||||||
expensesFilterConditions,
|
expensesFilterConditions,
|
||||||
|
expensesSelectedRows,
|
||||||
|
|
||||||
// #withSettings
|
// #withSettings
|
||||||
expensesTableSize,
|
expensesTableSize,
|
||||||
@@ -73,7 +75,7 @@ function ExpensesActionsBar({
|
|||||||
history.push('/expenses/new');
|
history.push('/expenses/new');
|
||||||
};
|
};
|
||||||
// Handle delete button click.
|
// Handle delete button click.
|
||||||
const handleBulkDelete = () => {};
|
const handleBulkDelete = () => { };
|
||||||
|
|
||||||
// Handles the tab chaning.
|
// Handles the tab chaning.
|
||||||
const handleTabChange = (view) => {
|
const handleTabChange = (view) => {
|
||||||
@@ -102,6 +104,21 @@ function ExpensesActionsBar({
|
|||||||
downloadExportPdf({ resource: 'Expense' });
|
downloadExportPdf({ resource: 'Expense' });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!isEmpty(expensesSelectedRows)) {
|
||||||
|
return (
|
||||||
|
<DashboardActionsBar>
|
||||||
|
<NavbarGroup>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||||
|
text={<T id={'delete'} />}
|
||||||
|
intent={Intent.DANGER}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
|
</DashboardActionsBar>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -185,8 +202,9 @@ export default compose(
|
|||||||
withDialogActions,
|
withDialogActions,
|
||||||
withExpensesActions,
|
withExpensesActions,
|
||||||
withSettingsActions,
|
withSettingsActions,
|
||||||
withExpenses(({ expensesTableState }) => ({
|
withExpenses(({ expensesTableState, expensesSelectedRows }) => ({
|
||||||
expensesFilterConditions: expensesTableState.filterRoles,
|
expensesFilterConditions: expensesTableState.filterRoles,
|
||||||
|
expensesSelectedRows,
|
||||||
})),
|
})),
|
||||||
withSettings(({ expenseSettings }) => ({
|
withSettings(({ expenseSettings }) => ({
|
||||||
expensesTableSize: expenseSettings?.tableSize,
|
expensesTableSize: expenseSettings?.tableSize,
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import { DRAWERS } from '@/constants/drawers';
|
|||||||
function ExpensesDataTable({
|
function ExpensesDataTable({
|
||||||
// #withExpensesActions
|
// #withExpensesActions
|
||||||
setExpensesTableState,
|
setExpensesTableState,
|
||||||
|
setExpensesSelectedRows,
|
||||||
|
|
||||||
// #withDrawerActions
|
// #withDrawerActions
|
||||||
openDrawer,
|
openDrawer,
|
||||||
@@ -42,7 +43,7 @@ function ExpensesDataTable({
|
|||||||
expensesTableSize,
|
expensesTableSize,
|
||||||
|
|
||||||
// #withExpenses
|
// #withExpenses
|
||||||
expensesTableState
|
expensesTableState,
|
||||||
}) {
|
}) {
|
||||||
// Expenses list context.
|
// Expenses list context.
|
||||||
const {
|
const {
|
||||||
@@ -102,6 +103,12 @@ function ExpensesDataTable({
|
|||||||
openDrawer(DRAWERS.EXPENSE_DETAILS, { expenseId: cell.row.original.id });
|
openDrawer(DRAWERS.EXPENSE_DETAILS, { expenseId: cell.row.original.id });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle selected rows change.
|
||||||
|
const handleSelectedRowsChange = (selectedFlatRows) => {
|
||||||
|
const selectedIds = selectedFlatRows?.map((row) => row.original.id) || [];
|
||||||
|
setExpensesSelectedRows(selectedIds);
|
||||||
|
};
|
||||||
|
|
||||||
// Display empty status instead of the table.
|
// Display empty status instead of the table.
|
||||||
if (isEmptyStatus) {
|
if (isEmptyStatus) {
|
||||||
return <ExpensesEmptyStatus />;
|
return <ExpensesEmptyStatus />;
|
||||||
@@ -132,6 +139,7 @@ function ExpensesDataTable({
|
|||||||
onCellClick={handleCellClick}
|
onCellClick={handleCellClick}
|
||||||
initialColumnsWidths={initialColumnsWidths}
|
initialColumnsWidths={initialColumnsWidths}
|
||||||
onColumnResizing={handleColumnResizing}
|
onColumnResizing={handleColumnResizing}
|
||||||
|
onSelectedRowsChange={handleSelectedRowsChange}
|
||||||
size={expensesTableSize}
|
size={expensesTableSize}
|
||||||
payload={{
|
payload={{
|
||||||
onPublish: handlePublishExpense,
|
onPublish: handlePublishExpense,
|
||||||
@@ -152,5 +160,5 @@ export default compose(
|
|||||||
withSettings(({ expenseSettings }) => ({
|
withSettings(({ expenseSettings }) => ({
|
||||||
expensesTableSize: expenseSettings?.tableSize,
|
expensesTableSize: expenseSettings?.tableSize,
|
||||||
})),
|
})),
|
||||||
withExpenses(({ expensesTableState }) => ({ expensesTableState }))
|
withExpenses(({ expensesTableState }) => ({ expensesTableState })),
|
||||||
)(ExpensesDataTable);
|
)(ExpensesDataTable);
|
||||||
|
|||||||
@@ -2,17 +2,20 @@
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import {
|
import {
|
||||||
expensesTableStateChangedFactory,
|
expensesTableStateChangedFactory,
|
||||||
|
getExpensesSelectedRowsFactory,
|
||||||
getExpensesTableStateFactory,
|
getExpensesTableStateFactory,
|
||||||
} from '@/store/expenses/expenses.selectors';
|
} from '@/store/expenses/expenses.selectors';
|
||||||
|
|
||||||
export default (mapState) => {
|
export default (mapState) => {
|
||||||
const getExpensesTableState = getExpensesTableStateFactory();
|
const getExpensesTableState = getExpensesTableStateFactory();
|
||||||
const expensesTableStateChanged = expensesTableStateChangedFactory();
|
const expensesTableStateChanged = expensesTableStateChangedFactory();
|
||||||
|
const getSelectedRows = getExpensesSelectedRowsFactory();
|
||||||
|
|
||||||
const mapStateToProps = (state, props) => {
|
const mapStateToProps = (state, props) => {
|
||||||
const mapped = {
|
const mapped = {
|
||||||
expensesTableState: getExpensesTableState(state, props),
|
expensesTableState: getExpensesTableState(state, props),
|
||||||
expensesTableStateChanged: expensesTableStateChanged(state, props),
|
expensesTableStateChanged: expensesTableStateChanged(state, props),
|
||||||
|
expensesSelectedRows: getSelectedRows(state, props),
|
||||||
};
|
};
|
||||||
return mapState ? mapState(mapped, state, props) : mapped;
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,11 +3,14 @@ import { connect } from 'react-redux';
|
|||||||
import {
|
import {
|
||||||
setExpensesTableState,
|
setExpensesTableState,
|
||||||
resetExpensesTableState,
|
resetExpensesTableState,
|
||||||
|
setExpensesSelectedRows,
|
||||||
} from '@/store/expenses/expenses.actions';
|
} from '@/store/expenses/expenses.actions';
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
setExpensesTableState: (state) => dispatch(setExpensesTableState(state)),
|
setExpensesTableState: (state) => dispatch(setExpensesTableState(state)),
|
||||||
resetExpensesTableState: (state) => dispatch(resetExpensesTableState(state)),
|
resetExpensesTableState: (state) => dispatch(resetExpensesTableState(state)),
|
||||||
|
setExpensesSelectedRows: (selectedRows) =>
|
||||||
|
dispatch(setExpensesSelectedRows(selectedRows)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(null, mapDispatchToProps);
|
export default connect(null, mapDispatchToProps);
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import withDialogActions from '../Dialog/withDialogActions';
|
|||||||
|
|
||||||
import { DialogsName } from '@/constants/dialogs';
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
|
import { isEmpty } from 'lodash';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Items actions bar.
|
* Items actions bar.
|
||||||
@@ -118,6 +119,22 @@ function ItemsActionsBar({
|
|||||||
downloadExportPdf({ resource: 'Item' });
|
downloadExportPdf({ resource: 'Item' });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!isEmpty(itemsSelectedRows)) {
|
||||||
|
return (
|
||||||
|
<DashboardActionsBar>
|
||||||
|
<NavbarGroup>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||||
|
text={<T id={'delete'} />}
|
||||||
|
intent={Intent.DANGER}
|
||||||
|
onClick={handleBulkDelete}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
|
</DashboardActionsBar>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -150,18 +167,8 @@ function ItemsActionsBar({
|
|||||||
>
|
>
|
||||||
<DashboardFilterButton conditionsCount={itemsFilterRoles.length} />
|
<DashboardFilterButton conditionsCount={itemsFilterRoles.length} />
|
||||||
</AdvancedFilterPopover>
|
</AdvancedFilterPopover>
|
||||||
|
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
|
|
||||||
<If condition={itemsSelectedRows.length}>
|
|
||||||
<Button
|
|
||||||
className={Classes.MINIMAL}
|
|
||||||
icon={<Icon icon="trash-16" iconSize={16} />}
|
|
||||||
text={<T id={'delete'} />}
|
|
||||||
intent={Intent.DANGER}
|
|
||||||
onClick={handleBulkDelete}
|
|
||||||
/>
|
|
||||||
</If>
|
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import { useDownloadExportPdf } from '@/hooks/query/FinancialReports/use-export-
|
|||||||
|
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
import { DialogsName } from '@/constants/dialogs';
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
import { isEmpty } from 'lodash';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bills actions bar.
|
* Bills actions bar.
|
||||||
@@ -46,6 +47,7 @@ function BillActionsBar({
|
|||||||
|
|
||||||
// #withBills
|
// #withBills
|
||||||
billsConditionsRoles,
|
billsConditionsRoles,
|
||||||
|
billsSelectedRows,
|
||||||
|
|
||||||
// #withSettings
|
// #withSettings
|
||||||
billsTableSize,
|
billsTableSize,
|
||||||
@@ -97,6 +99,26 @@ function BillActionsBar({
|
|||||||
const handlePrintBtnClick = () => {
|
const handlePrintBtnClick = () => {
|
||||||
downloadExportPdf({ resource: 'Bill' });
|
downloadExportPdf({ resource: 'Bill' });
|
||||||
};
|
};
|
||||||
|
// Handle bulk delete.
|
||||||
|
const handleBulkDelete = () => {
|
||||||
|
openAlert('bills-bulk-delete', { billsIds: billsSelectedRows });
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!isEmpty(billsSelectedRows)) {
|
||||||
|
return (
|
||||||
|
<DashboardActionsBar>
|
||||||
|
<NavbarGroup>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||||
|
text={<T id={'delete'} />}
|
||||||
|
intent={Intent.DANGER}
|
||||||
|
onClick={handleBulkDelete}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
|
</DashboardActionsBar>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
@@ -180,8 +202,9 @@ function BillActionsBar({
|
|||||||
export default compose(
|
export default compose(
|
||||||
withBillsActions,
|
withBillsActions,
|
||||||
withSettingsActions,
|
withSettingsActions,
|
||||||
withBills(({ billsTableState }) => ({
|
withBills(({ billsTableState, billsSelectedRows }) => ({
|
||||||
billsConditionsRoles: billsTableState.filterRoles,
|
billsConditionsRoles: billsTableState.filterRoles,
|
||||||
|
billsSelectedRows,
|
||||||
})),
|
})),
|
||||||
withSettings(({ billsettings }) => ({
|
withSettings(({ billsettings }) => ({
|
||||||
billsTableSize: billsettings?.tableSize,
|
billsTableSize: billsettings?.tableSize,
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import { DRAWERS } from '@/constants/drawers';
|
|||||||
function BillsDataTable({
|
function BillsDataTable({
|
||||||
// #withBillsActions
|
// #withBillsActions
|
||||||
setBillsTableState,
|
setBillsTableState,
|
||||||
|
setBillsSelectedRows,
|
||||||
|
|
||||||
// #withBills
|
// #withBills
|
||||||
billsTableState,
|
billsTableState,
|
||||||
@@ -108,6 +109,12 @@ function BillsDataTable({
|
|||||||
openDrawer(DRAWERS.BILL_DETAILS, { billId: cell.row.original.id });
|
openDrawer(DRAWERS.BILL_DETAILS, { billId: cell.row.original.id });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle selected rows change.
|
||||||
|
const handleSelectedRowsChange = (selectedFlatRows) => {
|
||||||
|
const selectedIds = selectedFlatRows?.map((row) => row.original.id) || [];
|
||||||
|
setBillsSelectedRows(selectedIds);
|
||||||
|
};
|
||||||
|
|
||||||
// Local storage memorizing columns widths.
|
// Local storage memorizing columns widths.
|
||||||
const [initialColumnsWidths, , handleColumnResizing] =
|
const [initialColumnsWidths, , handleColumnResizing] =
|
||||||
useMemorizedColumnsWidths(TABLES.BILLS);
|
useMemorizedColumnsWidths(TABLES.BILLS);
|
||||||
@@ -138,6 +145,7 @@ function BillsDataTable({
|
|||||||
onCellClick={handleCellClick}
|
onCellClick={handleCellClick}
|
||||||
initialColumnsWidths={initialColumnsWidths}
|
initialColumnsWidths={initialColumnsWidths}
|
||||||
onColumnResizing={handleColumnResizing}
|
onColumnResizing={handleColumnResizing}
|
||||||
|
onSelectedRowsChange={handleSelectedRowsChange}
|
||||||
size={billsTableSize}
|
size={billsTableSize}
|
||||||
payload={{
|
payload={{
|
||||||
onDelete: handleDeleteBill,
|
onDelete: handleDeleteBill,
|
||||||
|
|||||||
@@ -3,16 +3,19 @@ import { connect } from 'react-redux';
|
|||||||
import {
|
import {
|
||||||
getBillsTableStateFactory,
|
getBillsTableStateFactory,
|
||||||
billsTableStateChangedFactory,
|
billsTableStateChangedFactory,
|
||||||
|
getBillsSelectedRowsFactory,
|
||||||
} from '@/store/Bills/bills.selectors';
|
} from '@/store/Bills/bills.selectors';
|
||||||
|
|
||||||
export default (mapState) => {
|
export default (mapState) => {
|
||||||
const getBillsTableState = getBillsTableStateFactory();
|
const getBillsTableState = getBillsTableStateFactory();
|
||||||
const billsTableStateChanged = billsTableStateChangedFactory();
|
const billsTableStateChanged = billsTableStateChangedFactory();
|
||||||
|
const getBillsSelectedRows = getBillsSelectedRowsFactory();
|
||||||
|
|
||||||
const mapStateToProps = (state, props) => {
|
const mapStateToProps = (state, props) => {
|
||||||
const mapped = {
|
const mapped = {
|
||||||
billsTableState: getBillsTableState(state, props),
|
billsTableState: getBillsTableState(state, props),
|
||||||
billsTableStateChanged: billsTableStateChanged(state, props),
|
billsTableStateChanged: billsTableStateChanged(state, props),
|
||||||
|
billsSelectedRows: getBillsSelectedRows(state, props),
|
||||||
};
|
};
|
||||||
return mapState ? mapState(mapped, state, props) : mapped;
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,11 +3,14 @@ import { connect } from 'react-redux';
|
|||||||
import {
|
import {
|
||||||
setBillsTableState,
|
setBillsTableState,
|
||||||
resetBillsTableState,
|
resetBillsTableState,
|
||||||
|
setBillsSelectedRows,
|
||||||
} from '@/store/Bills/bills.actions';
|
} from '@/store/Bills/bills.actions';
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
setBillsTableState: (queries) => dispatch(setBillsTableState(queries)),
|
setBillsTableState: (queries) => dispatch(setBillsTableState(queries)),
|
||||||
resetBillsTableState: () => dispatch(resetBillsTableState()),
|
resetBillsTableState: () => dispatch(resetBillsTableState()),
|
||||||
|
setBillsSelectedRows: (selectedRows) =>
|
||||||
|
dispatch(setBillsSelectedRows(selectedRows)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(null, mapDispatchToProps);
|
export default connect(null, mapDispatchToProps);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
} from '@/store/VendorCredit/vendorCredit.selector';
|
} from '@/store/VendorCredit/vendorCredit.selector';
|
||||||
|
|
||||||
export default (mapState) => {
|
export default (mapState) => {
|
||||||
const getVendorsCreditNoteTableState = getVendorCreditTableStateFactory();
|
const getVendorsCreditNoteTableState = getVendorCreditTableStateFactoryth();
|
||||||
const isVendorsCreditNoteTableChanged =
|
const isVendorsCreditNoteTableChanged =
|
||||||
isVendorCreditTableStateChangedFactory();
|
isVendorCreditTableStateChangedFactory();
|
||||||
|
|
||||||
@@ -17,6 +17,7 @@ export default (mapState) => {
|
|||||||
state,
|
state,
|
||||||
props,
|
props,
|
||||||
),
|
),
|
||||||
|
vendorsCreditNoteSelectedRows: getVendorsCreditNoteSelectedRows(state, props),
|
||||||
};
|
};
|
||||||
return mapState ? mapState(mapped, state, props) : mapped;
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { connect } from 'react-redux';
|
|||||||
import {
|
import {
|
||||||
setVendorCreditTableState,
|
setVendorCreditTableState,
|
||||||
resetVendorCreditTableState,
|
resetVendorCreditTableState,
|
||||||
|
setVendorCreditsSelectedRows,
|
||||||
} from '@/store/VendorCredit/vendorCredit.actions';
|
} from '@/store/VendorCredit/vendorCredit.actions';
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
@@ -10,6 +11,8 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
dispatch(setVendorCreditTableState(queries)),
|
dispatch(setVendorCreditTableState(queries)),
|
||||||
resetVendorsCreditNoteTableState: () =>
|
resetVendorsCreditNoteTableState: () =>
|
||||||
dispatch(resetVendorCreditTableState()),
|
dispatch(resetVendorCreditTableState()),
|
||||||
|
setVendorsCreditNoteSelectedRows: (selectedRows) =>
|
||||||
|
dispatch(setVendorCreditsSelectedRows(selectedRows)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(null, mapDispatchToProps);
|
export default connect(null, mapDispatchToProps);
|
||||||
|
|||||||
@@ -127,6 +127,24 @@ function EstimateActionsBar({
|
|||||||
openAlert('estimates-bulk-delete', { estimatesIds: estimatesSelectedRows });
|
openAlert('estimates-bulk-delete', { estimatesIds: estimatesSelectedRows });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log(estimatesSelectedRows, 'estimatesSelectedRows');
|
||||||
|
|
||||||
|
if (!isEmpty(estimatesSelectedRows)) {
|
||||||
|
return (
|
||||||
|
<DashboardActionsBar>
|
||||||
|
<NavbarGroup>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||||
|
text={<T id={'delete'} />}
|
||||||
|
intent={Intent.DANGER}
|
||||||
|
onClick={handleBulkDelete}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
|
</DashboardActionsBar>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -160,16 +178,7 @@ function EstimateActionsBar({
|
|||||||
conditionsCount={estimatesFilterRoles.length}
|
conditionsCount={estimatesFilterRoles.length}
|
||||||
/>
|
/>
|
||||||
</AdvancedFilterPopover>
|
</AdvancedFilterPopover>
|
||||||
|
<NavbarDivider />
|
||||||
<If condition={!isEmpty(estimatesSelectedRows)}>
|
|
||||||
<Button
|
|
||||||
className={Classes.MINIMAL}
|
|
||||||
icon={<Icon icon={'trash-16'} iconSize={16} />}
|
|
||||||
text={<T id={'delete'} />}
|
|
||||||
intent={Intent.DANGER}
|
|
||||||
onClick={handleBulkDelete}
|
|
||||||
/>
|
|
||||||
</If>
|
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
||||||
|
|||||||
@@ -3,17 +3,19 @@ import { connect } from 'react-redux';
|
|||||||
import {
|
import {
|
||||||
getEstimatesTableStateFactory,
|
getEstimatesTableStateFactory,
|
||||||
isEstimatesTableStateChangedFactory,
|
isEstimatesTableStateChangedFactory,
|
||||||
|
getEstimatesSelectedRowsFactory,
|
||||||
} from '@/store/Estimate/estimates.selectors';
|
} from '@/store/Estimate/estimates.selectors';
|
||||||
|
|
||||||
export default (mapState) => {
|
export default (mapState) => {
|
||||||
const getEstimatesTableState = getEstimatesTableStateFactory();
|
const getEstimatesTableState = getEstimatesTableStateFactory();
|
||||||
|
const getSelectedRows = getEstimatesSelectedRowsFactory();
|
||||||
const isEstimatesTableStateChanged = isEstimatesTableStateChangedFactory();
|
const isEstimatesTableStateChanged = isEstimatesTableStateChangedFactory();
|
||||||
|
|
||||||
const mapStateToProps = (state, props) => {
|
const mapStateToProps = (state, props) => {
|
||||||
const mapped = {
|
const mapped = {
|
||||||
estimatesTableState: getEstimatesTableState(state, props),
|
estimatesTableState: getEstimatesTableState(state, props),
|
||||||
estimatesTableStateChanged: isEstimatesTableStateChanged(state, props),
|
estimatesTableStateChanged: isEstimatesTableStateChanged(state, props),
|
||||||
estimatesSelectedRows: state.estimates?.selectedRows || [],
|
estimatesSelectedRows: getSelectedRows(state, props),
|
||||||
};
|
};
|
||||||
return mapState ? mapState(mapped, state, props) : mapped;
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -123,6 +123,22 @@ function InvoiceActionsBar({
|
|||||||
openAlert('invoices-bulk-delete', { invoicesIds: invoicesSelectedRows });
|
openAlert('invoices-bulk-delete', { invoicesIds: invoicesSelectedRows });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!isEmpty(invoicesSelectedRows)) {
|
||||||
|
return (
|
||||||
|
<DashboardActionsBar>
|
||||||
|
<NavbarGroup>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||||
|
text={<T id={'delete'} />}
|
||||||
|
intent={Intent.DANGER}
|
||||||
|
onClick={handleBulkDelete}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
|
</DashboardActionsBar>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -155,16 +171,6 @@ function InvoiceActionsBar({
|
|||||||
</AdvancedFilterPopover>
|
</AdvancedFilterPopover>
|
||||||
|
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
|
|
||||||
<If condition={!isEmpty(invoicesSelectedRows)}>
|
|
||||||
<Button
|
|
||||||
className={Classes.MINIMAL}
|
|
||||||
icon={<Icon icon={'trash-16'} iconSize={16} />}
|
|
||||||
text={<T id={'delete'} />}
|
|
||||||
intent={Intent.DANGER}
|
|
||||||
onClick={handleBulkDelete}
|
|
||||||
/>
|
|
||||||
</If>
|
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
||||||
@@ -224,9 +230,9 @@ export default compose(
|
|||||||
withInvoiceActions,
|
withInvoiceActions,
|
||||||
withSettingsActions,
|
withSettingsActions,
|
||||||
withAlertActions,
|
withAlertActions,
|
||||||
withInvoices(({ invoicesTableState }) => ({
|
withInvoices(({ invoicesTableState, invoicesSelectedRows }) => ({
|
||||||
invoicesFilterRoles: invoicesTableState.filterRoles,
|
invoicesFilterRoles: invoicesTableState.filterRoles,
|
||||||
invoicesSelectedRows: invoicesTableState?.selectedRows || [],
|
invoicesSelectedRows,
|
||||||
})),
|
})),
|
||||||
withSettings(({ invoiceSettings }) => ({
|
withSettings(({ invoiceSettings }) => ({
|
||||||
invoicesTableSize: invoiceSettings?.tableSize,
|
invoicesTableSize: invoiceSettings?.tableSize,
|
||||||
|
|||||||
@@ -3,17 +3,19 @@ import { connect } from 'react-redux';
|
|||||||
import {
|
import {
|
||||||
getInvoicesTableStateFactory,
|
getInvoicesTableStateFactory,
|
||||||
isInvoicesTableStateChangedFactory,
|
isInvoicesTableStateChangedFactory,
|
||||||
|
getInvoicesSelectedRowsFactory,
|
||||||
} from '@/store/Invoice/invoices.selector';
|
} from '@/store/Invoice/invoices.selector';
|
||||||
|
|
||||||
export default (mapState) => {
|
export default (mapState) => {
|
||||||
const getInvoicesTableState = getInvoicesTableStateFactory();
|
const getInvoicesTableState = getInvoicesTableStateFactory();
|
||||||
const isInvoicesTableStateChanged = isInvoicesTableStateChangedFactory();
|
const isInvoicesTableStateChanged = isInvoicesTableStateChangedFactory();
|
||||||
|
const getSelectedRows = getInvoicesSelectedRowsFactory();
|
||||||
|
|
||||||
const mapStateToProps = (state, props) => {
|
const mapStateToProps = (state, props) => {
|
||||||
const mapped = {
|
const mapped = {
|
||||||
invoicesTableState: getInvoicesTableState(state, props),
|
invoicesTableState: getInvoicesTableState(state, props),
|
||||||
invoicesTableStateChanged: isInvoicesTableStateChanged(state, props),
|
invoicesTableStateChanged: isInvoicesTableStateChanged(state, props),
|
||||||
invoicesSelectedRows: state.invoices?.selectedRows || [],
|
invoicesSelectedRows: getSelectedRows(state, props),
|
||||||
};
|
};
|
||||||
return mapState ? mapState(mapped, state, props) : mapped;
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import { DialogsName } from '@/constants/dialogs';
|
|||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
|
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
|
||||||
import { DRAWERS } from '@/constants/drawers';
|
import { DRAWERS } from '@/constants/drawers';
|
||||||
|
import { isEmpty } from 'lodash';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receipts actions bar.
|
* Receipts actions bar.
|
||||||
@@ -55,6 +56,7 @@ function ReceiptActionsBar({
|
|||||||
|
|
||||||
// #withReceipts
|
// #withReceipts
|
||||||
receiptsFilterConditions,
|
receiptsFilterConditions,
|
||||||
|
receiptSelectedRows,
|
||||||
|
|
||||||
// #withSettings
|
// #withSettings
|
||||||
receiptsTableSize,
|
receiptsTableSize,
|
||||||
@@ -118,6 +120,24 @@ function ReceiptActionsBar({
|
|||||||
openDrawer(DRAWERS.BRANDING_TEMPLATES, { resource: 'SaleReceipt' });
|
openDrawer(DRAWERS.BRANDING_TEMPLATES, { resource: 'SaleReceipt' });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!isEmpty(receiptSelectedRows)) {
|
||||||
|
const handleBulkDelete = () => {
|
||||||
|
openAlert('receipts-bulk-delete', { receiptsIds: receiptSelectedRows });
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<DashboardActionsBar>
|
||||||
|
<NavbarGroup>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||||
|
text={<T id={'delete'} />}
|
||||||
|
intent={Intent.DANGER}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
|
</DashboardActionsBar>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -219,8 +239,9 @@ function ReceiptActionsBar({
|
|||||||
export default compose(
|
export default compose(
|
||||||
withReceiptsActions,
|
withReceiptsActions,
|
||||||
withSettingsActions,
|
withSettingsActions,
|
||||||
withReceipts(({ receiptTableState }) => ({
|
withReceipts(({ receiptTableState, receiptSelectedRows }) => ({
|
||||||
receiptsFilterConditions: receiptTableState.filterRoles,
|
receiptsFilterConditions: receiptTableState.filterRoles,
|
||||||
|
receiptSelectedRows,
|
||||||
})),
|
})),
|
||||||
withSettings(({ receiptSettings }) => ({
|
withSettings(({ receiptSettings }) => ({
|
||||||
receiptsTableSize: receiptSettings?.tableSize,
|
receiptsTableSize: receiptSettings?.tableSize,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import {
|
import {
|
||||||
|
getReceiptsSelectedRowsFactory,
|
||||||
getReceiptsTableStateFactory,
|
getReceiptsTableStateFactory,
|
||||||
receiptsTableStateChangedFactory,
|
receiptsTableStateChangedFactory,
|
||||||
} from '@/store/receipts/receipts.selector';
|
} from '@/store/receipts/receipts.selector';
|
||||||
@@ -8,11 +9,13 @@ import {
|
|||||||
export default (mapState) => {
|
export default (mapState) => {
|
||||||
const getReceiptsTableState = getReceiptsTableStateFactory();
|
const getReceiptsTableState = getReceiptsTableStateFactory();
|
||||||
const receiptsTableStateChanged = receiptsTableStateChangedFactory();
|
const receiptsTableStateChanged = receiptsTableStateChangedFactory();
|
||||||
|
const getSelectedRows = getReceiptsSelectedRowsFactory();
|
||||||
|
|
||||||
const mapStateToProps = (state, props) => {
|
const mapStateToProps = (state, props) => {
|
||||||
const mapped = {
|
const mapped = {
|
||||||
receiptTableState: getReceiptsTableState(state, props),
|
receiptTableState: getReceiptsTableState(state, props),
|
||||||
receiptsTableStateChanged: receiptsTableStateChanged(state, props),
|
receiptsTableStateChanged: receiptsTableStateChanged(state, props),
|
||||||
|
receiptSelectedRows: getSelectedRows(state, props),
|
||||||
};
|
};
|
||||||
return mapState ? mapState(mapped, state, props) : mapped;
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { isEqual } from 'lodash';
|
|||||||
import { paginationLocationQuery } from '@/store/selectors';
|
import { paginationLocationQuery } from '@/store/selectors';
|
||||||
import { createDeepEqualSelector } from '@/utils';
|
import { createDeepEqualSelector } from '@/utils';
|
||||||
import { defaultTableQuery } from './bills.reducer';
|
import { defaultTableQuery } from './bills.reducer';
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
|
|
||||||
const billsTableStateSelector = (state) => state.bills.tableState;
|
const billsTableStateSelector = (state) => state.bills.tableState;
|
||||||
|
|
||||||
@@ -24,3 +25,9 @@ export const billsTableStateChangedFactory = () =>
|
|||||||
createDeepEqualSelector(billsTableStateSelector, (tableState) => {
|
createDeepEqualSelector(billsTableStateSelector, (tableState) => {
|
||||||
return !isEqual(tableState, defaultTableQuery);
|
return !isEqual(tableState, defaultTableQuery);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const getBillsSelectedRowsFactory = () =>
|
||||||
|
createSelector(
|
||||||
|
(state) => state.bills.selectedRows,
|
||||||
|
(selectedRows) => selectedRows,
|
||||||
|
);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { isEqual } from 'lodash';
|
|||||||
import { createDeepEqualSelector } from '@/utils';
|
import { createDeepEqualSelector } from '@/utils';
|
||||||
import { paginationLocationQuery } from '@/store/selectors';
|
import { paginationLocationQuery } from '@/store/selectors';
|
||||||
import { defaultTableQuery } from './estimates.reducer';
|
import { defaultTableQuery } from './estimates.reducer';
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
|
|
||||||
const estimatesTableState = (state) => state.salesEstimates.tableState;
|
const estimatesTableState = (state) => state.salesEstimates.tableState;
|
||||||
|
|
||||||
@@ -23,3 +24,8 @@ export const isEstimatesTableStateChangedFactory = () =>
|
|||||||
createDeepEqualSelector(estimatesTableState, (tableState) => {
|
createDeepEqualSelector(estimatesTableState, (tableState) => {
|
||||||
return !isEqual(tableState, defaultTableQuery);
|
return !isEqual(tableState, defaultTableQuery);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const getEstimatesSelectedRowsFactory = () => createSelector(
|
||||||
|
(state) => state.salesEstimates.selectedRows,
|
||||||
|
(selectedRows) => selectedRows,
|
||||||
|
);
|
||||||
@@ -3,6 +3,7 @@ import { isEqual } from 'lodash';
|
|||||||
import { paginationLocationQuery } from '@/store/selectors';
|
import { paginationLocationQuery } from '@/store/selectors';
|
||||||
import { createDeepEqualSelector } from '@/utils';
|
import { createDeepEqualSelector } from '@/utils';
|
||||||
import { defaultTableQuery } from './invoices.reducer';
|
import { defaultTableQuery } from './invoices.reducer';
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
|
|
||||||
const invoicesTableStateSelector = (state) => state.salesInvoices.tableState;
|
const invoicesTableStateSelector = (state) => state.salesInvoices.tableState;
|
||||||
|
|
||||||
@@ -25,9 +26,15 @@ export const getInvoicesTableStateFactory = () =>
|
|||||||
* Retrieve invoices table state.
|
* Retrieve invoices table state.
|
||||||
*/
|
*/
|
||||||
export const isInvoicesTableStateChangedFactory = () =>
|
export const isInvoicesTableStateChangedFactory = () =>
|
||||||
createDeepEqualSelector(
|
createDeepEqualSelector(invoicesTableStateSelector, (tableState) => {
|
||||||
invoicesTableStateSelector,
|
|
||||||
(tableState) => {
|
|
||||||
return !isEqual(tableState, defaultTableQuery);
|
return !isEqual(tableState, defaultTableQuery);
|
||||||
},
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve invoices selected rows.
|
||||||
|
*/
|
||||||
|
export const getInvoicesSelectedRowsFactory = () =>
|
||||||
|
createSelector(
|
||||||
|
(state) => state.salesInvoices.selectedRows,
|
||||||
|
(selectedRows) => selectedRows,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -30,3 +30,9 @@ export const isVendorCreditTableStateChangedFactory = () =>
|
|||||||
createDeepEqualSelector(vendorCreditsTableStateSelector, (tableState) => {
|
createDeepEqualSelector(vendorCreditsTableStateSelector, (tableState) => {
|
||||||
return !isEqual(tableState, defaultTableQuery);
|
return !isEqual(tableState, defaultTableQuery);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const getVendorsCreditNoteSelectedRowsFactory = () =>
|
||||||
|
createSelector(
|
||||||
|
(state) => state.vendorCredit.selectedRows,
|
||||||
|
(selectedRows) => selectedRows,
|
||||||
|
);
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
|
|
||||||
import { createDeepEqualSelector } from '@/utils';
|
import { createDeepEqualSelector } from '@/utils';
|
||||||
import { paginationLocationQuery } from '@/store/selectors';
|
import { paginationLocationQuery } from '@/store/selectors';
|
||||||
import { defaultTableQuery } from './expenses.reducer';
|
import { defaultTableQuery } from './expenses.reducer';
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
|
|
||||||
// Items table state selectors.
|
// Items table state selectors.
|
||||||
const expensesTableStateSelector = (state) => state.expenses.tableState;
|
const expensesTableStateSelector = (state) => state.expenses.tableState;
|
||||||
@@ -25,3 +25,9 @@ export const expensesTableStateChangedFactory = () =>
|
|||||||
createDeepEqualSelector(expensesTableStateSelector, (tableState) => {
|
createDeepEqualSelector(expensesTableStateSelector, (tableState) => {
|
||||||
return !isEqual(tableState, defaultTableQuery);
|
return !isEqual(tableState, defaultTableQuery);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const getExpensesSelectedRowsFactory = () =>
|
||||||
|
createSelector(
|
||||||
|
(state) => state.expenses.selectedRows,
|
||||||
|
(selectedRows) => selectedRows,
|
||||||
|
);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
import { paginationLocationQuery } from '@/store/selectors';
|
import { paginationLocationQuery } from '@/store/selectors';
|
||||||
import { createDeepEqualSelector } from '@/utils';
|
import { createDeepEqualSelector } from '@/utils';
|
||||||
import { defaultTableQuery } from './manualJournals.reducers';
|
import { defaultTableQuery } from './manualJournals.reducers';
|
||||||
@@ -24,3 +24,9 @@ export const manualJournalTableStateChangedFactory = () =>
|
|||||||
createDeepEqualSelector(manualJournalsTableState, (tableState) => {
|
createDeepEqualSelector(manualJournalsTableState, (tableState) => {
|
||||||
return !isEqual(tableState, defaultTableQuery);
|
return !isEqual(tableState, defaultTableQuery);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const getManualJournalsSelectedRowsFactory = () =>
|
||||||
|
createSelector(
|
||||||
|
(state) => state.manualJournals.selectedRows,
|
||||||
|
(selectedRows) => selectedRows,
|
||||||
|
);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { isEqual } from 'lodash';
|
|||||||
import { paginationLocationQuery } from '@/store/selectors';
|
import { paginationLocationQuery } from '@/store/selectors';
|
||||||
import { createDeepEqualSelector } from '@/utils';
|
import { createDeepEqualSelector } from '@/utils';
|
||||||
import { defaultTableQuery } from './receipts.reducer';
|
import { defaultTableQuery } from './receipts.reducer';
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
|
|
||||||
const receiptTableStateSelector = (state) => state.salesReceipts.tableState;
|
const receiptTableStateSelector = (state) => state.salesReceipts.tableState;
|
||||||
|
|
||||||
@@ -24,3 +25,9 @@ export const receiptsTableStateChangedFactory = () =>
|
|||||||
createDeepEqualSelector(receiptTableStateSelector, (tableState) => {
|
createDeepEqualSelector(receiptTableStateSelector, (tableState) => {
|
||||||
return !isEqual(tableState, defaultTableQuery);
|
return !isEqual(tableState, defaultTableQuery);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const getReceiptsSelectedRowsFactory = () =>
|
||||||
|
createSelector(
|
||||||
|
(state) => state.salesReceipts.selectedRows,
|
||||||
|
(selectedRows) => selectedRows,
|
||||||
|
);
|
||||||
Reference in New Issue
Block a user