diff --git a/packages/webapp/package-lock.json b/packages/webapp/package-lock.json index 90d70e072..10375684a 100644 --- a/packages/webapp/package-lock.json +++ b/packages/webapp/package-lock.json @@ -1227,9 +1227,9 @@ } }, "@blueprintjs-formik/select": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/@blueprintjs-formik/select/-/select-0.1.5.tgz", - "integrity": "sha512-EqGbuoiS1VrWpzjd39uVhBAmfVobdpgqalGcpODyGA+XAYoft1UU12yzTzrEOwBZpQKiC12UQwekUPspYBsVKA==", + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@blueprintjs-formik/select/-/select-0.2.3.tgz", + "integrity": "sha512-j/zkX0B9wgtoHgK6Z/rlowB7F7zemrAajBU+d3caCoEYMMqwAI0XA++GytqrIhv5fEGjkZ1hkxS9j8eqX8vtjA==", "requires": { "lodash.get": "^4.4.2", "lodash.keyby": "^4.6.0", diff --git a/packages/webapp/package.json b/packages/webapp/package.json index 4b6ed1037..1c49ec017 100644 --- a/packages/webapp/package.json +++ b/packages/webapp/package.json @@ -5,7 +5,7 @@ "dependencies": { "@blueprintjs-formik/core": "^0.2.1", "@blueprintjs-formik/datetime": "^0.3.4", - "@blueprintjs-formik/select": "^0.2.2", + "@blueprintjs-formik/select": "^0.2.3", "@blueprintjs/core": "^3.50.2", "@blueprintjs/datetime": "^3.23.12", "@blueprintjs/popover2": "^0.11.1", diff --git a/packages/webapp/src/components/Accounts/AccountsMultiSelect.tsx b/packages/webapp/src/components/Accounts/AccountsMultiSelect.tsx index 00df4fce9..c7b2d1e01 100644 --- a/packages/webapp/src/components/Accounts/AccountsMultiSelect.tsx +++ b/packages/webapp/src/components/Accounts/AccountsMultiSelect.tsx @@ -1,11 +1,23 @@ // @ts-nocheck -import React, { useMemo } from 'react'; +import React from 'react'; import { MenuItem } from '@blueprintjs/core'; import { FMultiSelect } from '../Forms'; import { accountPredicate } from './_components'; import { MenuItemNestedText } from '../Menu'; import { usePreprocessingAccounts } from './_hooks'; +// Create new account renderer. +const createNewItemRenderer = (query, active, handleClick) => { + return ( + + ); +}; + /** * Default account item renderer of the list. * @returns {JSX.Element} @@ -30,13 +42,16 @@ const accountRenderer = ( ); }; +// Create new item from the given query string. +const createNewItemFromQuery = (name) => ({ name }); + /** * Accounts multi-select field binded with Formik form. - * @param {*} param0 * @returns {JSX.Element} */ export function AccountsMultiSelect({ items, + allowCreate, filterByRootTypes, filterByParentTypes, @@ -46,12 +61,22 @@ export function AccountsMultiSelect({ ...rest }) { // Filters accounts based on filter props. - const filteredAccounts = usePreprocessingAccounts(accounts, { + const filteredAccounts = usePreprocessingAccounts(items, { filterByParentTypes, filterByTypes, filterByNormal, filterByRootTypes, }); + // Maybe inject new item props to select component. + const maybeCreateNewItemRenderer = allowCreate ? createNewItemRenderer : null; + const maybeCreateNewItemFromQuery = allowCreate + ? createNewItemFromQuery + : null; + + // Handles the create item click. + const handleCreateItemClick = () => { + openDialog(DialogsName.AccountForm); + }; return ( ); diff --git a/packages/webapp/src/components/Accounts/AccountsSelect.tsx b/packages/webapp/src/components/Accounts/AccountsSelect.tsx index edeaa2aae..414a95467 100644 --- a/packages/webapp/src/components/Accounts/AccountsSelect.tsx +++ b/packages/webapp/src/components/Accounts/AccountsSelect.tsx @@ -5,6 +5,7 @@ import intl from 'react-intl-universal'; import { MenuItem } from '@blueprintjs/core'; import { MenuItemNestedText, FSelect } from '@/components'; import { accountPredicate } from './_components'; +import { DialogsName } from '@/constants/dialogs'; import withDialogActions from '@/containers/Dialog/withDialogActions'; import { usePreprocessingAccounts } from './_hooks'; @@ -75,6 +76,11 @@ function AccountsSelectRoot({ ? createNewItemFromQuery : null; + // Handles the create item click. + const handleCreateItemClick = () => { + openDialog(DialogsName.AccountForm); + }; + return ( ); diff --git a/packages/webapp/src/style/App.scss b/packages/webapp/src/style/App.scss index 76c182828..039cc6080 100644 --- a/packages/webapp/src/style/App.scss +++ b/packages/webapp/src/style/App.scss @@ -52,6 +52,7 @@ body.hide-scrollbar .Pane2 { } .bp3-fill { + .bp3-popover-wrapper, .bp3-popover-target { display: block; @@ -68,9 +69,9 @@ body.hide-scrollbar .Pane2 { margin-right: 6px; } -.bp3-select-popover .bp3-menu { +.bp3-select-popover .bp3-menu, +.bp3-multi-select-popover .bp3-menu { max-height: 300px; - max-width: 400px; overflow: auto; } @@ -103,27 +104,21 @@ body.hide-scrollbar .Pane2 { background-color: #0066ff; } -.ReactVirtualized__Collection { -} +.ReactVirtualized__Collection {} -.ReactVirtualized__Collection__innerScrollContainer { -} +.ReactVirtualized__Collection__innerScrollContainer {} /* Grid default theme */ -.ReactVirtualized__Grid { -} +.ReactVirtualized__Grid {} -.ReactVirtualized__Grid__innerScrollContainer { -} +.ReactVirtualized__Grid__innerScrollContainer {} /* Table default theme */ -.ReactVirtualized__Table { -} +.ReactVirtualized__Table {} -.ReactVirtualized__Table__Grid { -} +.ReactVirtualized__Table__Grid {} .ReactVirtualized__Table__headerRow { font-weight: 700; @@ -186,8 +181,7 @@ body.hide-scrollbar .Pane2 { /* List default theme */ -.ReactVirtualized__List { -} +.ReactVirtualized__List {} .bp3-drawer { box-shadow: 0 0 0; @@ -243,7 +237,7 @@ html[lang^='ar'] { padding-left: 14px; padding-right: 14px; - & + .bp3-button { + &+.bp3-button { margin-left: 8px; } } @@ -255,7 +249,7 @@ html[lang^='ar'] { margin: 0; } - > .bp3-spinner { + >.bp3-spinner { margin: 20px 0; } } @@ -283,6 +277,7 @@ html[lang^='ar'] { .align-right { text-align: right; } + .align-center { text-align: center; } @@ -292,6 +287,6 @@ html[lang^='ar'] { } -span.table-tooltip-overview-target{ +span.table-tooltip-overview-target { display: inline; } \ No newline at end of file