Taichi Masuyama 4 年 前
コミット
ec8123c553
1 ファイル変更9 行追加0 行削除
  1. 9 0
      packages/app/src/server/models/page.ts

+ 9 - 0
packages/app/src/server/models/page.ts

@@ -1139,6 +1139,15 @@ export default (crowi: Crowi): any => {
     }
     }
 
 
     if (isExRestricted && grant !== GRANT_RESTRICTED) {
     if (isExRestricted && grant !== GRANT_RESTRICTED) {
+      const emptyPageAtSamePath = await this.findOne({ path: pageData.path, isEmpty: true });
+
+      if (emptyPageAtSamePath != null) {
+        // Update children's parent with new parent
+        await this.updateMany(
+          { parent: emptyPageAtSamePath._id },
+          { parent: savedPage._id },
+        );
+      }
       await this.findOneAndDelete({ path: pageData.path, isEmpty: true });
       await this.findOneAndDelete({ path: pageData.path, isEmpty: true });
     }
     }