@@ -20,8 +20,8 @@ export class DynamicFlatNode {
20
20
21
21
22
22
/**
23
- * Database for dynamic data. When expanding a node in the tree, the data source will need to fetch
24
- * the descendants data from the database.
23
+ * Database for dynamic data. When expanding a node in the tree, the data
24
+ * source will need to fetch the descendants data from the database.
25
25
*/
26
26
export class DynamicDatabase {
27
27
dataMap = new Map ( [
@@ -47,12 +47,11 @@ export class DynamicDatabase {
47
47
return this . dataMap . has ( node ) ;
48
48
}
49
49
}
50
+
50
51
/**
51
- * File database, it can build a tree structured Json object from string.
52
- * Each node in Json object represents a file or a directory. For a file, it has filename and type.
53
- * For a directory, it has filename and children (a list of files or directories).
54
- * The input will be a json object string, and the output is a list of `FileNode` with nested
55
- * structure.
52
+ * Plant database that can build a tree-structured JSON object from a string. Each node in the
53
+ * object represents a plant or a group of plants. The input will be a JSON object string, and
54
+ * the output is a list of `FileNode`-s with a nested structure.
56
55
*/
57
56
@Injectable ( )
58
57
export class DynamicDataSource {
@@ -81,11 +80,11 @@ export class DynamicDataSource {
81
80
/** Handle expand/collapse behaviors */
82
81
handleTreeControl ( change : SelectionChange < DynamicFlatNode > ) {
83
82
if ( change . added ) {
84
- change . added . forEach ( ( node ) => this . toggleNode ( node , true ) ) ;
83
+ change . added . forEach ( node => this . toggleNode ( node , true ) ) ;
85
84
}
86
85
if ( change . removed ) {
87
86
// Use reverse to remove from bottom to top
88
- change . removed . reverse ( ) . forEach ( ( node ) => this . toggleNode ( node , false ) ) ;
87
+ change . removed . slice ( ) . reverse ( ) . forEach ( node => this . toggleNode ( node , false ) ) ;
89
88
}
90
89
}
91
90
0 commit comments