[ADF-491] Task Attachment List Component (#1877)

* Create a new component Task Attachment List
Improve the datatable to get the rows to show

* The component name should follow the guide style
Move the Content calls in a different service file
Show the attach file inside the viewer

* Change method name

* Datatable should get the path and show the icon

* Improve attachment component

* Improve datatable documentation

* Remove console.log
This commit is contained in:
Maurizio Vitale
2017-05-18 16:52:39 +02:00
committed by Eugenio Romano
parent 608b3639ea
commit a90423aa21
39 changed files with 4252 additions and 5 deletions

View File

@@ -18,6 +18,7 @@
import {
Component,
OnChanges,
SimpleChange,
SimpleChanges,
Input,
Output,
@@ -28,7 +29,7 @@ import {
ContentChild,
Optional
} from '@angular/core';
import { DataTableAdapter, DataRow, DataColumn, DataSorting, DataRowEvent, ObjectDataTableAdapter } from '../../data/index';
import { DataTableAdapter, DataRow, DataColumn, DataSorting, DataRowEvent, ObjectDataTableAdapter, ObjectDataRow } from '../../data/index';
import { DataCellEvent } from './data-cell.event';
import { DataRowActionEvent } from './data-row-action.event';
import { DataColumnListComponent } from 'ng2-alfresco-core';
@@ -48,6 +49,9 @@ export class DataTableComponent implements AfterContentInit, OnChanges {
@Input()
data: DataTableAdapter;
@Input()
rows: any[] = [];
@Input()
multiselect: boolean = false;
@@ -96,10 +100,25 @@ export class DataTableComponent implements AfterContentInit, OnChanges {
}
ngOnChanges(changes: SimpleChanges) {
if (changes['data'] && changes['data'].currentValue) {
if (this.isPropertyChanged(changes['data'])) {
this.loadTable();
return;
}
if (this.isPropertyChanged(changes['rows'])) {
if (this.data) {
this.data.setRows(this.convertToRowsData(changes['rows'].currentValue));
}
return;
}
}
isPropertyChanged(property: SimpleChange): boolean {
return property && property.currentValue ? true : false;
}
convertToRowsData(rows: any []): ObjectDataRow[] {
return rows.map(row => new ObjectDataRow(row));
}
loadTable() {
@@ -110,7 +129,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges {
}
if (!this.data) {
this.data = new ObjectDataTableAdapter([], schema);
this.data = new ObjectDataTableAdapter(this.rows, schema);
} else {
this.setHtmlColumnConfigurationOnObjectAdapter(schema);
}