Remove addColumnsFromObject function

pull/3/head
Max Ehrlicher-Schmidt 4 years ago
parent 8b6640dfc4
commit bd3a10bad8

@ -8,7 +8,7 @@ export function flatten(object: Object, prefix: string = ''): any {
newObject[flattenedProperty] = newObject[flattenedProperty] =
flattenedObject[flattenedProperty]; flattenedObject[flattenedProperty];
} }
} else if(!prop.includes('_', 0)) { } else {
newObject[propName] = object[prop]; newObject[propName] = object[prop];
} }
} }

@ -70,12 +70,16 @@ export class BikesComponent {
this.displayedColumns = []; this.displayedColumns = [];
this.dataColumns = []; this.dataColumns = [];
this.addColumnsFromObject('', this.data[0]);
for (let index in this.data) { for (let index in this.data) {
this.data[index] = flatten(this.data[index]); this.data[index] = flatten(this.data[index]);
} }
for (const prop in this.data[0]) {
if (!this.blacklistedColumns.includes(prop) && !prop.includes("__")) {
this.dataColumns.push(prop);
}
}
//sort, so the displayedColumns array is in the same order as the columnInfo //sort, so the displayedColumns array is in the same order as the columnInfo
this.dataColumns.sort((columnA, columnB) => { this.dataColumns.sort((columnA, columnB) => {
const indexA = this.columnInfo.findIndex((c) => c.name == columnA); const indexA = this.columnInfo.findIndex((c) => c.name == columnA);
@ -110,17 +114,6 @@ export class BikesComponent {
clearInterval(this.relockingInterval); clearInterval(this.relockingInterval);
} }
addColumnsFromObject(prefix: string, object: Object) {
for (const prop in object) {
let propName = prefix + prop;
if (typeof object[prop] === 'object') {
this.addColumnsFromObject(prefix + prop + '.', object[prop]);
} else if (!this.blacklistedColumns.includes(propName)) {
this.dataColumns.push(propName);
}
}
}
getHeader(propertyName: string) { getHeader(propertyName: string) {
return ( return (
this.columnInfo.find((column) => column.name === propertyName)?.header || this.columnInfo.find((column) => column.name === propertyName)?.header ||

Loading…
Cancel
Save