diff --git a/assets/js/src/subscribers/listing.jsx b/assets/js/src/subscribers/listing.jsx index de2e036d32..def466c550 100644 --- a/assets/js/src/subscribers/listing.jsx +++ b/assets/js/src/subscribers/listing.jsx @@ -9,8 +9,8 @@ define('subscribers.listing',
  • All - (0) - | + ({ this.props.count }) +  | 
  • @@ -65,78 +65,122 @@ define('subscribers.listing', this.props.onSetPage(1); }, setLastPage: function() { - var last_page = Math.ceil(this.props.count / this.props.limit); - this.props.onSetPage(last_page); + this.props.onSetPage(this.getLastPage()); }, setPreviousPage: function() { - this.props.onSetPage(this.getPageValue(this.props.page - 1)); + this.props.onSetPage(this.constrainPage(this.props.page - 1)); }, setNextPage: function() { - this.props.onSetPage(this.getPageValue(this.props.page + 1)); + this.props.onSetPage(this.constrainPage(this.props.page + 1)); }, - getPageValue: function(page) { - var last_page = Math.ceil(this.props.count / this.props.limit); - return Math.min(Math.max(1, Math.abs(~~page)), last_page); + constrainPage: function(page) { + return Math.min(Math.max(1, Math.abs(~~page)), this.getLastPage()); }, handleSetPage: function() { this.props.onSetPage( - this.getPageValue(this.refs.page.getDOMNode().value) + this.constrainPage(this.refs.page.getDOMNode().value) ); }, + getLastPage: function() { + return Math.ceil(this.props.count / this.props.limit); + }, render: function() { - return ( -
    - {this.props.count} item(s) + if(this.props.count === 0) { + return (
    ); + } else { + var firstPage = ( + + ), + previousPage = ( + + ), + nextPage = ( + + ), + lastPage = ( + + ); - -
    - First page - - - - Previous page - - + if(this.props.count > this.props.limit) { + if(this.props.page > 1) { + previousPage = ( + + Previous page + + + ); + }var last_page = Math.ceil(this.props.count / this.props.limit); - - - -  of  - - {Math.ceil(this.props.count / this.props.limit)} + if(this.props.page > 2) { + firstPage = ( + + First page + + + ); + } + + if(this.props.page < this.getLastPage()) { + nextPage = ( + + Next page + + + ); + } + + if(this.props.page < this.getLastPage() - 1) { + lastPage = ( + + Last page + + + ); + } + } + + return ( +
    + {this.props.count} item(s) + + + {firstPage} + {previousPage} +   + + + +  of  + + {Math.ceil(this.props.count / this.props.limit)} + +   + {nextPage} + {lastPage} - - - Next page - - - - Last page - - - -
    - ); +
    + ); + } } }); @@ -338,7 +382,7 @@ define('subscribers.listing', return (
    - +