Skip to content

Commit

Permalink
update implementation of openAncestors to use collect
Browse files Browse the repository at this point in the history
  • Loading branch information
griest024 committed Aug 1, 2024
1 parent a54b334 commit 58acbec
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions libs/design/tree/src/tree-item/tree-item.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
Input,
} from '@angular/core';

import { collect } from '@daffodil/core';

import { DaffTreeUi } from '../interfaces/tree-ui';
import { DaffTreeNotifierService } from '../tree/tree-notifier.service';
import { DaffTreeFlatNode } from '../utils/flatten-tree';
Expand Down Expand Up @@ -141,14 +143,7 @@ export class DaffTreeItemDirective {
* Opens parent and parent of parent all the way to the root of the tree.
*/
openAncestors() {
const openParent = (tree: DaffTreeUi<unknown>) => {
if (tree?.parent.parent === undefined) {
return;
}
tree.parent.open = true;
openParent(tree.parent);
};
openParent(this._node._treeRef);
collect(this._node._treeRef, (node) => [node.parent], this._node.level).forEach((node) => node.open = true);
this.treeNotifier.notify();
}

Expand Down

0 comments on commit 58acbec

Please sign in to comment.