Skip to content

Instantly share code, notes, and snippets.

@thomsbg
Created June 7, 2017 20:50
Show Gist options
  • Save thomsbg/3cf8ec573f58c6bc2b0d59c1976d58c7 to your computer and use it in GitHub Desktop.
Save thomsbg/3cf8ec573f58c6bc2b0d59c1976d58c7 to your computer and use it in GitHub Desktop.
diff --git a/client/actions/groups.js b/client/actions/groups.js
index bc8e4f61d..175ce42bc 100644
--- a/client/actions/groups.js
+++ b/client/actions/groups.js
@@ -36,11 +36,11 @@ export function getAllParents(group, groups) {
return [group];
}
-function childrenOf(group, groups) {
- var children = sortBy(compact(group.child_entry_group_ids.map((id) => {
- return groups.find(group => group.id === id);
- })), 'name');
- group.children = children;
+function childrenOf(parent, groups) {
+ var children = sortBy(groups.filter(group => {
+ return group.parent_entry_group_id == parent.id;
+ }), 'name');
+ parent.children = children;
return children;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment