From 28fb8ff8e35445bf32441f5ba4db34ffe2fa8ce1 Mon Sep 17 00:00:00 2001 From: Max Ehrlicher-Schmidt Date: Tue, 1 Dec 2020 23:21:20 +0100 Subject: [PATCH] Add lendingStation to timeFrame table --- .../time-frames/time-frames.component.ts | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/app/pages/tables/time-frames/time-frames.component.ts b/src/app/pages/tables/time-frames/time-frames.component.ts index a663aea..9dcffdd 100644 --- a/src/app/pages/tables/time-frames/time-frames.component.ts +++ b/src/app/pages/tables/time-frames/time-frames.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { BikesService } from 'src/app/services/bikes.service'; +import { LendingStationsService } from 'src/app/services/lending-stations.service'; import { TimeFrameService } from 'src/app/services/timeFrame.service'; @Component({ selector: 'app-time-frames', @@ -22,10 +23,7 @@ export class TimeFramesComponent implements OnInit { link: (element) => { return '/bike/' + element['cargoBike.id']; }, - possibleObjects: [ - { id: 1, name: 'test' }, - { id: 2, name: 'bike2' }, - ], + possibleObjects: [], nameToShowInSelection: (bike) => bike.name, valueToOverwriteDataPath: (bike) => bike.name, currentlySelectedObjectId: (timeFrame) => { @@ -39,6 +37,13 @@ export class TimeFramesComponent implements OnInit { link: (element) => { return '/lendingStation/' + element['lendingStation.id']; }, + possibleObjects: [], + nameToShowInSelection: (station) => station.name, + valueToOverwriteDataPath: (station) => station.name, + currentlySelectedObjectId: (timeFrame) => { + return timeFrame['lendingStation.id']; + }, + propertyNameOfReferenceId: 'lendingStationId' }, ]; @@ -51,7 +56,8 @@ export class TimeFramesComponent implements OnInit { loadingRowIds: string[] = []; constructor( private service: TimeFrameService, - private bikesService: BikesService + private bikesService: BikesService, + private lendingStationsService: LendingStationsService ) { this.bikesService.loadTableData(); this.bikesService.tableData.subscribe((data) => { @@ -59,7 +65,13 @@ export class TimeFramesComponent implements OnInit { (column) => column.dataPath === 'cargoBike.name' ).possibleObjects = data; }); - // TODO: add LendingStationService + + this.lendingStationsService.loadTableData(); + this.lendingStationsService.tableData.subscribe((data) => { + this.columnInfo.find( + (column) => column.dataPath === 'lendingStation.name' + ).possibleObjects = data; + }); } ngOnInit() {