diff --git a/src/app/pages/tables/bikes/bikes.component.html b/src/app/pages/tables/bikes/bikes.component.html index 9271fd9..cdbca50 100644 --- a/src/app/pages/tables/bikes/bikes.component.html +++ b/src/app/pages/tables/bikes/bikes.component.html @@ -15,7 +15,7 @@ + diff --git a/src/app/pages/tables/bikes/bikes.component.ts b/src/app/pages/tables/bikes/bikes.component.ts index 125f257..89454a3 100644 --- a/src/app/pages/tables/bikes/bikes.component.ts +++ b/src/app/pages/tables/bikes/bikes.component.ts @@ -261,11 +261,23 @@ export class BikesComponent { this.bikesService.loadBikes(); } - addEmptyRow() { + addNewObject() { this.paginator.firstPage(); this.resetFilter(); this.resetSorting(); - this.data.data = [{ newObject: true }, ...this.data.data]; + this.data.data = [{ newObject: true, id: this.getNewId() }, ...this.data.data]; + } + + getNewId(): string { + let id = -1; + while(this.getRowById(id.toString())) { + id--; + } + return id.toString(); + } + + deleteNewObject(row: any) { + this.data.data = this.data.data.filter(element => row.id !== element.id); } create(row: any) {