From db39cc2fde1f051a012a45a05640a476e0d4596d Mon Sep 17 00:00:00 2001 From: Igor Octaviano Date: Wed, 19 Aug 2020 17:17:05 -0300 Subject: [PATCH] OHIF-298: Fix dropdown color in win browsers (#1981) * ohif-298: use new select in pagination * ohif-298: add menu placement * ohif-298: update border * ohif-298: fix sticky menu Co-authored-by: Danny Brown --- extensions/default/src/ViewerLayout/index.jsx | 1 + platform/ui/src/components/Header/Header.jsx | 17 +++++-- platform/ui/src/components/Select/Select.jsx | 15 ++++-- .../StudyListPagination.js | 51 ++++++++++--------- .../viewer/src/routes/WorkList/WorkList.jsx | 2 +- 5 files changed, 54 insertions(+), 32 deletions(-) diff --git a/extensions/default/src/ViewerLayout/index.jsx b/extensions/default/src/ViewerLayout/index.jsx index d6dcdedc3..8227c67d5 100644 --- a/extensions/default/src/ViewerLayout/index.jsx +++ b/extensions/default/src/ViewerLayout/index.jsx @@ -143,6 +143,7 @@ function ViewerLayout({ extensionManager, servicesManager, hotkeysManager, + commandsManager, // From Modes leftPanels, rightPanels, diff --git a/platform/ui/src/components/Header/Header.jsx b/platform/ui/src/components/Header/Header.jsx index 8b0a30f3b..6c4e572b0 100644 --- a/platform/ui/src/components/Header/Header.jsx +++ b/platform/ui/src/components/Header/Header.jsx @@ -6,7 +6,7 @@ import classNames from 'classnames'; import { useHistory } from 'react-router-dom'; import { NavBar, Svg, Icon, IconButton, Dropdown } from '@ohif/ui'; -function Header({ children, menuOptions, isReturnEnabled }) { +function Header({ children, menuOptions, isReturnEnabled, isSticky }) { const { t } = useTranslation(); const history = useHistory(); @@ -17,7 +17,7 @@ function Header({ children, menuOptions, isReturnEnabled }) { }; return ( - +
{/* // TODO: Should preserve filter/sort @@ -60,12 +60,21 @@ function Header({ children, menuOptions, isReturnEnabled }) { } Header.propTypes = { + menuOptions: PropTypes.arrayOf( + PropTypes.shape({ + title: PropTypes.string.isRequired, + icon: PropTypes.string, + onClick: PropTypes.func.isRequired, + }) + ), children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]), - isReturnEnabled: PropTypes.bool + isReturnEnabled: PropTypes.bool, + isSticky: PropTypes.bool }; Header.defaultProps = { - isReturnEnabled: true + isReturnEnabled: true, + isSticky: false }; export default Header; diff --git a/platform/ui/src/components/Select/Select.jsx b/platform/ui/src/components/Select/Select.jsx index 2cb76d728..e81956b80 100644 --- a/platform/ui/src/components/Select/Select.jsx +++ b/platform/ui/src/components/Select/Select.jsx @@ -43,9 +43,13 @@ const Select = ({ onChange, options, placeholder, + noIcons, + menuPlacement, value, }) => { - const _components = isMulti ? { Option, MultiValue } : {}; + const _noIconComponents = { DropdownIndicator: () => null, IndicatorSeparator: () => null }; + let _components = isMulti ? { Option, MultiValue } : {}; + _components = noIcons ? { ..._components, ..._noIconComponents } : _components; const selectedOptions = []; // Map array of values to an array of selected options @@ -69,12 +73,13 @@ const Select = ({ isClearable={isClearable} isMulti={isMulti} isSearchable={isSearchable} + menuPlacement={menuPlacement} closeMenuOnSelect={closeMenuOnSelect} hideSelectedOptions={hideSelectedOptions} components={_components} placeholder={placeholder} options={options} - value={isMulti ? selectedOptions : value} + value={value && Array.isArray(value) ? selectedOptions : value} onChange={(selectedOptions, { action }) => { const newSelection = !selectedOptions.length ? selectedOptions @@ -93,6 +98,8 @@ Select.defaultProps = { isDisabled: false, isMulti: false, isSearchable: true, + noIcons: false, + menuPlacement: 'auto', value: [], }; @@ -104,6 +111,8 @@ Select.propTypes = { isDisabled: PropTypes.bool, isMulti: PropTypes.bool, isSearchable: PropTypes.bool, + noIcons: PropTypes.bool, + menuPlacement: PropTypes.oneOf(['auto', 'bottom', 'top']), onChange: PropTypes.func.isRequired, options: PropTypes.arrayOf( PropTypes.shape({ @@ -112,7 +121,7 @@ Select.propTypes = { }) ), placeholder: PropTypes.string, - value: PropTypes.oneOfType(PropTypes.string, PropTypes.arrayOf(PropTypes.string)), + value: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.any]), }; export default Select; diff --git a/platform/ui/src/components/StudyListPagination/StudyListPagination.js b/platform/ui/src/components/StudyListPagination/StudyListPagination.js index 0781e68f9..3530e6f39 100644 --- a/platform/ui/src/components/StudyListPagination/StudyListPagination.js +++ b/platform/ui/src/components/StudyListPagination/StudyListPagination.js @@ -1,6 +1,6 @@ -import React from 'react'; +import React, { useState } from 'react'; import PropTypes from 'prop-types'; -import { Button, ButtonGroup, Icon, Typography } from '../'; +import { Button, ButtonGroup, Typography, Select } from '../'; const StudyListPagination = ({ onChangePage, @@ -13,30 +13,33 @@ const StudyListPagination = ({ onChangePage(toPage); }; + const ranges = [ + { value: '25', label: '25' }, + { value: '50', label: '50' }, + { value: '100', label: '100' }, + ]; + const [selectedRange, setSelectedRange] = useState(ranges.find(r => r.value == perPage)); + const onSelectedRange = (selectedRange) => { + setSelectedRange(selectedRange); + onChangePerPage(selectedRange.value); + }; + return (
-
- -
- -
-
+