yusuketk 5 anni fa
parent
commit
f14b4d5532

+ 4 - 4
src/client/js/components/ArchiveCreateModal.jsx

@@ -14,7 +14,7 @@ const ArchiveCreateModal = (props) => {
   const [isCommentDownload, setIsCommentDownload] = useState(false);
   const [isAttachmentFileDownload, setIsAttachmentFileDownload] = useState(false);
   const [isSubordinatedPageDownload, setIsSubordinatedPageDownload] = useState(false);
-  const [fileType, setFileType] = useState('markDown');
+  const [fileType, setFileType] = useState('markdown');
   const [hierarchyType, setHierarchyType] = useState('allSubordinatedPage');
   const [hierarchyValue, setHierarchyValue] = useState(1);
 
@@ -57,7 +57,7 @@ const ArchiveCreateModal = (props) => {
 
     try {
       await appContainer.apiv3Post('/page/archive', {
-        basePagePath: props.path,
+        rootPagePath: props.path,
         isCommentDownload,
         isAttachmentFileDownload,
         isSubordinatedPageDownload,
@@ -95,9 +95,9 @@ const ArchiveCreateModal = (props) => {
               id="customRadio1"
               name="isFileType"
               value="customRadio1"
-              checked={fileType === 'markDown'}
+              checked={fileType === 'markdown'}
               onChange={() => {
-                handleChangeFileType('markDown');
+                handleChangeFileType('markdown');
               }}
             />
             <label className="custom-control-label" htmlFor="customRadio1">

+ 4 - 5
src/server/models/page-archive.js

@@ -3,11 +3,10 @@ module.exports = function(crowi) {
   const ObjectId = mongoose.Schema.Types.ObjectId;
 
   const pageArchiveSchema = new mongoose.Schema({
-    filePath: { type: String, required: true },
-    creator: { type: ObjectId, ref: 'User', index: true },
-    basePagePath: { type: String, required: true },
-    fileType: { type: String },
-    NumOfPages: { type: Number },
+    owner: { type: ObjectId, ref: 'User', index: true },
+    rootPagePath: { type: String, required: true },
+    fileType: { type: String, enum: ['pdf', 'markdown'] },
+    numOfPages: { type: Number },
     hasComment: { type: Boolean },
     hasAttachment: { type: Boolean },
   }, {

+ 9 - 14
src/server/routes/apiv3/page.js

@@ -130,7 +130,7 @@ module.exports = (crowi) => {
       body('isCommentDownload').isBoolean(),
       body('isAttachmentFileDownload').isBoolean(),
       body('isSubordinatedPageDownload').isBoolean(),
-      body('fileType').isString().isIn(['pdf', 'markDown']),
+      body('fileType').isString().isIn(['pdf', 'markdown']),
       body('hierarchyType').isString().isIn(['allSubordinatedPage', 'decideHierarchy']),
       body('hierarchyValue').isNumeric(),
     ],
@@ -216,28 +216,23 @@ module.exports = (crowi) => {
    *                  $ref: '#/components/schemas/Page'
    */
   router.post('/archive', accessTokenParser, loginRequired, csrf, validator.archive, apiV3FormValidator, async(req, res) => {
+    const PageArchive = crowi.model('PageArchive');
 
     const {
-      basePagePath,
+      rootPagePath,
       isCommentDownload,
       isAttachmentFileDownload,
-      isSubordinatedPageDownload,
       fileType,
-      hierarchyType,
-      hierarchyValue,
     } = req.body;
-    const PageArchive = crowi.model('PageArchive');
+    const owner = req.user._id;
 
-    const filePath = 'path'; // TODO ファイル作成タスクにてアーカイブzipファイルのパスを入れる
-    const NumOfPages = 1; // TODO 最終的なページ数を入れる
-    const creator = req.user._id;
+    const numOfPages = 1; // TODO 最終的にzipファイルに取り込むページ数を入れる
 
-    const archive = await PageArchive.create({
-      filePath,
-      creator,
+    await PageArchive.create({
+      owner,
       fileType,
-      basePagePath,
-      NumOfPages,
+      rootPagePath,
+      numOfPages,
       hasComment: isCommentDownload,
       hasAttachment: isAttachmentFileDownload});
   });