mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-09-17 14:21:14 +00:00
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:
committed by
Cilibiu Bogdan
parent
0ac33f820b
commit
7bb0905045
@@ -23,8 +23,8 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Observable, Subscription } from 'rxjs/Rx';
|
||||
import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Router, ActivatedRoute, Params } from '@angular/router';
|
||||
import { MinimalNodeEntity, MinimalNodeEntryEntity, PathElementEntity, NodePaging, PathElement } from 'alfresco-js-api';
|
||||
import {
|
||||
@@ -32,8 +32,6 @@ import {
|
||||
ContentService, AlfrescoApiService, UserPreferencesService, NotificationService
|
||||
} from '@alfresco/adf-core';
|
||||
|
||||
import { DocumentListComponent } from '@alfresco/adf-content-services';
|
||||
|
||||
import { BrowsingFilesService } from '../../common/services/browsing-files.service';
|
||||
import { ContentManagementService } from '../../common/services/content-management.service';
|
||||
import { NodeActionsService } from '../../common/services/node-actions.service';
|
||||
@@ -45,17 +43,13 @@ import { PageComponent } from '../page.component';
|
||||
templateUrl: './files.component.html'
|
||||
})
|
||||
export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||
@ViewChild(DocumentListComponent) documentList: DocumentListComponent;
|
||||
|
||||
isValidPath = true;
|
||||
|
||||
private nodePath: PathElement[];
|
||||
private subscriptions: Subscription[] = [];
|
||||
|
||||
sorting = [ 'modifiedAt', 'desc' ];
|
||||
|
||||
constructor(private router: Router,
|
||||
private route: ActivatedRoute,
|
||||
route: ActivatedRoute,
|
||||
private nodesApi: NodesApiService,
|
||||
private nodeActionsService: NodeActionsService,
|
||||
private uploadService: UploadService,
|
||||
@@ -66,12 +60,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||
private notificationService: NotificationService,
|
||||
public permission: NodePermissionService,
|
||||
preferences: UserPreferencesService) {
|
||||
super(preferences);
|
||||
|
||||
const sortingKey = this.preferences.get(`${this.prefix}.sorting.key`) || 'modifiedAt';
|
||||
const sortingDirection = this.preferences.get(`${this.prefix}.sorting.direction`) || 'desc';
|
||||
|
||||
this.sorting = [sortingKey, sortingDirection];
|
||||
super(preferences, route);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -116,8 +105,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.forEach(s => s.unsubscribe());
|
||||
|
||||
super.ngOnDestroy();
|
||||
this.browsingFilesService.onChangeParent.next(null);
|
||||
}
|
||||
|
||||
@@ -269,19 +257,10 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||
return false;
|
||||
}
|
||||
|
||||
onSortingChanged(event: CustomEvent) {
|
||||
this.preferences.set(`${this.prefix}.sorting.key`, event.detail.key || 'modifiedAt');
|
||||
this.preferences.set(`${this.prefix}.sorting.direction`, event.detail.direction || 'desc');
|
||||
}
|
||||
|
||||
openSnackMessage(event: any) {
|
||||
this.notificationService.openSnackMessage(
|
||||
event,
|
||||
4000
|
||||
);
|
||||
}
|
||||
|
||||
private get prefix() {
|
||||
return this.route.snapshot.data.preferencePrefix;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user