[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:
Denys Vuika
2017-05-22 15:46:54 +01:00
committed by Eugenio Romano
parent ef5bb6333c
commit da18a21e7c
32 changed files with 112 additions and 92 deletions

View File

@@ -27,9 +27,11 @@ export * from './src/components/datatable/data-row-action.event';
import { DataTableComponent } from './src/components/datatable/datatable.component';
import { NoContentTemplateComponent } from './src/components/datatable/no-content-template.component';
import { PaginationComponent } from './src/components/pagination/pagination.component';
import { DataTableCellComponent } from './src/components/datatable/datatable-cell.component';
export const ALFRESCO_DATATABLE_DIRECTIVES: [any] = [
DataTableComponent,
DataTableCellComponent,
NoContentTemplateComponent,
PaginationComponent
];

View File

@@ -0,0 +1,48 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Component, Input, ChangeDetectionStrategy } from '@angular/core';
import { DataTableAdapter, DataColumn, DataRow } from '../../data/index';
@Component({
selector: 'alfresco-datatable-cell',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-container>{{value}}</ng-container>'
})
export class DataTableCellComponent {
@Input()
data: DataTableAdapter;
@Input()
column: DataColumn;
@Input()
row: DataRow;
@Input()
value: any;
constructor() { }
ngOnInit() {
if (this.column && this.column.key && this.row && this.data) {
this.value = this.data.getValue(this.row, this.column);
}
}
}

View File

@@ -70,10 +70,10 @@
(error)="onImageLoadingError($event)">
</div>
<div *ngSwitchCase="'date'" class="cell-value" [attr.data-automation-id]="'date_' + data.getValue(row, col)">
{{data.getValue(row, col)}}
<alfresco-datatable-cell [data]="data" [column]="col" [row]="row"></alfresco-datatable-cell>
</div>
<div *ngSwitchCase="'text'" class="cell-value" [attr.data-automation-id]="'text_' + data.getValue(row, col)">
{{data.getValue(row, col)}}
<alfresco-datatable-cell [data]="data" [column]="col" [row]="row"></alfresco-datatable-cell>
</div>
<span *ngSwitchDefault class="cell-value">
<!-- empty cell for unknown column type -->
@@ -95,7 +95,7 @@
</button>
<ul alfresco-mdl-menu class="mdl-menu--bottom-right"
[attr.for]="'action_menu_' + idx">
<li class="mdl-menu__item" [attr.disabled]="action.disabled"
<li class="mdl-menu__item" [attr.disabled]="action.disabled || undefined"
[attr.data-automation-id]="action.title"
*ngFor="let action of getRowActions(row)"
(click)="onExecuteRowAction(row, action)">

View File

@@ -20,6 +20,7 @@ import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { CoreModule } from 'ng2-alfresco-core';
import { MdCheckboxChange } from '@angular/material';
import { DataTableComponent } from './datatable.component';
import { DataTableCellComponent } from './datatable-cell.component';
import {
DataRow,
DataColumn,
@@ -40,7 +41,10 @@ describe('DataTable', () => {
imports: [
CoreModule.forRoot()
],
declarations: [DataTableComponent]
declarations: [
DataTableCellComponent,
DataTableComponent
]
}).compileComponents();
}));

View File

@@ -258,7 +258,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges {
}
onExecuteRowAction(row: DataRow, action: any) {
if (action.disabled) {
if (action.disabled || action.disabled) {
event.stopPropagation();
} else {
this.executeRowAction.emit(new DataRowActionEvent(row, action));

View File

@@ -17,3 +17,4 @@
export * from './datatable.component';
export * from './no-content-template.component';
export * from './datatable-cell.component';

View File

@@ -41,9 +41,6 @@
"es2015",
"dom"
],
"typeRoots": [
"./node_modules/@types"
],
"suppressImplicitAnyIndexErrors": true
},
"exclude": [