zamis 5 лет назад
Родитель
Сommit
af009351a7

+ 4 - 2
src/client/js/components/Admin/UserGroupDetail/UserGroupPageList.jsx

@@ -17,6 +17,7 @@ class UserGroupPageList extends React.Component {
     this.state = {
       currentPages: [],
       activePage: 1,
+      totalDocs: 0,
       pagingLimit: 10,
     };
 
@@ -36,9 +37,10 @@ class UserGroupPageList extends React.Component {
         limit,
         offset,
       });
-      const { pages } = res.data;
+      const { totalDocs, pages } = res.data;
 
       this.setState({
+        totalDocs,
         activePage: pageNum,
         currentPages: pages,
       });
@@ -61,7 +63,7 @@ class UserGroupPageList extends React.Component {
           <PaginationWrapper
             activePage={this.state.activePage}
             changePage={this.handlePageChange}
-            totalItemsCount={relatedPages.length}
+            totalItemsCount={this.state.totalDocs}
             pagingLimit={this.state.pagingLimit}
             align="center"
             size="sm"

+ 2 - 2
src/server/routes/apiv3/user-group.js

@@ -578,7 +578,7 @@ module.exports = (crowi) => {
     const { limit, offset } = req.query;
 
     try {
-      const { docs, total } = await Page.paginate({
+      const { docs, totalDocs } = await Page.paginate({
         grant: Page.GRANT_USER_GROUP,
         grantedGroup: { $in: [id] },
       }, {
@@ -593,7 +593,7 @@ module.exports = (crowi) => {
       const current = offset / limit + 1;
 
       // TODO: create a common moudule for paginated response
-      return res.apiv3({ total, current, pages: docs });
+      return res.apiv3({ totalDocs, current, pages: docs });
     }
     catch (err) {
       const msg = `Error occurred in fetching pages for group: ${id}`;