Skip to content

Commit

Permalink
Fixed #896 - alwaysShowPaginator prop not used
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed May 21, 2019
1 parent df3e0a0 commit 21cfa7b
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/components/datatable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ export class DataTable extends Component {
return (
<Paginator first={this.getFirst()} rows={this.getRows()} pageLinkSize={this.props.pageLinkSize} className={className} onPageChange={this.onPageChange} template={this.props.paginatorTemplate}
totalRecords={totalRecords} rowsPerPageOptions={this.props.rowsPerPageOptions} currentPageReportTemplate={this.props.currentPageReportTemplate}
leftContent={this.props.paginatorLeft} rightContent={this.props.paginatorRight} />
leftContent={this.props.paginatorLeft} rightContent={this.props.paginatorRight} alwaysShow={this.props.alwaysShowPaginator} />
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/dataview/DataView.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class DataView extends Component {
return (
<Paginator first={first} rows={rows} pageLinkSize={this.props.pageLinkSize} className={className} onPageChange={this.onPageChange} template={this.props.paginatorTemplate}
totalRecords={totalRecords} rowsPerPageOptions={this.props.rowsPerPageOptions} currentPageReportTemplate={this.props.currentPageReportTemplate}
leftContent={this.props.paginatorLeft} rightContent={this.props.paginatorRight} />
leftContent={this.props.paginatorLeft} rightContent={this.props.paginatorRight} alwaysShow={this.props.alwaysShowPaginator} />
);
}

Expand Down
109 changes: 58 additions & 51 deletions src/components/paginator/Paginator.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export class Paginator extends Component {
onPageChange: null,
leftContent: null,
rightContent: null,
currentPageReportTemplate: '({currentPage} of {totalPages})'
currentPageReportTemplate: '({currentPage} of {totalPages})',
alwaysShow: true
}

static propTypes = {
Expand All @@ -38,7 +39,8 @@ export class Paginator extends Component {
onPageChange: PropTypes.func,
leftContent: PropTypes.any,
rightContent: PropTypes.any,
currentPageReportTemplate: PropTypes.any
currentPageReportTemplate: PropTypes.any,
alwaysShow: PropTypes.bool
}

constructor(props) {
Expand Down Expand Up @@ -142,58 +144,63 @@ export class Paginator extends Component {
}

render() {
let className = classNames('p-paginator p-component p-unselectable-text', this.props.className);

let paginatorElements = this.props.template.split(' ').map((value) => {
let key = value.trim();
let element;
if (!this.props.alwaysShow && this.getPageCount() === 1) {
return null;
}
else {
let className = classNames('p-paginator p-component p-unselectable-text', this.props.className);

switch(key) {
case 'FirstPageLink':
element = <FirstPageLink key={key} onClick={this.changePageToFirst} disabled={this.isFirstPage()} />;
break;

case 'PrevPageLink':
element = <PrevPageLink key={key} onClick={this.changePageToPrev} disabled={this.isFirstPage()} />;
break;

case 'NextPageLink':
element = <NextPageLink key={key} onClick={this.changePageToNext} disabled={this.isLastPage()} />;
break;

case 'LastPageLink':
element = <LastPageLink key={key} onClick={this.changePageToLast} disabled={this.isLastPage()} />;
break;

case 'PageLinks':
element = <PageLinks key={key} value={this.updatePageLinks()} page={this.getPage()} onClick={this.onPageLinkClick} />;
break;
let paginatorElements = this.props.template.split(' ').map((value) => {
let key = value.trim();
let element;

case 'RowsPerPageDropdown':
element = <RowsPerPageDropdown key={key} value={this.props.rows} options={this.props.rowsPerPageOptions} onChange={this.onRowsChange} />;
break;
switch(key) {
case 'FirstPageLink':
element = <FirstPageLink key={key} onClick={this.changePageToFirst} disabled={this.isFirstPage()} />;
break;

case 'PrevPageLink':
element = <PrevPageLink key={key} onClick={this.changePageToPrev} disabled={this.isFirstPage()} />;
break;

case 'NextPageLink':
element = <NextPageLink key={key} onClick={this.changePageToNext} disabled={this.isLastPage()} />;
break;

case 'LastPageLink':
element = <LastPageLink key={key} onClick={this.changePageToLast} disabled={this.isLastPage()} />;
break;

case 'PageLinks':
element = <PageLinks key={key} value={this.updatePageLinks()} page={this.getPage()} onClick={this.onPageLinkClick} />;
break;

case 'RowsPerPageDropdown':
element = <RowsPerPageDropdown key={key} value={this.props.rows} options={this.props.rowsPerPageOptions} onChange={this.onRowsChange} />;
break;

case 'CurrentPageReport':
element = <CurrentPageReport template={this.props.currentPageReportTemplate} key={key} page={this.getPage()} pageCount={this.getPageCount()} />;
break;

default:
element = null;
break;
}

case 'CurrentPageReport':
element = <CurrentPageReport template={this.props.currentPageReportTemplate} key={key} page={this.getPage()} pageCount={this.getPageCount()} />;
break;

default:
element = null;
break;
}
return element;
});

let leftContent = this.props.leftContent && <div className="p-paginator-left-content" >{this.props.leftContent}</div>;
let rightContent = this.props.rightContent && <div className="p-paginator-right-content" >{this.props.rightContent}</div>

return element;
});

let leftContent = this.props.leftContent && <div className="p-paginator-left-content" >{this.props.leftContent}</div>;
let rightContent = this.props.rightContent && <div className="p-paginator-right-content" >{this.props.rightContent}</div>

return (
<div className={className} style={this.props.style}>
{leftContent}
{paginatorElements}
{rightContent}
</div>
);
return (
<div className={className} style={this.props.style}>
{leftContent}
{paginatorElements}
{rightContent}
</div>
);
}
}
}
2 changes: 1 addition & 1 deletion src/components/treetable/TreeTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ export class TreeTable extends Component {
<Paginator first={this.getFirst()} rows={this.getRows()} pageLinkSize={this.props.pageLinkSize} className={className}
onPageChange={this.onPageChange} template={this.props.paginatorTemplate}
totalRecords={totalRecords} rowsPerPageOptions={this.props.rowsPerPageOptions} currentPageReportTemplate={this.props.currentPageReportTemplate}
leftContent={this.props.paginatorLeft} rightContent={this.props.paginatorRight} />
leftContent={this.props.paginatorLeft} rightContent={this.props.paginatorRight} alwaysShow={this.props.alwaysShowPaginator} />
)
}

Expand Down

0 comments on commit 21cfa7b

Please sign in to comment.