Files
ohif-viewer/platform/ui/src/components/studyList/TablePagination.js
T
Igor Octaviano f65639c2b0 feat: New dialog service (#1202)
* Add dialog provider boilerplate and improve provider imports

* Add react-draggable dependency

* Add dialog service boilerplate

* Refactor modal to use react-modal and remove dependency on modal themed styles

* Update cinedialog to use new dialog provider

* Add multiple dialogs and refactor provider (dialogs)

* Set app root (modal)

* Add modal zindex bigger than tooltip

* Block drag on buttons/svgs/paths/input and improve jsdoc

* Use guid util to generate dialog ids

* Explicit props in dialog provider

* Improve jsdocs

* Fix tests broken

* Fix boundaries calculation

* Remember last dialog position

* Update providers location

* Add scroll to modal

* Add toggable button toolbar and fix css modal
2019-11-19 14:17:33 -05:00

107 lines
3.1 KiB
JavaScript

import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import './PaginationArea.styl';
import { withTranslation } from '../../contextProviders';
class TablePagination extends PureComponent {
static defaultProps = {
pageOptions: [5, 10, 25, 50, 100],
rowsPerPage: 25,
currentPage: 0,
};
static propTypes = {
/* Values to show in "rows per page" select dropdown */
pageOptions: PropTypes.array,
rowsPerPage: PropTypes.number.isRequired,
currentPage: PropTypes.number.isRequired,
nextPageFunc: PropTypes.func,
prevPageFunc: PropTypes.func,
onRowsPerPageChange: PropTypes.func,
recordCount: PropTypes.number.isRequired,
};
nextPage = () => {
this.props.nextPageFunc(this.props.currentPage);
};
prevPage = () => {
this.props.prevPageFunc(this.props.currentPage);
};
onRowsPerPageChange = event => {
this.props.onRowsPerPageChange(parseInt(event.target.value));
};
renderPaginationButtons() {
return (
<div className="col-xs-8 col-sm-9 col-md-9">
<div className="form-inline form-group page-buttons noselect">
<React.Fragment>
<ul className="pagination-control no-margins">
<li className="page-item prev">
<button
onClick={this.prevPage}
disabled={this.props.currentPage === 0}
className="btn page-link"
>
{this.props.t('Previous')}
</button>
</li>
<li className="page-item next">
<button
onClick={this.nextPage}
disabled={
this.props.recordCount === 0 ||
this.props.rowsPerPage > this.props.recordCount
}
className="btn page-link"
>
{this.props.t('Next')}
</button>
</li>
</ul>
</React.Fragment>
</div>
</div>
);
}
renderRowsPerPageDropdown() {
return (
<div className="form-inline form-group rows-per-page">
<span>{this.props.t('Show')}</span>
<select
onChange={this.onRowsPerPageChange}
defaultValue={this.props.rowsPerPage}
>
{this.props.pageOptions.map(pageNumber => {
return (
<option key={pageNumber} value={pageNumber}>
{pageNumber}
</option>
);
})}
</select>
<span>{this.props.t('RowsPerPage')}</span>
</div>
);
}
render() {
return (
<div className="pagination-area">
<div className="rows-dropdown">{this.renderRowsPerPageDropdown()}</div>
<div className="pagination-buttons">
<div className="form-inline form-group page-number pull-right">
{this.renderPaginationButtons()}
</div>
</div>
</div>
);
}
}
const connectedComponent = withTranslation('Common')(TablePagination);
export { connectedComponent as TablePagination };