Merge "Don't show next arrow when there are not more changes on next page"

This commit is contained in:
Wyatt Allen 2017-02-23 23:42:33 +00:00 committed by Gerrit Code Review
commit de9f76de42
3 changed files with 16 additions and 10 deletions

View File

@ -62,7 +62,7 @@ limitations under the License.
hidden$="[[_hidePrevArrow(_offset)]]" hidden>&larr; Prev</a>
<a id="nextArrow"
href$="[[_computeNavLink(_query, _offset, 1, _changesPerPage)]]"
hidden$="[[_hideNextArrow(_loading, _changesPerPage)]]" hidden>
hidden$="[[_hideNextArrow(_loading)]]" hidden>
Next &rarr;</a>
</nav>
</div>

View File

@ -134,8 +134,9 @@
return offset === 0;
},
_hideNextArrow: function(loading, changesPerPage) {
return loading || !this._changes || this._changes.length < changesPerPage;
_hideNextArrow: function(loading) {
return loading || !this._changes || !this._changes.length ||
!this._changes[this._changes.length - 1]._more_changes;
},
_handleNextPage: function() {

View File

@ -86,16 +86,21 @@ limitations under the License.
test('_hideNextArrow', function() {
var loading = true;
var changesPerPage = 25;
assert.isTrue(element._hideNextArrow(loading, changesPerPage));
assert.isTrue(element._hideNextArrow(loading));
loading = false;
assert.isTrue(element._hideNextArrow(loading, changesPerPage));
assert.isTrue(element._hideNextArrow(loading));
element._changes = [];
assert.isTrue(element._hideNextArrow(loading));
element._changes =
Array.apply(null, Array(5)).map(Number.prototype.valueOf, 0);
assert.isTrue(element._hideNextArrow(loading, changesPerPage));
Array.apply(null, Array(5)).map(Object.prototype.valueOf, {});
assert.isTrue(element._hideNextArrow(loading));
element._changes =
Array.apply(null, Array(25)).map(Number.prototype.valueOf, 0);
assert.isFalse(element._hideNextArrow(loading, changesPerPage));
Array.apply(null, Array(25)).map(Object.prototype.valueOf,
{_more_changes: true});
assert.isFalse(element._hideNextArrow(loading));
element._changes =
Array.apply(null, Array(25)).map(Object.prototype.valueOf, {});
assert.isTrue(element._hideNextArrow(loading));
});
test('_handleNextPage', function() {