fixed some issues in table component and added tests (#1873)

* fixed some issues in table component  and added tests

* fixed the enter key handling in text area component
This commit is contained in:
Leila Lali
2018-07-09 14:40:21 -07:00
committed by GitHub
parent 53953f5cda
commit b2ceb09e4d
6 changed files with 168 additions and 13 deletions

View File

@@ -74,15 +74,21 @@ export default class TableComponent extends ComponentBase implements IComponent,
}
}
transformData(rows: string[][], columns: any[]): { [key: string]: string }[] {
return rows.map(row => {
let object: { [key: string]: string } = {};
row.forEach((val, index) => {
let columnName: string = (columns[index].value) ? columns[index].value : <string>columns[index];
object[columnName] = val;
public static transformData(rows: string[][], columns: any[]): { [key: string]: string }[] {
if (rows && columns) {
return rows.map(row => {
let object: { [key: string]: string } = {};
if (row.forEach) {
row.forEach((val, index) => {
let columnName: string = (columns[index].value) ? columns[index].value : <string>columns[index];
object[columnName] = val;
});
}
return object;
});
return object;
});
} else {
return [];
}
}
ngAfterViewInit(): void {
@@ -147,7 +153,7 @@ export default class TableComponent extends ComponentBase implements IComponent,
public setProperties(properties: { [key: string]: any; }): void {
super.setProperties(properties);
this._tableData.clear();
this._tableData.push(this.transformData(this.data, this.columns));
this._tableData.push(TableComponent.transformData(this.data, this.columns));
this._tableColumns = this.transformColumns(this.columns);
this._table.columns = this._tableColumns;
this._table.setData(this._tableData);