From 79e38d2374fe7a6a9a82468361e18e1070e276f8 Mon Sep 17 00:00:00 2001 From: "a.bouhuolia" Date: Mon, 2 Aug 2021 09:36:45 +0200 Subject: [PATCH] feat: Sidebar overlay. --- client/src/components/App.js | 2 +- .../Dashboard/DashboardSplitePane.js | 2 +- client/src/components/Sidebar/Sidebar.js | 1 - client/src/config/sidebarMenu.js | 2 +- .../containers/Accounts/AccountsActionsBar.js | 16 +++++++++++- .../src/containers/Accounts/AccountsChart.js | 5 ++-- client/src/containers/Accounts/utils.js | 12 ++++++++- .../CustomersLanding/CustomersActionsBar.js | 20 ++++++++++---- .../CustomersLanding/CustomersList.js | 6 ++--- .../CustomersLanding/CustomersListProvider.js | 10 ++++--- .../Customers/CustomersLanding/utils.js | 8 ++++++ .../src/containers/Items/ItemsActionsBar.js | 19 ++++++++++++-- client/src/containers/Items/ItemsList.js | 3 +-- .../src/containers/Items/ItemsListProvider.js | 9 ++++--- client/src/containers/Items/utils.js | 12 ++++++++- .../VendorsLanding/VendorActionsBar.js | 17 ++++++++++++ .../Vendors/VendorsLanding/VendorsList.js | 4 +-- .../VendorsLanding/VendorsListProvider.js | 26 ++++++++++++------- .../Vendors/VendorsLanding/utils.js | 13 ++++++++-- client/src/lang/en/index.json | 3 ++- .../src/store/customers/customers.reducer.js | 1 + client/src/store/items/items.reducer.js | 1 + client/src/store/vendors/vendors.reducer.js | 1 + client/src/style/pages/Accounts/List.scss | 7 ----- .../src/style/pages/Dashboard/Dashboard.scss | 20 ++++++++++++++ client/src/style/pages/Items/List.scss | 1 - 26 files changed, 170 insertions(+), 51 deletions(-) create mode 100644 client/src/containers/Customers/CustomersLanding/utils.js diff --git a/client/src/components/App.js b/client/src/components/App.js index 655023182..f851f4234 100644 --- a/client/src/components/App.js +++ b/client/src/components/App.js @@ -48,7 +48,7 @@ function App({ locale }) {
- {/* */} + diff --git a/client/src/components/Dashboard/DashboardSplitePane.js b/client/src/components/Dashboard/DashboardSplitePane.js index 42433bffb..a6a2445e4 100644 --- a/client/src/components/Dashboard/DashboardSplitePane.js +++ b/client/src/components/Dashboard/DashboardSplitePane.js @@ -9,7 +9,7 @@ function DashboardSplitPane({ sidebarExpended, children }) { - const initialSize = 210; + const initialSize = 190; const [defaultSize, setDefaultSize] = useState( parseInt(localStorage.getItem('dashboard-size'), 10) || initialSize, diff --git a/client/src/components/Sidebar/Sidebar.js b/client/src/components/Sidebar/Sidebar.js index 4dc1bc19a..8d6688f7c 100644 --- a/client/src/components/Sidebar/Sidebar.js +++ b/client/src/components/Sidebar/Sidebar.js @@ -2,7 +2,6 @@ import React from 'react'; import SidebarContainer from 'components/Sidebar/SidebarContainer'; import SidebarHead from 'components/Sidebar/SidebarHead'; import SidebarMenu from 'components/Sidebar/SidebarMenu'; -import SidebarOverlay from 'components/SidebarOverlay'; import 'style/containers/Dashboard/Sidebar.scss'; diff --git a/client/src/config/sidebarMenu.js b/client/src/config/sidebarMenu.js index e7c627a3f..a32fcff06 100644 --- a/client/src/config/sidebarMenu.js +++ b/client/src/config/sidebarMenu.js @@ -217,7 +217,7 @@ export default [ ], }, { - text: , + text: , children: [ { text: , diff --git a/client/src/containers/Accounts/AccountsActionsBar.js b/client/src/containers/Accounts/AccountsActionsBar.js index 2731c823e..57381b7fa 100644 --- a/client/src/containers/Accounts/AccountsActionsBar.js +++ b/client/src/containers/Accounts/AccountsActionsBar.js @@ -10,6 +10,7 @@ import { PopoverInteractionKind, Position, Intent, + Switch, } from '@blueprintjs/core'; import classNames from 'classnames'; import { FormattedMessage as T } from 'components'; @@ -36,6 +37,7 @@ function AccountsActionsBar({ // #withAccounts accountsSelectedRows, + accountsInactiveMode, // #withAlertActions openAlert, @@ -74,6 +76,12 @@ function AccountsActionsBar({ setAccountsTableState({ customViewId: customView.id || null }); }; + // Handle inactive switch changing. + const handleInactiveSwitchChange = (event) => { + const checked = event.target.checked; + setAccountsTableState({ inactiveMode: checked }); + }; + return ( @@ -149,6 +157,11 @@ function AccountsActionsBar({ icon={} text={} /> + } + defaultChecked={accountsInactiveMode} + onChange={handleInactiveSwitchChange} + /> ); @@ -157,8 +170,9 @@ function AccountsActionsBar({ export default compose( withDialogActions, withAlertActions, - withAccounts(({ accountsSelectedRows }) => ({ + withAccounts(({ accountsSelectedRows, accountsTableState }) => ({ accountsSelectedRows, + accountsInactiveMode: accountsTableState.inactiveMode, })), withAccountsTableActions, )(AccountsActionsBar); diff --git a/client/src/containers/Accounts/AccountsChart.js b/client/src/containers/Accounts/AccountsChart.js index 43645728e..bcfd3ca8f 100644 --- a/client/src/containers/Accounts/AccountsChart.js +++ b/client/src/containers/Accounts/AccountsChart.js @@ -12,7 +12,8 @@ import AccountsDataTable from './AccountsDataTable'; import withAccounts from 'containers/Accounts/withAccounts'; -import { transformTableStateToQuery, compose } from 'utils'; +import { compose } from 'utils'; +import { transformAccountsStateToQuery } from './utils'; /** * Accounts chart list. @@ -23,7 +24,7 @@ function AccountsChart({ }) { return ( diff --git a/client/src/containers/Accounts/utils.js b/client/src/containers/Accounts/utils.js index 47ed45a5f..3fc1a9d10 100644 --- a/client/src/containers/Accounts/utils.js +++ b/client/src/containers/Accounts/utils.js @@ -3,7 +3,7 @@ import { Intent, Tag } from '@blueprintjs/core'; import { If, AppToaster } from 'components'; import intl from 'react-intl-universal'; import { NormalCell, BalanceCell } from './components'; -import { isBlank, compose } from 'utils'; +import { transformTableStateToQuery, isBlank } from 'utils'; /** * Account name accessor. @@ -100,3 +100,13 @@ export const useAccountsTableColumns = () => { export const rowClassNames = (row) => ({ inactive: !row.original.active, }); + +/** + * Transformes the table state to list query. + */ +export const transformAccountsStateToQuery = (tableState) => { + return { + ...transformTableStateToQuery(tableState), + inactive_mode: tableState.inactiveMode, + } +} \ No newline at end of file diff --git a/client/src/containers/Customers/CustomersLanding/CustomersActionsBar.js b/client/src/containers/Customers/CustomersLanding/CustomersActionsBar.js index e9c3de802..72c9b7bd2 100644 --- a/client/src/containers/Customers/CustomersLanding/CustomersActionsBar.js +++ b/client/src/containers/Customers/CustomersLanding/CustomersActionsBar.js @@ -8,6 +8,7 @@ import { Popover, Position, PopoverInteractionKind, + Switch } from '@blueprintjs/core'; import { FormattedMessage as T } from 'components'; import intl from 'react-intl-universal'; @@ -34,15 +35,13 @@ function CustomerActionsBar({ // #withCustomersActions setCustomersTableState, + accountsInactiveMode, // #withAlertActions openAlert, }) { // History context. const history = useHistory(); - - // React intl - // Customers list context. const { customersViews } = useCustomersListContext(); @@ -61,6 +60,11 @@ function CustomerActionsBar({ customViewId: viewId.id || null, }); }; + // Handle inactive switch changing. + const handleInactiveSwitchChange = (event) => { + const checked = event.target.checked; + setCustomersTableState({ inactiveMode: checked }); + }; return ( @@ -86,7 +90,7 @@ function CustomerActionsBar({ >