-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(tree): add tree demo page #8749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
||
getChildren = (node: JsonNode) => { return ofObservable(node.children); } | ||
|
||
hasChild = (_: number, _nodeData: JsonFlatNode) => { return _nodeData.expandable; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tinayuangao I noticed this a week or so ago while trialling the tree; users have to define two functions that achieve the exact same result but with different signatures; isExpandable
, used by the when
, and hasChild
, used by the TreeControl. Would it be sensible to change this?
/** Tree flattener to transfrom JsonNode to JsonFlatNode */ | ||
export class TreeFlattener { | ||
|
||
static flattenNodes( structuredData: JsonNode[]): JsonFlatNode[] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra space
structuredData.forEach((node) => { | ||
this._flattenNode(node, 0, resultNodes, []); | ||
}); | ||
return resultNodes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return structuredData.map(node => this._flattenNode(node, 0, resultNodes, []));
/** Tree flattener to transfrom JsonNode to JsonFlatNode */ | ||
export class TreeFlattener { | ||
|
||
static flattenNodes( structuredData: JsonNode[]): JsonFlatNode[] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to just have module-level functions instead of static methods?
src/demo-app/tree/tree-demo.html
Outdated
<mat-card> | ||
<mat-card-header>Flattened tree</mat-card-header> | ||
|
||
<mat-tree [dataSource]="dataSource" [treeControl]="treeControl">--> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hanging -->
?
|
||
constructor(database: JsonDatabase) { | ||
// For flat tree | ||
this.treeControl = new FlatTreeControl<JsonFlatNode>(this.getLevel, this.isExpandable); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to use a more real-world example, such as collection of directories?
7b0ae83
to
d93eef7
Compare
Comments addressed. Please take a look. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
No description provided.