Commits

Hrafn Malmquist authored and github-actions[bot] committed e89a277702a
Improve documentation

(cherry picked from commit d9b6e9d81f2fba70f7c13a1377e2f2472c20d592)
No tags

src/app/community-list-page/community-list/community-list.component.ts

Modified
52 52 this.communityListService.getExpandedNodesFromStore().pipe(take(1)).subscribe((result) => {
53 53 this.expandedNodes = [...result];
54 54 this.dataSource.loadCommunities(this.paginationConfig, this.expandedNodes);
55 55 });
56 56 }
57 57
58 58 ngOnDestroy(): void {
59 59 this.communityListService.saveCommunityListStateToStore(this.expandedNodes, this.loadingNode);
60 60 }
61 61
62 - // whether or not this node has children (subcommunities or collections)
62 + /**
63 + * Whether this node has children (subcommunities or collections)
64 + * @param _
65 + * @param node
66 + */
63 67 hasChild(_: number, node: FlatNode) {
64 68 return node.isExpandable$;
65 69 }
66 70
67 - // whether or not it is a show more node (contains no data, but is indication that there are more topcoms, subcoms or collections
71 + /**
72 + * Whether this is a show more node that contains no data, but indicates that there is
73 + * one or more community or collection.
74 + * @param _
75 + * @param node
76 + */
68 77 isShowMore(_: number, node: FlatNode) {
69 78 return node.isShowMoreNode;
70 79 }
71 80
72 81 /**
73 - * Toggles the expanded variable of a node, adds it to the expanded nodes list and reloads the tree so this node is expanded
82 + * Toggles the expanded variable of a node, adds it to the expanded nodes list and reloads the tree
83 + * so this node is expanded
74 84 * @param node Node we want to expand
75 85 */
76 86 toggleExpanded(node: FlatNode) {
77 87 this.loadingNode = node;
78 88 if (node.isExpanded) {
79 89 this.expandedNodes = this.expandedNodes.filter((node2) => node2.name !== node.name);
80 90 node.isExpanded = false;
81 91 } else {
82 92 this.expandedNodes.push(node);
83 93 node.isExpanded = true;
86 96 }
87 97 if (isEmpty(node.currentCommunityPage)) {
88 98 node.currentCommunityPage = 1;
89 99 }
90 100 }
91 101 this.dataSource.loadCommunities(this.paginationConfig, this.expandedNodes);
92 102 }
93 103
94 104 /**
95 105 * Makes sure the next page of a node is added to the tree (top community, sub community of collection)
96 - * > Finds its parent (if not top community) and increases its corresponding collection/subcommunity currentPage
97 - * > Reloads tree with new page added to corresponding top community lis, sub community list or collection list
98 - * @param node The show more node indicating whether it's an increase in top communities, sub communities or collections
106 + * > Finds its parent (if not top community) and increases its corresponding collection/subcommunity
107 + * currentPage
108 + * > Reloads tree with new page added to corresponding top community lis, sub community list or
109 + * collection list
110 + * @param node The show more node indicating whether it's an increase in top communities, sub communities
111 + * or collections
99 112 */
100 113 getNextPage(node: FlatNode): void {
101 114 this.loadingNode = node;
102 115 if (node.parent != null) {
103 116 if (node.id === 'collection') {
104 117 const parentNodeInExpandedNodes = this.expandedNodes.find((node2: FlatNode) => node.parent.id === node2.id);
105 118 parentNodeInExpandedNodes.currentCollectionPage++;
106 119 }
107 120 if (node.id === 'community') {
108 121 const parentNodeInExpandedNodes = this.expandedNodes.find((node2: FlatNode) => node.parent.id === node2.id);

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut