Merge "Add "Page ..." next to back and forward arrows"

This commit is contained in:
Paladox none
2020-01-09 14:57:55 +00:00
committed by Gerrit Code Review
3 changed files with 13 additions and 0 deletions

View File

@@ -89,6 +89,7 @@ limitations under the License.
</div>
<slot></slot>
<nav>
Page [[_computePage(offset, itemsPerPage)]]
<a id="prevArrow"
href$="[[_computeNavLink(offset, -1, itemsPerPage, filter, path)]]"
hidden$="[[_hidePrevArrow(loading, offset)]]" hidden>

View File

@@ -104,6 +104,13 @@
const lastPage = items.length < this.itemsPerPage + 1;
return lastPage;
}
// TODO: fix offset (including itemsPerPage)
// to either support a decimal or make it go to the nearest
// whole number (e.g 3).
_computePage(offset, itemsPerPage) {
return offset / itemsPerPage + 1;
}
}
customElements.define(GrListView.is, GrListView);

View File

@@ -157,5 +157,10 @@ limitations under the License.
element.path = TAGS_PATH;
assert.equal(element._computeNavLink.lastCall.args[4], TAGS_PATH);
});
test('_computePage', () => {
assert.equal(element._computePage(0, 25), 1);
assert.equal(element._computePage(50, 25), 3);
});
});
</script>