|
@@ -97,16 +97,6 @@ class UserGroup {
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- static async findGroupsWithDescendantsRecursively(groups, descendants = groups) {
|
|
|
|
|
- const nextGroups = await this.find({ parent: { $in: groups.map(g => g._id) } });
|
|
|
|
|
-
|
|
|
|
|
- if (nextGroups.length === 0) {
|
|
|
|
|
- return descendants;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return this.findAllAncestorGroups(nextGroups, descendants.concat(nextGroups));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
// Delete completely
|
|
// Delete completely
|
|
|
static async removeCompletelyByRootGroupId(deleteRootGroupId, action, transferToUserGroupId, user) {
|
|
static async removeCompletelyByRootGroupId(deleteRootGroupId, action, transferToUserGroupId, user) {
|
|
|
const UserGroupRelation = mongoose.model('UserGroupRelation');
|
|
const UserGroupRelation = mongoose.model('UserGroupRelation');
|
|
@@ -161,6 +151,16 @@ class UserGroup {
|
|
|
return this.findAllAncestorGroups(nextParent, ancestors);
|
|
return this.findAllAncestorGroups(nextParent, ancestors);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ static async findGroupsWithDescendantsRecursively(groups, descendants = groups) {
|
|
|
|
|
+ const nextGroups = await this.find({ parent: { $in: groups.map(g => g._id) } });
|
|
|
|
|
+
|
|
|
|
|
+ if (nextGroups.length === 0) {
|
|
|
|
|
+ return descendants;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return this.findGroupsWithDescendantsRecursively(nextGroups, descendants.concat(nextGroups));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// TODO 85062: write test code
|
|
// TODO 85062: write test code
|
|
|
static async updateGroup(id, name, description, parentId, forceUpdateParents = false) {
|
|
static async updateGroup(id, name, description, parentId, forceUpdateParents = false) {
|
|
|
const userGroup = await this.findById(id);
|
|
const userGroup = await this.findById(id);
|