TsuyoshiSuzukief 7 лет назад
Родитель
Сommit
ef9b33f5c3
2 измененных файлов с 22 добавлено и 11 удалено
  1. 3 2
      src/client/js/components/RecentCreated/RecentCreated.js
  2. 19 9
      src/server/models/page.js

+ 3 - 2
src/client/js/components/RecentCreated/RecentCreated.js

@@ -27,9 +27,10 @@ export default class RecentCreated extends React.Component {
     const limit = this.state.limit;
     const offset = (selectPageNumber - 1) * limit;
 
-    this.props.crowi.apiGet('/pages.list', {page_id: pageId , user: userId , limit: limit , offset: offset , })
+    this.props.crowi.apiGet('/pages.recentCreated', {page_id: pageId , user: userId , limit: limit , offset: offset , })
       .then(res => {
-        const pages = res.pages;
+        console.log("res.pages=", res.pages);
+        const pages = res.pages[1];
         let inUse = {};
         const active = selectPageNumber;
 

+ 19 - 9
src/server/models/page.js

@@ -677,15 +677,24 @@ module.exports = function(crowi) {
     var conditions = {
       creator: user._id,
       redirectTo: null,
-      $or: [
-        {status: null},
-        {status: STATUS_PUBLISHED},
+      $and:[
+        {$or:
+          [
+            {status: null},
+            {status: STATUS_PUBLISHED},
+          ]},
+        {$or: [
+          {grant: GRANT_PUBLIC},
+          {grant: GRANT_USER_GROUP},
+        ]}
       ],
     };
 
+    /*
     if (!user.equals(currentUser._id)) {
       conditions.grant = GRANT_PUBLIC;
     }
+    */
 
     return new Promise(function(resolve, reject) {
       Page
@@ -697,12 +706,13 @@ module.exports = function(crowi) {
       .exec()
       .then(function(pages) {
         return Page.populate(pages, {path: 'lastUpdateUser', model: 'User', select: User.USER_PUBLIC_FIELDS}).then(function(data){
-          let totalCount = "";
-          totalCount = new Promise(function(rev,rej){
-            Page.find(conditions).count().populate('revision').exec().then(data);
-          });
-          data.totalCount = totalCount;
-          resolve(data);
+          let totalCount = 30;
+          // TODO- totalCount DB search
+          total = [
+            {totalCount: totalCount}
+          ];
+          total.push(data);
+          resolve(total);
         });
       });
     });