feat: StudyListTable, ExpandedRow, API definitions (#1579)

* feat: StudyListTable Refactor

* feat: StudyListTable + Props Refactor

* fix expanded rows handler

* update and fix study list doc page

* fix date format

* use moment to format date

* expose new components

* fix study list expanded row

* Export and Create doc page for Pagination

* API Definition, Export and Doc page for StudyListTable

* StudyListTableRow

* use real example to mount study list

* move files

* temporary change study list (viewer) structure

* fix studyList

* remove unused files

* remove file

* remove unused package

* PR fixes

* Remove console.dir

Co-authored-by: Gustavo Lelis <galelis@gmail.com>
This commit is contained in:
Rodrigo AntinarelliandGustavo Lelis authored and James A. Petts committed 2020-05-15 13:46:20 +02:00
1 parent 056f56f5b4
commit f4b078912a
21 files changed
+858 -240

No files matched your search

@@ -3,125 +3,6 @@ import PropTypes from 'prop-types';
import { Button, Icon, Typography, InputGroup } from '@ohif/ui';
<<<<<<< HEAD
const isFiltering = (currentFiltersValues, filtersValues) => {
return Object.keys(currentFiltersValues).some((name) => {
const filterValue = currentFiltersValues[name];
return filterValue !== filtersValues[name];
});
};
const StudyListFilter = ({ filtersMeta, filtersValues, numOfStudies }) => {
const [currentFiltersValues, setcurrentFiltersValues] = useState(
filtersValues
);
const { sortBy, sortDirection } = currentFiltersValues;
const handleFilterLabelClick = (name) => {
let _sortDirection = 'ascending';
if (sortBy === name) {
if (sortDirection === 'ascending') {
_sortDirection = 'descending';
} else if (sortDirection === 'descending') {
_sortDirection = 'none';
}
}
if (numOfStudies <= 100) {
setcurrentFiltersValues((prevState) => ({
...prevState,
sortBy: _sortDirection !== 0 ? name : '',
sortDirection: _sortDirection,
}));
}
};
const clearFilters = () => {
setcurrentFiltersValues(filtersValues);
};
const renderFieldInputComponent = ({
name,
displayName,
inputProps,
isSortable,
inputType,
}) => {
const _isSortable = isSortable && numOfStudies <= 100 && numOfStudies > 0;
const _sortDirection = sortBy !== name ? 'none' : sortDirection;
const onLabelClick = () => {
if (_isSortable) {
handleFilterLabelClick(name);
}
};
switch (inputType) {
case 'Text':
return (
<InputText
key={name}
label={displayName}
isSortable={_isSortable}
sortDirection={_sortDirection}
onLabelClick={onLabelClick}
value={currentFiltersValues[name]}
onChange={(newValue) => {
setcurrentFiltersValues((prevState) => ({
...prevState,
[name]: newValue,
}));
}}
/>
);
break;
case 'MultiSelect':
return (
<InputMultiSelect
key={name}
label={displayName}
isSortable={_isSortable}
sortDirection={_sortDirection}
onLabelClick={onLabelClick}
options={inputProps.options}
value={currentFiltersValues[name]}
onChange={(newValue) => {
setcurrentFiltersValues((prevState) => ({
...prevState,
[name]: newValue,
}));
}}
/>
);
case 'DateRange':
return (
<InputDateRange
key={name}
label={displayName}
isSortable={_isSortable}
sortDirection={_sortDirection}
onLabelClick={onLabelClick}
value={currentFiltersValues[name]}
onChange={(newValue) => {
setcurrentFiltersValues((prevState) => ({
...prevState,
[name]: newValue,
}));
}}
/>
);
case 'None':
return (
<InputLabelWrapper
key={name}
label={displayName}
isSortable={_isSortable}
sortDirection={_sortDirection}
onLabelClick={onLabelClick}
/>
);
default:
break;
}
=======
const StudyListFilter = ({
filtersMeta,
filterValues,
@@ -137,7 +18,6 @@ const StudyListFilter = ({
...filterValues,
...sortingValues,
});
>>>>>>> 26d8c8ae5... refactor: StudyListFilter refactor (#1580)
};
const isSortingEnable = numOfStudies > 0 && numOfStudies <= 100;
@@ -194,26 +74,6 @@ const StudyListFilter = ({
</div>
</div>
<div className="sticky z-10 border-b-4 border-black" style={{ top: 58 }}>
<<<<<<< HEAD
<div className="bg-primary-dark pt-3 pb-3 ">
<div className="container m-auto relative flex flex-col">
<div className="flex flex-row w-full">
{filtersMeta.map((filterMeta) => {
return (
<div
key={filterMeta.name}
className={classnames(
'pl-4 first:pl-12',
`w-${filterMeta.gridCol}/24`
)}
>
{renderFieldInputComponent(filterMeta)}
</div>
);
})}
</div>
</div>
=======
<div className="bg-custom-navyDark pt-3 pb-3 ">
<InputGroup
inputMeta={filtersMeta}
@@ -223,7 +83,6 @@ const StudyListFilter = ({
onSortingChange={setFilterSorting}
isSortingEnable={isSortingEnable}
/>
>>>>>>> 26d8c8ae5... refactor: StudyListFilter refactor (#1580)
</div>
{numOfStudies > 100 && (
<div className="container m-auto">
@@ -1,85 +0,0 @@
import React, { useState } from 'react';
import {
Typography,
ButtonGroup,
Button,
IconButton,
Icon,
} from '../../../components/';
const StudyListPagination = (props) => {
const [currentPage, setCurrentPage] = useState(1);
const navigateToPage = (page) => {
const toPage = page < 1 ? 1 : page;
setCurrentPage(toPage);
};
return (
<div className="bg-black py-10">
<div className="container m-auto relative px-8">
<div className="flex justify-between">
<div className="flex items-center">
<div className="relative mr-3">
<select
defaultValue="25"
className="block appearance-none w-full bg-transparent border border-common-active text-white text-base px-2 pr-4 rounded leading-tight focus:outline-none"
style={{ height: 28 }}
>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
<div className="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2">
<Icon
name="arrow-down"
className="text-white"
style={{ width: 6 }}
/>
</div>
</div>
<Typography className="text-base opacity-60">
Results per page
</Typography>
</div>
<div className="">
<div className="flex items-center">
<Typography className="opacity-60 mr-4 text-base">
Page {currentPage}
</Typography>
<ButtonGroup color="primary">
<IconButton
size="small"
className="border-common-active px-4 py-2 text-base"
style={{ padding: '3px 12px', minWidth: 0 }}
color="white"
onClick={() => navigateToPage(1)}
>
<>{`<<`}</>
</IconButton>
<Button
size="small"
className="border-common-active py-2 text-base"
style={{ padding: '3px 8px', minWidth: 0 }}
color="white"
onClick={() => navigateToPage(currentPage - 1)}
>{`< Previous`}</Button>
<Button
size="small"
className="border-common-active py-2 text-base"
style={{ padding: '3px 20px', minWidth: 0 }}
color="white"
onClick={() => navigateToPage(currentPage + 1)}
>
{`Next >`}
</Button>
</ButtonGroup>
</div>
</div>
</div>
</div>
</div>
);
};
export default StudyListPagination;