70599: Improvements comcol tree

This commit is contained in:
Marie Verdonck
2020-05-03 01:53:46 +02:00
parent bb4aedc472
commit b1e44a7fa5
4 changed files with 60 additions and 89 deletions

View File

@@ -1,5 +1,7 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { take } from 'rxjs/operators';
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { FindListOptions } from '../../core/data/request.models';
import { CommunityListService, FlatNode } from '../community-list-service';
import { CommunityListDatasource } from '../community-list-datasource';
import { FlatTreeControl } from '@angular/cdk/tree';
@@ -27,7 +29,13 @@ export class CommunityListComponent implements OnInit, OnDestroy {
dataSource: CommunityListDatasource;
paginationConfig: FindListOptions;
constructor(private communityListService: CommunityListService) {
this.paginationConfig = new FindListOptions();
this.paginationConfig.elementsPerPage = 2;
this.paginationConfig.currentPage = 1;
this.paginationConfig.sort = new SortOptions('dc.title', SortDirection.ASC);
}
ngOnInit() {
@@ -37,7 +45,7 @@ export class CommunityListComponent implements OnInit, OnDestroy {
});
this.communityListService.getExpandedNodesFromStore().pipe(take(1)).subscribe((result) => {
this.expandedNodes = [...result];
this.dataSource.loadCommunities(this.expandedNodes);
this.dataSource.loadCommunities(this.paginationConfig, this.expandedNodes);
});
}
@@ -74,7 +82,7 @@ export class CommunityListComponent implements OnInit, OnDestroy {
node.currentCommunityPage = 1;
}
}
this.dataSource.loadCommunities(this.expandedNodes);
this.dataSource.loadCommunities(this.paginationConfig, this.expandedNodes);
}
/**
@@ -94,10 +102,10 @@ export class CommunityListComponent implements OnInit, OnDestroy {
const parentNodeInExpandedNodes = this.expandedNodes.find((node2: FlatNode) => node.parent.id === node2.id);
parentNodeInExpandedNodes.currentCommunityPage++;
}
this.dataSource.loadCommunities(this.expandedNodes);
this.dataSource.loadCommunities(this.paginationConfig, this.expandedNodes);
} else {
this.communityListService.getNextPageTopCommunities();
this.dataSource.loadCommunities(this.expandedNodes);
this.paginationConfig.currentPage++;
this.dataSource.loadCommunities(this.paginationConfig, this.expandedNodes);
}
}