You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by benkeen <gi...@git.apache.org> on 2015/11/26 00:35:49 UTC
[GitHub] couchdb-fauxton pull request: Pagination update
GitHub user benkeen opened a pull request:
https://github.com/apache/couchdb-fauxton/pull/584
Pagination update
This refactors the <Pagination /> element to make it a bit more
generic. Namely:
- max visible pages that appear in pagination is now configurable
- optional callback function to be called when the user clicks
a pagination link, instead of just outputting an href on the <a>
tags
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/benkeen/couchdb-fauxton pagination-update
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/couchdb-fauxton/pull/584.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #584
----
commit 7654a0cf51f5e3ff4b599da1ffd5a063320fd37f
Author: Ben Keen <be...@gmail.com>
Date: 2015-11-16T20:39:05Z
testing
commit 816e7962b75fd599a78afda3c28553bffac4eb75
Author: Ben Keen <be...@gmail.com>
Date: 2015-11-25T23:11:23Z
Pagination component update
This refactors the <Pagination /> element to make it a bit more
generic. Namely:
- max visible pages that appear in pagination is now configurable
- can add a callback function to be called when the user clicks
a pagination link, instead of just outputting an href on the <a>
tags
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: Pagination update
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on the pull request:
https://github.com/apache/couchdb-fauxton/pull/584#issuecomment-159944641
+1 when green
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: Pagination update
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/couchdb-fauxton/pull/584
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: Pagination update
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/584#discussion_r45990170
--- Diff: app/addons/fauxton/tests/componentsSpec.react.jsx ---
@@ -202,6 +202,50 @@ define([
assert.equal("30", lis[10].innerText);
});
+ it('limits the number of total pages when customized', function () {
+ var maxNavPages = 15;
+ var pageEl = TestUtils.renderIntoDocument(
+ <Views.Pagination page={1} total={1000} maxNavPages={maxNavPages} />,
+ container
+ );
+ var lis = pageEl.getDOMNode().getElementsByTagName("li");
+ assert.equal(1 + maxNavPages + 1, lis.length);
+ });
+
+ it('calls callback method when supplied', function () {
+ var spy = sinon.spy();
+ var pageEl = TestUtils.renderIntoDocument(
+ <Views.Pagination page={1} total={100} onClick={spy} />,
+ container
+ );
+ var links = React.findDOMNode(pageEl).getElementsByTagName("a");
+
+ TestUtils.Simulate.click(links[3]);
+
+ // confirm it gets called
+ assert.ok(spy.calledOnce);
+
+ // confirm it's called with the pagination number (3)
+ assert.ok(spy.calledWith(3));
+ });
+
+ it('calls callback method with correct values for prev and next', function () {
+ var spy = sinon.spy();
+
+ var currentPage = 5;
+ var pageEl = TestUtils.renderIntoDocument(
+ <Views.Pagination page={currentPage} total={200} onClick={spy} />,
+ container
+ );
+ var links = React.findDOMNode(pageEl).getElementsByTagName("a");
+
+ TestUtils.Simulate.click(links[0]);
+ assert.ok(spy.calledWith(currentPage - 1));
+
+ TestUtils.Simulate.click(links[11]); // last index
+ assert.ok(spy.calledWith(currentPage + 1));
+ });
+
--- End diff --
i really like the avoidance of jquery here i am usually to lazy to do that in my tests
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---