diff --git a/src/app/helperFunctions/flattenObject.ts b/src/app/helperFunctions/flattenObject.ts index abb715f..1edae54 100644 --- a/src/app/helperFunctions/flattenObject.ts +++ b/src/app/helperFunctions/flattenObject.ts @@ -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]; } } diff --git a/src/app/pages/tables/bikes/bikes.component.ts b/src/app/pages/tables/bikes/bikes.component.ts index ee1afa4..1e0f4d3 100644 --- a/src/app/pages/tables/bikes/bikes.component.ts +++ b/src/app/pages/tables/bikes/bikes.component.ts @@ -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 ||