Просмотр исходного кода

output server side children path

zahmis 5 лет назад
Родитель
Сommit
6cb9eab7f6
2 измененных файлов с 14 добавлено и 1 удалено
  1. 5 1
      src/client/js/components/PageDuplicateModal.jsx
  2. 9 0
      src/server/routes/apiv3/pages.js

+ 5 - 1
src/client/js/components/PageDuplicateModal.jsx

@@ -44,8 +44,12 @@ const PageDuplicateModal = (props) => {
     setPageNameInput(value);
   }
 
-  function changeIsDuplicateRecursivelyHandler() {
+  async function changeIsDuplicateRecursivelyHandler() {
     setIsDuplicateRecursively(!isDuplicateRecursively);
+
+    const res = await appContainer.apiv3Get('/pages/duplicate', { path });
+    const { duplicatePath } = res;
+    console.log(duplicatePath);
   }
 
   async function duplicate() {

+ 9 - 0
src/server/routes/apiv3/pages.js

@@ -82,5 +82,14 @@ module.exports = (crowi) => {
     }
   });
 
+  router.get('/duplicate', async(req, res) => {
+    const { path } = req.query;
+    const searchWord = new RegExp(`^${path}`);
+    const duplicateData = await Page.find({ path: { $in: searchWord } });
+    const duplicatePath = duplicateData.map(element => element.path);
+    console.log(duplicatePath);
+    return res.apiv3({ duplicatePath });
+  });
+
   return router;
 };