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] =
flattenedObject[flattenedProperty];
}
} else if(!prop.includes('_', 0)) {
} else {
newObject[propName] = object[prop];
}
}

@ -69,13 +69,17 @@ export class BikesComponent {
if (this.data[0]) {
this.displayedColumns = [];
this.dataColumns = [];
this.addColumnsFromObject('', this.data[0]);
for (let index in this.data) {
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
this.dataColumns.sort((columnA, columnB) => {
const indexA = this.columnInfo.findIndex((c) => c.name == columnA);
@ -110,17 +114,6 @@ export class BikesComponent {
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) {
return (
this.columnInfo.find((column) => column.name === propertyName)?.header ||

Loading…
Cancel
Save