From 33cecb042c50b7df7bd0c8c90ffc72d5cc45f403 Mon Sep 17 00:00:00 2001 From: alecmerdler Date: Fri, 21 Apr 2017 13:26:51 -0700 Subject: [PATCH] do not remove properties from item in cor-table-column --- .../ui/cor-table/cor-table.component.ts | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/static/js/directives/ui/cor-table/cor-table.component.ts b/static/js/directives/ui/cor-table/cor-table.component.ts index 60982f6e7..6d7839ae6 100644 --- a/static/js/directives/ui/cor-table/cor-table.component.ts +++ b/static/js/directives/ui/cor-table/cor-table.component.ts @@ -54,8 +54,7 @@ export class CorTableComponent implements OnChanges { } private tablePredicateClass(col: CorTableColumn, options: any) { - return this.TableService.tablePredicateClass(col.datafield, this.options.predicate, - this.options.reverse); + return this.TableService.tablePredicateClass(col.datafield, this.options.predicate, this.options.reverse); } private refreshOrder(): void { @@ -64,28 +63,24 @@ export class CorTableComponent implements OnChanges { columnMap[col.datafield] = col; }); - var filterCols = this.columns.filter(function(col) { - return !!col.sortfield; - }).map((col) => (col.datafield)); + const filterCols = this.columns.filter(col => !!col.sortfield) + .map(col => col.datafield); - var numericCols = this.columns.filter(function(col) { - return col.isNumeric(); - }).map((col) => (col.datafield)); + const numericCols = this.columns.filter(col => col.isNumeric()) + .map(col => col.datafield); - var tableData = this.tableData || []; - var processed = tableData.map((item) => { - var keys = Object.keys(item); - var newObj = {}; - for (var i = 0; i < keys.length; ++i) { - var key = keys[i]; + const tableData = this.tableData || []; + const processed = tableData.map((item) => { + var newObj = Object.assign({}, item); + Object.keys(item).forEach((key) => { if (columnMap[key]) { newObj[key] = columnMap[key].processColumnForOrdered(this.TableService, item[key]); } - } + }); + return newObj; }); - this.orderedData = this.TableService.buildOrderedItems(processed, this.options, - filterCols, numericCols); + this.orderedData = this.TableService.buildOrderedItems(processed, this.options, filterCols, numericCols); } }