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
2a4f264a
Commit
2a4f264a
authored
Apr 11, 2016
by
Elias Nahum
Committed by
Juorder Antonio
May 24, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add pagination to companies section
parent
2b204ae9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
5 deletions
+36
-5
companies.jsx
src/components/companies/companies.jsx
+36
-5
No files found.
src/components/companies/companies.jsx
View file @
2a4f264a
...
@@ -8,6 +8,7 @@ import Promise from 'bluebird';
...
@@ -8,6 +8,7 @@ import Promise from 'bluebird';
import
MessageBar
from
'../message_bar.jsx'
;
import
MessageBar
from
'../message_bar.jsx'
;
import
PageInfo
from
'../page_info.jsx'
;
import
PageInfo
from
'../page_info.jsx'
;
import
Panel
from
'../panel.jsx'
;
import
Panel
from
'../panel.jsx'
;
import
Pagination
from
'../pagination.jsx'
;
import
CompaniesStore
from
'../../stores/company_store.jsx'
;
import
CompaniesStore
from
'../../stores/company_store.jsx'
;
import
ZimbraStore
from
'../../stores/zimbra_store.jsx'
;
import
ZimbraStore
from
'../../stores/zimbra_store.jsx'
;
...
@@ -26,12 +27,16 @@ export default class Companies extends React.Component {
...
@@ -26,12 +27,16 @@ export default class Companies extends React.Component {
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
);
super
(
props
);
this
.
state
=
{};
this
.
getCompanies
=
this
.
getCompanies
.
bind
(
this
);
this
.
getCompanies
=
this
.
getCompanies
.
bind
(
this
);
this
.
getDomains
=
this
.
getDomains
.
bind
(
this
);
this
.
getDomains
=
this
.
getDomains
.
bind
(
this
);
this
.
getPlans
=
this
.
getPlans
.
bind
(
this
);
this
.
getPlans
=
this
.
getPlans
.
bind
(
this
);
this
.
gotoCompany
=
this
.
gotoCompany
.
bind
(
this
);
this
.
gotoCompany
=
this
.
gotoCompany
.
bind
(
this
);
const
page
=
parseInt
(
this
.
props
.
location
.
query
.
page
,
10
)
||
1
;
this
.
state
=
{
page
,
offset
:
((
page
-
1
)
*
Constants
.
QueryOptions
.
DEFAULT_LIMIT
)
};
this
.
isGlobalAdmin
=
UserStore
.
isGlobalAdmin
();
this
.
isGlobalAdmin
=
UserStore
.
isGlobalAdmin
();
}
}
...
@@ -160,7 +165,15 @@ export default class Companies extends React.Component {
...
@@ -160,7 +165,15 @@ export default class Companies extends React.Component {
});
});
}
}
componentWillReceiveProps
()
{
componentWillReceiveProps
(
nextProps
)
{
const
arePagesDiff
=
(
nextProps
.
location
.
query
.
page
!==
this
.
props
.
location
.
query
.
page
);
if
(
arePagesDiff
)
{
const
page
=
parseInt
(
nextProps
.
location
.
query
.
page
,
10
)
||
1
;
this
.
setState
({
page
,
offset
:
((
page
-
1
)
*
Constants
.
QueryOptions
.
DEFAULT_LIMIT
)
});
}
GlobalActions
.
emitEndLoading
();
GlobalActions
.
emitEndLoading
();
}
}
...
@@ -180,6 +193,8 @@ export default class Companies extends React.Component {
...
@@ -180,6 +193,8 @@ export default class Companies extends React.Component {
let
panelBody
;
let
panelBody
;
let
noLimitError
;
let
noLimitError
;
let
pagination
=
null
;
if
(
this
.
state
.
companies
.
length
===
0
)
{
if
(
this
.
state
.
companies
.
length
===
0
)
{
panelBody
=
(
panelBody
=
(
<
div
className=
'center-block text-center'
>
<
div
className=
'center-block text-center'
>
...
@@ -192,7 +207,23 @@ export default class Companies extends React.Component {
...
@@ -192,7 +207,23 @@ export default class Companies extends React.Component {
</
div
>
</
div
>
);
);
}
else
{
}
else
{
const
rows
=
this
.
state
.
companies
.
map
((
c
)
=>
{
const
data
=
this
.
state
.
companies
;
if
(
data
.
length
>
Constants
.
QueryOptions
.
DEFAULT_LIMIT
)
{
const
totalPages
=
Math
.
ceil
(
data
.
length
/
Constants
.
QueryOptions
.
DEFAULT_LIMIT
);
pagination
=
(
<
Pagination
key=
'panelPaginationCompanies'
url=
'companies'
currentPage=
{
this
.
state
.
page
}
totalPages=
{
totalPages
}
/>
);
}
const
chunk
=
data
.
slice
(
this
.
state
.
offset
,
(
this
.
state
.
page
*
Constants
.
QueryOptions
.
DEFAULT_LIMIT
));
const
rows
=
chunk
.
map
((
c
)
=>
{
const
cos
=
Utils
.
getEnabledPlansByCosId
(
ZimbraStore
.
getAllCos
());
const
cos
=
Utils
.
getEnabledPlansByCosId
(
ZimbraStore
.
getAllCos
());
const
plansString
=
[];
const
plansString
=
[];
const
domains
=
c
.
domains
;
const
domains
=
c
.
domains
;
...
@@ -290,7 +321,7 @@ export default class Companies extends React.Component {
...
@@ -290,7 +321,7 @@ export default class Companies extends React.Component {
<
div
className=
'col-md-12 central-content'
>
<
div
className=
'col-md-12 central-content'
>
<
Panel
<
Panel
hasHeader=
{
false
}
hasHeader=
{
false
}
children=
{
panelBody
}
children=
{
[
panelBody
,
pagination
]
}
/>
/>
</
div
>
</
div
>
</
div
>
</
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