mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
fix: View.
This commit is contained in:
@@ -38,23 +38,8 @@ function AccountsViewsTabs({
|
||||
const { custom_view_id: customViewId = null } = useParams();
|
||||
|
||||
useEffect(() => {
|
||||
changeAccountsCurrentView(customViewId || -1);
|
||||
setTopbarEditView(customViewId);
|
||||
changePageSubtitle(customViewId && viewItem ? viewItem.name : '');
|
||||
|
||||
addAccountsTableQueries({
|
||||
custom_view_id: customViewId,
|
||||
});
|
||||
|
||||
return () => {
|
||||
setTopbarEditView(null);
|
||||
changePageSubtitle('');
|
||||
changeAccountsCurrentView(null);
|
||||
};
|
||||
}, [customViewId]);
|
||||
|
||||
useUpdateEffect(() => {
|
||||
onViewChanged && onViewChanged(customViewId);
|
||||
}, [customViewId]);
|
||||
|
||||
// Handle click a new view tab.
|
||||
@@ -63,6 +48,13 @@ function AccountsViewsTabs({
|
||||
history.push('/custom_views/accounts/new');
|
||||
};
|
||||
|
||||
const handleTabChange = (viewId) => {
|
||||
changeAccountsCurrentView(viewId || -1);
|
||||
// addAccountsTableQueries({
|
||||
// custom_view_id: viewId || null,
|
||||
// });
|
||||
};
|
||||
|
||||
const tabs = accountsViews.map((view) => ({
|
||||
...pick(view, ['name', 'id']),
|
||||
}));
|
||||
@@ -72,6 +64,7 @@ function AccountsViewsTabs({
|
||||
<DashboardViewsTabs
|
||||
initialViewId={customViewId}
|
||||
resourceName={'accounts'}
|
||||
onChange={handleTabChange}
|
||||
tabs={tabs}
|
||||
/>
|
||||
</NavbarGroup>
|
||||
|
||||
@@ -1,27 +1,30 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
getAccountsItems, getAccountsListFactory,
|
||||
getAccountsItems,
|
||||
getAccountsListFactory,
|
||||
getAccountsTableQuery,
|
||||
} from 'store/accounts/accounts.selectors';
|
||||
import {
|
||||
getResourceViews,
|
||||
} from 'store/customViews/customViews.selectors';
|
||||
import { getResourceViews } from 'store/customViews/customViews.selectors';
|
||||
|
||||
export default (mapState) => {
|
||||
const getAccountsList = getAccountsListFactory();
|
||||
|
||||
const mapStateToProps = (state, props) => {
|
||||
const query = getAccountsTableQuery(state, props);
|
||||
|
||||
const mapped = {
|
||||
accountsViews: getResourceViews(state, props, 'accounts'),
|
||||
accountsTable: getAccountsItems(state, props),
|
||||
accountsList: getAccountsList(state, props),
|
||||
accountsTypes: state.accounts.accountsTypes,
|
||||
|
||||
|
||||
// accountsTableQuery: query,
|
||||
accountsTableQuery: state.accounts.tableQuery,
|
||||
accountsLoading: state.accounts.loading,
|
||||
accountErrors: state.accounts.errors,
|
||||
};
|
||||
return mapState ? mapState(mapped, state, props) : mapped;
|
||||
};
|
||||
|
||||
|
||||
return connect(mapStateToProps);
|
||||
};
|
||||
|
||||
@@ -1,24 +1,31 @@
|
||||
import { connect } from 'react-redux';
|
||||
import t from 'store/types';
|
||||
import {
|
||||
fetchAccountsTable,
|
||||
} from 'store/accounts/accounts.actions';
|
||||
import { fetchAccountsTable } from 'store/accounts/accounts.actions';
|
||||
|
||||
const mapActionsToProps = (dispatch) => ({
|
||||
requestFetchAccountsTable: (query = {}) => dispatch(fetchAccountsTable({ query: { ...query } })),
|
||||
changeAccountsCurrentView: (id) => dispatch({
|
||||
type: t.ACCOUNTS_SET_CURRENT_VIEW,
|
||||
currentViewId: parseInt(id, 10),
|
||||
}),
|
||||
setAccountsTableQuery: (key, value) => dispatch({
|
||||
type: 'ACCOUNTS_TABLE_QUERY_SET', key, value,
|
||||
}),
|
||||
addAccountsTableQueries: (queries) => dispatch({
|
||||
type: 'ACCOUNTS_TABLE_QUERIES_ADD', queries,
|
||||
}),
|
||||
setSelectedRowsAccounts: (ids) => dispatch({
|
||||
type: t.ACCOUNTS_SELECTED_ROWS_SET, payload: { ids },
|
||||
}),
|
||||
requestFetchAccountsTable: (query = {}) =>
|
||||
dispatch(fetchAccountsTable({ query: { ...query } })),
|
||||
changeAccountsCurrentView: (id) =>
|
||||
dispatch({
|
||||
type: t.ACCOUNTS_SET_CURRENT_VIEW,
|
||||
currentViewId: parseInt(id, 10),
|
||||
}),
|
||||
setAccountsTableQuery: (key, value) =>
|
||||
dispatch({
|
||||
type: t.ACCOUNTS_TABLE_QUERY_SET,
|
||||
key,
|
||||
value,
|
||||
}),
|
||||
addAccountsTableQueries: (queries) =>
|
||||
dispatch({
|
||||
type: t.ACCOUNTS_TABLE_QUERIES_ADD,
|
||||
queries,
|
||||
}),
|
||||
setSelectedRowsAccounts: (ids) =>
|
||||
dispatch({
|
||||
type: t.ACCOUNTS_SELECTED_ROWS_SET,
|
||||
payload: { ids },
|
||||
}),
|
||||
});
|
||||
|
||||
export default connect(null, mapActionsToProps);
|
||||
export default connect(null, mapActionsToProps);
|
||||
|
||||
Reference in New Issue
Block a user