mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-551] sorting for document list (#1891)
* table cell component - table cell component with performance improvements * permissions and sorting fixes - fixed ability to set default sorting - fixed permission evaluation - new: context menu now also works with permissions - disabled tags column in demo shell due to performance implications * fix unit tests * fix tsconfig for unit testing
This commit is contained in:
committed by
Eugenio Romano
parent
ef5bb6333c
commit
da18a21e7c
@@ -28,7 +28,8 @@ import {
|
||||
ObjectDataColumn,
|
||||
DataCellEvent,
|
||||
DataRowActionEvent,
|
||||
DataColumn
|
||||
DataColumn,
|
||||
DataSorting
|
||||
} from 'ng2-alfresco-datatable';
|
||||
import { DocumentListService } from './../services/document-list.service';
|
||||
import { ContentActionModel } from './../models/content-action.model';
|
||||
@@ -156,8 +157,6 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
||||
private translateService: AlfrescoTranslationService,
|
||||
private el: ElementRef) {
|
||||
|
||||
this.data = new ShareDataTableAdapter(this.documentListService);
|
||||
|
||||
if (translateService) {
|
||||
translateService.addTranslationFolder('ng2-alfresco-documentlist', 'node_modules/ng2-alfresco-documentlist/src');
|
||||
}
|
||||
@@ -186,6 +185,7 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.data = new ShareDataTableAdapter(this.documentListService, null, this.getDefaultSorting());
|
||||
this.data.thumbnails = this.thumbnails;
|
||||
this.contextActionHandler.subscribe(val => this.contextActionCallback(val));
|
||||
|
||||
@@ -200,7 +200,7 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
||||
}
|
||||
|
||||
if (!this.data) {
|
||||
this.data = new ShareDataTableAdapter(this.documentListService, schema);
|
||||
this.data = new ShareDataTableAdapter(this.documentListService, schema, this.getDefaultSorting());
|
||||
} else if (schema && schema.length > 0) {
|
||||
this.data.setColumns(schema);
|
||||
}
|
||||
@@ -209,18 +209,6 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
||||
if (!columns || columns.length === 0) {
|
||||
this.setupDefaultColumns();
|
||||
}
|
||||
|
||||
// TODO: commented out as Permissions feature (Context Menus and Row Actions) breaks all component functionality
|
||||
/*
|
||||
if (this.sorting) {
|
||||
const [ key, direction ] = this.sorting;
|
||||
|
||||
this.data.setSorting({
|
||||
key,
|
||||
direction: direction || 'asc'
|
||||
});
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
@@ -294,28 +282,21 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
||||
|
||||
if (target) {
|
||||
let ltarget = target.toLowerCase();
|
||||
let actionWithPermission = this.checkPermissions(node);
|
||||
|
||||
let actionsByTarget = actionWithPermission.filter(entry => {
|
||||
let actionsByTarget = this.actions.filter(entry => {
|
||||
return entry.target.toLowerCase() === ltarget;
|
||||
}).map(action => new ContentActionModel(action));
|
||||
|
||||
actionsByTarget.forEach((action) => {
|
||||
this.checkPermission(node, action);
|
||||
});
|
||||
|
||||
let cloneActions = Object.create(actionsByTarget);
|
||||
return cloneActions;
|
||||
return actionsByTarget;
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
checkPermissions(node: MinimalNodeEntity): ContentActionModel[] {
|
||||
let actionsPermission: ContentActionModel[] = [];
|
||||
this.actions.forEach((action) => {
|
||||
actionsPermission.push(this.checkPermission(node, action));
|
||||
});
|
||||
return actionsPermission;
|
||||
}
|
||||
|
||||
checkPermission(node: any, action: ContentActionModel): ContentActionModel {
|
||||
if (action.permission) {
|
||||
if (this.hasPermissions(node)) {
|
||||
@@ -562,4 +543,13 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
||||
this.navigationMode = DocumentListComponent.SINGLE_CLICK_NAVIGATION;
|
||||
}
|
||||
}
|
||||
|
||||
private getDefaultSorting(): DataSorting {
|
||||
let defaultSorting: DataSorting;
|
||||
if (this.sorting) {
|
||||
const [ key, direction ] = this.sorting;
|
||||
defaultSorting = new DataSorting(key, direction);
|
||||
}
|
||||
return defaultSorting;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user