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

Tells the user which page they are on. This is already done on the
change list.

Bug: Issue 12108
Change-Id: Ic565cc76cc977955b71c12b9753b72c425b9f126
This commit is contained in:
Paladox none
2019-12-29 21:54:12 +00:00
parent 494d93fd26
commit e7cb81951d
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>