Don't show next arrow when there are not more changes on next page
The logic hiding the next arrow on the change list view was incorrect when there was a full page of results, but no more to dipslay. The API includes an attribute _more_changes on the last item of the array to let the client know whether or not there should be another page. This change uses _more_changes instead of comparing to _changesPerPage to take this edge case into account. Bug: Issue 5622 Change-Id: I17dba2c807d152485494405fb412a502ba666df6
This commit is contained in:
parent
d405bbaca3
commit
4491ff19a4
@ -62,7 +62,7 @@ limitations under the License.
|
||||
hidden$="[[_hidePrevArrow(_offset)]]" hidden>← Prev</a>
|
||||
<a id="nextArrow"
|
||||
href$="[[_computeNavLink(_query, _offset, 1, _changesPerPage)]]"
|
||||
hidden$="[[_hideNextArrow(_loading, _changesPerPage)]]" hidden>
|
||||
hidden$="[[_hideNextArrow(_loading)]]" hidden>
|
||||
Next →</a>
|
||||
</nav>
|
||||
</div>
|
||||
|
@ -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() {
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user