66 lines
1.6 KiB
TypeScript
66 lines
1.6 KiB
TypeScript
import {Component, OnInit} from '@angular/core';
|
|
import {Region} from '../../interfaces/region.interface';
|
|
import {ActivatedRoute, ParamMap} from '@angular/router';
|
|
import {DataService} from '../../services/data.service';
|
|
import {switchMap} from 'rxjs/operators';
|
|
|
|
interface VisualRegionPropDef {
|
|
property: string;
|
|
icon: string;
|
|
unit: string;
|
|
}
|
|
|
|
@Component({
|
|
selector: 'app-region-details',
|
|
templateUrl: './region-details.component.html',
|
|
styleUrls: ['./region-details.component.scss']
|
|
})
|
|
export class RegionDetailsComponent implements OnInit {
|
|
|
|
/** Cut descriptions after x chars */
|
|
readonly DESC_CUT_POINT = 300;
|
|
/** Region property to show in view */
|
|
readonly SHOWN_PROPS: VisualRegionPropDef[] = [
|
|
{
|
|
property: 'average_per_day_costs',
|
|
icon: 'euro',
|
|
unit: '€/day',
|
|
},
|
|
{
|
|
property: 'food_costs',
|
|
icon: 'local_dining',
|
|
unit: '€/day',
|
|
},
|
|
{
|
|
property: 'alcohol_costs',
|
|
icon: 'local_bar',
|
|
unit: '€/day',
|
|
},
|
|
{
|
|
property: 'local_transportation_costs',
|
|
icon: 'commute',
|
|
unit: '€/day',
|
|
},
|
|
{
|
|
property: 'entertainment_costs',
|
|
icon: 'local_activity',
|
|
unit: '€/day',
|
|
}
|
|
];
|
|
|
|
/** Current region */
|
|
region: Region;
|
|
/** Extend the description text */
|
|
isDescExtended = false;
|
|
|
|
constructor(private route: ActivatedRoute, private ds: DataService) {
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.route.paramMap.pipe(
|
|
switchMap((params: ParamMap) => this.ds.getRegion(parseInt(params.get('id'), 10)))
|
|
).subscribe((region: Region) => this.region = region);
|
|
}
|
|
|
|
}
|