Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zimbra-admin-api-js
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Public
zimbra-admin-api-js
Commits
7e065f40
Commit
7e065f40
authored
Apr 18, 2016
by
enahum
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #19 from ZBoxApp/pagination
Pagination with first, prev, next and last
parents
4505d6e4
b3565c27
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
8 deletions
+72
-8
pagination.jsx
src/components/pagination.jsx
+72
-8
No files found.
src/components/pagination.jsx
View file @
7e065f40
...
...
@@ -4,7 +4,25 @@ import {browserHistory} from 'react-router';
export
default
class
Pagination
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
handleFirst
=
this
.
handleFirst
.
bind
(
this
);
this
.
handlePrev
=
this
.
handlePrev
.
bind
(
this
);
this
.
handleChange
=
this
.
handleChange
.
bind
(
this
);
this
.
handleNext
=
this
.
handleNext
.
bind
(
this
);
this
.
handleLast
=
this
.
handleLast
.
bind
(
this
);
}
handleFirst
(
e
)
{
e
.
preventDefault
();
browserHistory
.
push
(
`/
${
this
.
props
.
url
}
`
);
}
handlePrev
(
e
)
{
e
.
preventDefault
();
const
prevPage
=
this
.
props
.
currentPage
-
1
;
if
(
prevPage
>
1
)
{
browserHistory
.
push
(
`/
${
this
.
props
.
url
}
?page=
${
prevPage
}
`
);
}
else
{
browserHistory
.
push
(
`/
${
this
.
props
.
url
}
`
);
}
}
handleChange
(
e
)
{
e
.
preventDefault
();
...
...
@@ -17,20 +35,60 @@ export default class Pagination extends React.Component {
browserHistory
.
push
(
`/
${
this
.
props
.
url
}${
pageUrl
}
`
);
}
handleNext
(
e
)
{
e
.
preventDefault
();
browserHistory
.
push
(
`/
${
this
.
props
.
url
}
?page=
${
this
.
props
.
currentPage
+
1
}
`
);
}
handleLast
(
e
)
{
e
.
preventDefault
();
browserHistory
.
push
(
`/
${
this
.
props
.
url
}
?page=
${
this
.
props
.
totalPages
}
`
);
}
render
()
{
const
total
=
this
.
props
.
totalPages
;
const
current
=
this
.
props
.
currentPage
;
const
pages
=
[];
//
let first;
//
let prev;
//
let next;
//
let last;
let
first
;
let
prev
;
let
next
;
let
last
;
let
i
=
1
;
// if (current > 1 && current < total) {
//
// }
if
(
current
>
1
&&
current
<=
total
)
{
first
=
(
<
li
key=
'first-page'
>
<
a
onClick=
{
this
.
handleFirst
}
>
{
'Primera'
}
</
a
>
</
li
>
);
prev
=
(
<
li
key=
'prev-page'
>
<
a
onClick=
{
this
.
handlePrev
}
>
{
'Ant.'
}
</
a
>
</
li
>
);
}
if
(
current
<
total
)
{
next
=
(
<
li
key=
'next-page'
>
<
a
onClick=
{
this
.
handleNext
}
>
{
'Sig.'
}
</
a
>
</
li
>
);
last
=
(
<
li
key=
'last-page'
>
<
a
onClick=
{
this
.
handleLast
}
>
{
'Última'
}
</
a
>
</
li
>
);
}
for
(;
i
<=
total
;
i
++
)
{
if
(
current
===
i
)
{
...
...
@@ -47,7 +105,9 @@ export default class Pagination extends React.Component {
<
li
key=
{
`page-${i}`
}
>
<
a
onClick=
{
this
.
handleChange
}
>
{
i
.
toString
()
}
</
a
>
>
{
i
.
toString
()
}
</
a
>
</
li
>
);
}
...
...
@@ -56,7 +116,11 @@ export default class Pagination extends React.Component {
return
(
<
div
className=
'pagination'
>
<
ul
className=
'pagination'
>
{
first
}
{
prev
}
{
pages
}
{
next
}
{
last
}
</
ul
>
</
div
>
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment