فهرست منبع

Merge branch 'feat/transplant-tabs-to-modal-for-master-merge' into add-pagination-for-displaying-attachment-data

zahmis 5 سال پیش
والد
کامیت
4b793dc736
2فایلهای تغییر یافته به همراه7 افزوده شده و 7 حذف شده
  1. 5 3
      src/client/js/components/PageAttachment.jsx
  2. 2 4
      src/server/routes/apiv3/attachment.js

+ 5 - 3
src/client/js/components/PageAttachment.jsx

@@ -59,10 +59,12 @@ class PageAttachment extends React.Component {
 
     if (!pageId) { return }
 
+    const limit = 10;
+    // offset値は、dummy data この後のタスクで実装
+    const offset = 0;
+    const res = await this.props.appContainer.apiv3Get('/attachment/list', { pageId, limit, offset });
+    const attachments = res.data.paginateResult.docs;
     const inUse = {};
-    const res = await appContainer.apiv3Get('/attachment/list', { pageId });
-    const attachments = res.data.result.attachments;
-
 
     for (const attachment of attachments) {
       inUse[attachment._id] = this.checkIfFileInUse(attachment);

+ 2 - 4
src/server/routes/apiv3/attachment.js

@@ -52,14 +52,12 @@ module.exports = (crowi) => {
         return res.apiv3Err(new ErrorV3(msg, 'attachment-list-failed'), 403);
       }
 
-      const attachments = await Attachment.find({ page: pageId });
-      const pagination = await Attachment.paginate(
+      const paginateResult = await Attachment.paginate(
         { page: pageId },
         queryOptions,
       );
 
-      const result = { attachments, pagination };
-      return res.apiv3({ result });
+      return res.apiv3({ paginateResult });
 
 
     }