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

update descendantCount from parent if grant restricted

yohei0125 4 лет назад
Родитель
Сommit
592f237173
1 измененных файлов с 5 добавлено и 0 удалено
  1. 5 0
      packages/app/src/server/models/page.ts

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

@@ -1152,6 +1152,11 @@ export default (crowi: Crowi): any => {
       await this.updateOne({ _id: newPageData._id }, { descendantCount: newDescendantCount });
       await this.updateOne({ _id: newPageData._id }, { descendantCount: newDescendantCount });
     }
     }
     else if (shouldMinusUpdateDescCount) {
     else if (shouldMinusUpdateDescCount) {
+      // Update from parent. Parent is null if newPageData.grant is RESTRECTED.
+      if (newPageData.grant === GRANT_RESTRICTED) {
+        await crowi.pageService.updateDescendantCountOfAncestors(exParent, -1, true);
+      }
+
       await crowi.pageService.updateDescendantCountOfAncestors(newPageData._id, -1, false);
       await crowi.pageService.updateDescendantCountOfAncestors(newPageData._id, -1, false);
     }
     }