Prechádzať zdrojové kódy

Moved new_checklist_item API to correct file where is other checklist item API.

Thanks to xet7 !
Lauri Ojansivu 2 rokov pred
rodič
commit
9de7040401
2 zmenil súbory, kde vykonal 45 pridanie a 45 odobranie
  1. 45 0
      models/checklistItems.js
  2. 0 45
      models/checklists.js

+ 45 - 0
models/checklistItems.js

@@ -282,6 +282,51 @@ if (Meteor.isServer) {
     },
   );
 
+  /**
+  * @operation new_checklist_item
+  * @summary add a new item to a checklist
+  *
+  * @param {string} boardId the board ID
+  * @param {string} cardId the card ID
+  * @param {string} checklistId the ID of the checklist
+  * @param {string} title the title of the new item
+  * @return_type {_id: string}
+  */
+
+  JsonRoutes.add(
+    'POST',
+    '/api/boards/:boardId/cards/:cardId/checklists/:checklistId/items',
+    function(req, res) {
+      const paramBoardId = req.params.boardId;
+      const paramChecklistId = req.params.checklistId;
+      const paramCardId = req.params.cardId;
+      Authentication.checkBoardAccess(req.userId, paramBoardId);
+      const checklist = Checklists.findOne({
+        _id: paramChecklistId,
+        cardId: paramCardId,
+      });
+      if (checklist) {
+        const id = ChecklistItems.insert({
+          cardId: paramCardId,
+          checklistId: paramChecklistId,
+          title: req.body.title,
+          isFinished: false,
+          sort: 0,
+        });
+        JsonRoutes.sendResult(res, {
+          code: 200,
+          data: {
+            _id: id,
+          },
+        });
+      } else {
+        JsonRoutes.sendResult(res, {
+          code: 404,
+        });
+      }
+    },
+  );
+
   /**
    * @operation edit_checklist_item
    * @tag Checklists

+ 0 - 45
models/checklists.js

@@ -383,51 +383,6 @@ if (Meteor.isServer) {
     },
   );
 
-  /**
-  * @operation new_checklist_item
-  * @summary add a new item to a checklist
-  *
-  * @param {string} boardId the board ID
-  * @param {string} cardId the card ID
-  * @param {string} checklistId the ID of the checklist
-  * @param {string} title the title of the new item
-  * @return_type {_id: string}
-  */
-
-  JsonRoutes.add(
-    'POST',
-    '/api/boards/:boardId/cards/:cardId/checklists/:checklistId/items',
-    function(req, res) {
-      const paramBoardId = req.params.boardId;
-      const paramChecklistId = req.params.checklistId;
-      const paramCardId = req.params.cardId;
-      Authentication.checkBoardAccess(req.userId, paramBoardId);
-      const checklist = Checklists.findOne({
-        _id: paramChecklistId,
-        cardId: paramCardId,
-      });
-      if (checklist) {
-        const id = ChecklistItems.insert({
-          cardId: paramCardId,
-          checklistId: paramChecklistId,
-          title: req.body.title,
-          isFinished: false,
-          sort: 0,
-        });
-        JsonRoutes.sendResult(res, {
-          code: 200,
-          data: {
-            _id: id,
-          },
-        });
-      } else {
-        JsonRoutes.sendResult(res, {
-          code: 404,
-        });
-      }
-    },
-  );
-
   /**
    * @operation delete_checklist
    * @summary Delete a checklist