imporove sorting management and reduce repetitive code (#381)

* rework sorting management

* remove fdescribe

* test fixes

* unified desctructor

* unified page reload

* test fixes

* code fixes

* test fixes

* test fixes
This commit is contained in:
Denys Vuika
2018-06-02 16:35:55 +01:00
committed by Cilibiu Bogdan
parent 0ac33f820b
commit 7bb0905045
23 changed files with 195 additions and 486 deletions

View File

@@ -25,18 +25,36 @@
import { MinimalNodeEntity, MinimalNodeEntryEntity, Pagination } from 'alfresco-js-api';
import { UserPreferencesService } from '@alfresco/adf-core';
import { ShareDataRow } from '@alfresco/adf-content-services';
import { ShareDataRow, DocumentListComponent } from '@alfresco/adf-content-services';
import { ActivatedRoute } from '@angular/router';
import { OnDestroy, ViewChild } from '@angular/core';
import { Subscription } from 'rxjs/Rx';
export abstract class PageComponent implements OnDestroy {
@ViewChild(DocumentListComponent)
documentList: DocumentListComponent;
export abstract class PageComponent {
title = 'Page';
infoDrawerOpened = false;
node: MinimalNodeEntryEntity;
protected subscriptions: Subscription[] = [];
get sortingPreferenceKey(): string {
return this.route.snapshot.data.sortingPreferenceKey;
}
static isLockedNode(node) {
return node.isLocked || (node.properties && node.properties['cm:lockType'] === 'READ_ONLY_LOCK');
}
constructor(protected preferences: UserPreferencesService) {
constructor(protected preferences: UserPreferencesService, protected route: ActivatedRoute) {
}
ngOnDestroy() {
this.subscriptions.forEach(subscription => subscription.unsubscribe());
this.subscriptions = [];
}
getParentNodeId(): string {
@@ -121,4 +139,11 @@ export abstract class PageComponent {
this.infoDrawerOpened = !this.infoDrawerOpened;
}
reload(): void {
if (this.documentList) {
this.documentList.resetSelection();
this.documentList.reload();
}
}
}