From 111aa839087c8e57be7de79738c72d68aa5e7e35 Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Thu, 25 Jun 2020 13:43:47 +0200 Subject: [PATCH] feat: fix accounts issue. --- client/src/components/Dashboard/Dashboard.js | 15 +- .../Dashboard/DashboardViewsTabs.js | 79 ++++++++++ client/src/components/DialogReduxConnect.js | 12 +- .../DynamicFilterCompatatorField.js | 26 ++++ .../DynamicFilter/DynamicFilterCompatators.js | 38 +++++ .../DynamicFilter/DynamicFilterValueField.js | 141 ++++++++++-------- client/src/components/FilterDropdown.js | 112 ++++++++------ .../components/Sidebar/SidebarContainer.js | 6 +- client/src/components/index.js | 4 + .../Accounting/ManualJournalActionsBar.js | 60 +++++--- .../Accounting/ManualJournalsList.js | 18 ++- .../Accounting/withManualJournals.js | 2 +- .../containers/Accounts/AccountsActionsBar.js | 7 +- .../src/containers/Accounts/AccountsChart.js | 1 + .../containers/Accounts/AccountsDataTable.js | 36 +++-- .../containers/Accounts/AccountsViewsTabs.js | 74 ++++----- .../src/containers/Accounts/withAccounts.js | 4 +- .../containers/Currencies/withCurrencies.js | 3 +- .../src/containers/Customers/withCustomers.js | 2 +- .../src/containers/Expenses/withExpenses.js | 2 +- client/src/containers/Items/withItems.js | 2 +- .../Resources/withResourceDetails.js | 2 +- .../src/containers/Views/withCurrentView.js | 7 + .../src/containers/Views/withViewDetails.js | 6 +- client/src/lang/en/index.js | 10 +- .../src/store/accounts/accounts.selectors.js | 23 ++- .../store/currencies/currencies.selector.js | 10 ++ .../customViews/customViews.selectors.js | 31 ++-- .../store/customers/customers.selectors.js | 23 ++- .../store/dashboard/dashboard.selectors.js | 18 +++ .../src/store/expenses/expenses.selectors.js | 23 ++- .../src/store/resources/resources.reducer.js | 17 ++- client/src/style/components/data-table.scss | 7 +- client/src/style/objects/typography.scss | 2 +- client/src/style/pages/accounts-chart.scss | 5 +- client/src/style/pages/dashboard.scss | 29 ++-- client/src/style/views/Sidebar.scss | 11 +- client/src/style/views/filter-dropdown.scss | 30 ++-- client/src/utils.js | 7 + server/src/data/ResourceFieldsKeys.js | 5 + ...0822214905_create_resource_fields_table.js | 1 + .../database/seeds/seed_accounts_fields.js | 60 +++++++- server/src/database/seeds/seed_resources.js | 2 + .../database/seeds/seed_resources_fields.js | 10 ++ server/src/http/controllers/Accounts.js | 64 +++++--- server/src/lib/ViewRolesBuilder/index.js | 95 +++++++++--- 46 files changed, 797 insertions(+), 345 deletions(-) create mode 100644 client/src/components/Dashboard/DashboardViewsTabs.js create mode 100644 client/src/components/DynamicFilter/DynamicFilterCompatatorField.js create mode 100644 client/src/components/DynamicFilter/DynamicFilterCompatators.js create mode 100644 client/src/containers/Views/withCurrentView.js create mode 100644 client/src/store/dashboard/dashboard.selectors.js diff --git a/client/src/components/Dashboard/Dashboard.js b/client/src/components/Dashboard/Dashboard.js index 38887f7ed..a65662853 100644 --- a/client/src/components/Dashboard/Dashboard.js +++ b/client/src/components/Dashboard/Dashboard.js @@ -8,15 +8,10 @@ import DialogsContainer from 'components/DialogsContainer'; import PreferencesContent from 'components/Preferences/PreferencesContent'; import PreferencesSidebar from 'components/Preferences/PreferencesSidebar'; import Search from 'containers/GeneralSearch/Search'; -import withDashboard from 'containers/Dashboard/withDashboard'; -import { compose } from 'utils'; - -function Dashboard({ sidebarExpended }) { +export default function Dashboard() { return ( -
+
@@ -35,9 +30,3 @@ function Dashboard({ sidebarExpended }) {
); } - -export default compose( - withDashboard(({ sidebarExpended }) => ({ - sidebarExpended, - })), -)(Dashboard); diff --git a/client/src/components/Dashboard/DashboardViewsTabs.js b/client/src/components/Dashboard/DashboardViewsTabs.js new file mode 100644 index 000000000..e82f2a7c3 --- /dev/null +++ b/client/src/components/Dashboard/DashboardViewsTabs.js @@ -0,0 +1,79 @@ +import React, { useState, useMemo } from 'react'; +import { FormattedMessage as T } from 'react-intl'; +import PropTypes from 'prop-types'; +import { Button, Tabs, Tab, Tooltip, Position } from '@blueprintjs/core'; +import { If, Icon } from 'components'; + +export default function DashboardViewsTabs({ + tabs, + allTab = true, + newViewTab = true, + onNewViewTabClick, + onChange, + onTabClick, +}) { + const [currentView, setCurrentView] = useState(0); + + const handleClickNewView = () => { + onNewViewTabClick && onNewViewTabClick(); + }; + + const handleTabClick = (viewId) => { + onTabClick && onTabClick(viewId); + }; + + const mappedTabs = useMemo( + () => tabs.map((tab) => ({ ...tab, onTabClick: handleTabClick })), + [tabs], + ); + + const handleViewLinkClick = () => { + onNewViewTabClick && onNewViewTabClick(); + }; + + const handleTabsChange = (viewId) => { + setCurrentView(viewId); + onChange && onChange(viewId); + }; + + return ( + + {allTab && ( + } onClick={handleViewLinkClick} /> + )} + {mappedTabs.map((tab) => ( + + ))} + + + } + position={Position.RIGHT} + > +