From f4b078912a60b5717b938bac8ea859533f455241 Mon Sep 17 00:00:00 2001 From: Rodrigo Antinarelli Date: Thu, 2 Apr 2020 16:58:18 -0300 Subject: [PATCH] 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 --- platform/ui/index.js | 3 + platform/ui/package.json | 1 - .../StudyListExpandedRow.js | 50 +++ .../components/StudyListExpandedRow/index.js | 2 + .../StudyListPagination.js | 35 +- .../StudyListPagination.mdx | 45 +++ .../components/StudyListPagination/index.js | 3 + .../StudyListTable/StudyListTable.js | 35 ++ .../StudyListTable/StudyListTable.mdx | 62 ++++ .../StudyListTable/StudyListTableRow.js | 85 +++++ .../ui/src/components/StudyListTable/index.js | 3 + platform/ui/src/components/index.js | 6 + platform/ui/src/mocks/studyList.json | 2 +- platform/ui/src/utils/capitalize.js | 3 - platform/ui/src/utils/getInstances.js | 15 - platform/ui/src/utils/getModalities.js | 20 - platform/ui/src/utils/index.js | 7 +- platform/ui/src/views/StudyList/StudyList.js | 218 +++++++++-- platform/ui/src/views/StudyList/StudyList.mdx | 350 +++++++++++++++++- .../StudyList/components/StudyListFilter.js | 141 ------- .../connectedComponents/ConnectedStudyList.js | 12 +- 21 files changed, 858 insertions(+), 240 deletions(-) create mode 100644 platform/ui/src/components/StudyListExpandedRow/StudyListExpandedRow.js create mode 100644 platform/ui/src/components/StudyListExpandedRow/index.js rename platform/ui/src/{views/StudyList/components => components/StudyListPagination}/StudyListPagination.js (68%) create mode 100644 platform/ui/src/components/StudyListPagination/StudyListPagination.mdx create mode 100644 platform/ui/src/components/StudyListPagination/index.js create mode 100644 platform/ui/src/components/StudyListTable/StudyListTable.js create mode 100644 platform/ui/src/components/StudyListTable/StudyListTable.mdx create mode 100644 platform/ui/src/components/StudyListTable/StudyListTableRow.js create mode 100644 platform/ui/src/components/StudyListTable/index.js delete mode 100644 platform/ui/src/utils/capitalize.js delete mode 100644 platform/ui/src/utils/getInstances.js delete mode 100644 platform/ui/src/utils/getModalities.js diff --git a/platform/ui/index.js b/platform/ui/index.js index ac7f13282..4071bb71f 100644 --- a/platform/ui/index.js +++ b/platform/ui/index.js @@ -27,6 +27,9 @@ export { Label, NavBar, Select, + StudyListExpandedRow, + StudyListPagination, + StudyListTable, Svg, Table, TableBody, diff --git a/platform/ui/package.json b/platform/ui/package.json index 6592f5fe3..5c5c65100 100644 --- a/platform/ui/package.json +++ b/platform/ui/package.json @@ -26,7 +26,6 @@ }, "dependencies": { "classnames": "^2.2.6", - "date-fns": "^2.10.0", "docz": "^2.2.0", "gatsby": "2.19.24", "gatsby-plugin-postcss": "^2.1.20", diff --git a/platform/ui/src/components/StudyListExpandedRow/StudyListExpandedRow.js b/platform/ui/src/components/StudyListExpandedRow/StudyListExpandedRow.js new file mode 100644 index 000000000..c913ca9e4 --- /dev/null +++ b/platform/ui/src/components/StudyListExpandedRow/StudyListExpandedRow.js @@ -0,0 +1,50 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +import { Table, TableHead, TableBody, TableRow, TableCell } from '@ohif/ui'; + +const StudyListExpandedRow = ({ + seriesTableColumns, + seriesTableDataSource, + children, +}) => { + return ( +
+
{children}
+
+ + + + {Object.keys(seriesTableColumns).map((columnKey) => { + return ( + + {seriesTableColumns[columnKey]} + + ); + })} + + + + + {seriesTableDataSource.map((row, i) => ( + + {Object.keys(row).map((cellKey) => { + const content = row[cellKey]; + return {content}; + })} + + ))} + +
+
+
+ ); +}; + +StudyListExpandedRow.propTypes = { + seriesTableDataSource: PropTypes.arrayOf(PropTypes.object).isRequired, + seriesTableColumns: PropTypes.object.isRequired, + children: PropTypes.node.isRequired, +}; + +export default StudyListExpandedRow; diff --git a/platform/ui/src/components/StudyListExpandedRow/index.js b/platform/ui/src/components/StudyListExpandedRow/index.js new file mode 100644 index 000000000..2442a9aaa --- /dev/null +++ b/platform/ui/src/components/StudyListExpandedRow/index.js @@ -0,0 +1,2 @@ +import StudyListExpandedRow from './StudyListExpandedRow'; +export default StudyListExpandedRow; diff --git a/platform/ui/src/views/StudyList/components/StudyListPagination.js b/platform/ui/src/components/StudyListPagination/StudyListPagination.js similarity index 68% rename from platform/ui/src/views/StudyList/components/StudyListPagination.js rename to platform/ui/src/components/StudyListPagination/StudyListPagination.js index 940ac1081..90966d5e3 100644 --- a/platform/ui/src/views/StudyList/components/StudyListPagination.js +++ b/platform/ui/src/components/StudyListPagination/StudyListPagination.js @@ -1,18 +1,22 @@ -import React, { useState } from 'react'; -import { - Typography, - ButtonGroup, - Button, - IconButton, - Icon, -} from '../../../components/'; +import React from 'react'; +import PropTypes from 'prop-types'; +import { Button, ButtonGroup, Icon, IconButton, Typography } from '@ohif/ui'; +<<<<<<< HEAD:platform/ui/src/views/StudyList/components/StudyListPagination.js const StudyListPagination = (props) => { const [currentPage, setCurrentPage] = useState(1); +======= +const StudyListPagination = ({ + onChangePage, + currentPage, + perPage, + onChangePerPage, +}) => { +>>>>>>> d5a288db1... feat: StudyListTable, ExpandedRow, API definitions (#1579):platform/ui/src/components/StudyListPagination/StudyListPagination.js const navigateToPage = (page) => { const toPage = page < 1 ? 1 : page; - setCurrentPage(toPage); + onChangePage(toPage); }; return ( @@ -22,9 +26,15 @@ const StudyListPagination = (props) => {