Ver Fonte

child group --> descendant group

Shun Miyazawa há 4 anos atrás
pai
commit
1cbbbda110
1 ficheiros alterados com 6 adições e 3 exclusões
  1. 6 3
      packages/app/src/server/routes/apiv3/user-group.js

+ 6 - 3
packages/app/src/server/routes/apiv3/user-group.js

@@ -275,9 +275,12 @@ module.exports = (crowi) => {
     const { groupId } = req.query;
 
     try {
-      const childGroups = await UserGroup.findChildUserGroupsByParentIds([groupId], false);
-      const childGroupIds = childGroups.childUserGroups.map(userGroups => userGroups._id.toString());
-      const selectableParentGroups = await UserGroup.find({ _id: { $nin: [groupId, ...childGroupIds] } });
+      const userGroup = await UserGroup.findById(groupId);
+
+      const descendantGroups = await UserGroup.findGroupsWithDescendantsRecursively([userGroup], []);
+      const descendantGroupIds = descendantGroups.map(userGroups => userGroups._id.toString());
+
+      const selectableParentGroups = await UserGroup.find({ _id: { $nin: [groupId, ...descendantGroupIds] } });
       return res.apiv3({ selectableParentGroups });
     }
     catch (err) {