mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-22 17:42:57 +00:00
@@ -15,10 +15,13 @@
|
|||||||
|
|
||||||
import moment, {Moment} from 'moment';
|
import moment, {Moment} from 'moment';
|
||||||
|
|
||||||
import {AfterViewInit, Component, Input} from '@angular/core';
|
import {AfterViewInit, Component, Input, OnDestroy} from '@angular/core';
|
||||||
import {SCDish, SCISO8601Date, SCPlace} from '@openstapps/core';
|
import {SCDish, SCISO8601Date, SCPlace} from '@openstapps/core';
|
||||||
import {keys} from 'lodash-es';
|
import {keys} from 'lodash-es';
|
||||||
import {PlaceMensaService} from './place-mensa-service';
|
import {PlaceMensaService} from './place-mensa-service';
|
||||||
|
import {DataRoutingService} from '../../../../data-routing.service';
|
||||||
|
import {Router} from '@angular/router';
|
||||||
|
import {Subscription} from 'rxjs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
@@ -29,7 +32,7 @@ import {PlaceMensaService} from './place-mensa-service';
|
|||||||
templateUrl: 'place-mensa.html',
|
templateUrl: 'place-mensa.html',
|
||||||
styleUrls: ['place-mensa.scss'],
|
styleUrls: ['place-mensa.scss'],
|
||||||
})
|
})
|
||||||
export class PlaceMensaDetailComponent implements AfterViewInit {
|
export class PlaceMensaDetailComponent implements AfterViewInit, OnDestroy {
|
||||||
/**
|
/**
|
||||||
* Map of dishes for each day
|
* Map of dishes for each day
|
||||||
*/
|
*/
|
||||||
@@ -56,7 +59,16 @@ export class PlaceMensaDetailComponent implements AfterViewInit {
|
|||||||
*/
|
*/
|
||||||
startingDay: Moment;
|
startingDay: Moment;
|
||||||
|
|
||||||
constructor(private readonly mensaService: PlaceMensaService) {
|
/**
|
||||||
|
* Array of all subscriptions to Observables
|
||||||
|
*/
|
||||||
|
subscriptions: Subscription[] = [];
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private readonly mensaService: PlaceMensaService,
|
||||||
|
protected router: Router,
|
||||||
|
private readonly dataRoutingService: DataRoutingService,
|
||||||
|
) {
|
||||||
this.startingDay = moment().startOf('day');
|
this.startingDay = moment().startOf('day');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,5 +85,19 @@ export class PlaceMensaDetailComponent implements AfterViewInit {
|
|||||||
}
|
}
|
||||||
this.selectedDay = keys(result)[0];
|
this.selectedDay = keys(result)[0];
|
||||||
});
|
});
|
||||||
|
this.subscriptions.push(
|
||||||
|
this.dataRoutingService.itemSelectListener().subscribe(item => {
|
||||||
|
void this.router.navigate(['data-detail', item.uid]);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove subscriptions when the component is removed
|
||||||
|
*/
|
||||||
|
ngOnDestroy() {
|
||||||
|
for (const sub of this.subscriptions) {
|
||||||
|
sub.unsubscribe();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user