diff --git a/src/app/components/tableComponents/cell/cell.component.ts b/src/app/components/tableComponents/cell/cell.component.ts index 8e30590..18aeffd 100644 --- a/src/app/components/tableComponents/cell/cell.component.ts +++ b/src/app/components/tableComponents/cell/cell.component.ts @@ -23,10 +23,6 @@ export class CellComponent { this.inputType = 'number'; } else if (this.inputType === 'ID' || this.inputType === 'String') { this.inputType = 'text'; - } else if (this.inputType === 'Boolean') { - - } else { - console.log(this.inputType); } } diff --git a/src/app/pages/tables/bikes/bikes.component.ts b/src/app/pages/tables/bikes/bikes.component.ts index aca5cf8..1e26f37 100644 --- a/src/app/pages/tables/bikes/bikes.component.ts +++ b/src/app/pages/tables/bikes/bikes.component.ts @@ -114,10 +114,20 @@ export class BikesComponent { bikesService.bikes.subscribe((newTableDataSource) => { this.reloadingTable = false; - this.data = []; + const tempDataSource = []; for (const row of newTableDataSource) { - this.data.push(flatten(row)); + const oldRow = this.getRowById(row.id); + /** make sure to not overwrite a row that is being edited */ + if (!oldRow) { + tempDataSource.push(flatten(row)); + } + else if (!(oldRow.isLockedByMe && row.isLockedByMe)) { + tempDataSource.push(flatten(row)); + } else if (!!oldRow) { + tempDataSource.push(oldRow); + } } + this.data = tempDataSource; }); bikesService.loadBikes(); } @@ -191,6 +201,10 @@ export class BikesComponent { this.bikesService.unlockBike({ id: row.id }); } + getRowById(id: string) { + return this.data.find(row => row.id === id); + } + drop(event: CdkDragDrop) { moveItemInArray( this.displayedColumns,