opt-cc/static/src/app/pub/decoration-overview/decoration-overview.compone...

53 lines
1.5 KiB
TypeScript
Raw Normal View History

2018-07-28 19:13:30 +02:00
import {Component, OnInit} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Fraction} from '../../utils/fraction.enum';
import {Decoration} from '../../models/model-interfaces';
import {DecorationService} from '../../services/army-management/decoration.service';
import {MatBottomSheet} from '@angular/material';
import {UserListSheetComponent} from '../user-list-sheet/user-list-sheet.component';
@Component({
selector: 'cc-decoration-overview',
templateUrl: './decoration-overview.component.html',
styleUrls: ['./decoration-overview.component.css']
})
2018-07-28 19:13:30 +02:00
export class DecorationOverviewComponent implements OnInit {
2018-08-09 22:07:47 +02:00
decorations: Decoration[];
2018-07-18 21:15:42 +02:00
2018-08-09 22:07:47 +02:00
medals: Decoration[];
2018-07-18 21:15:42 +02:00
2018-08-09 22:07:47 +02:00
ribbons: Decoration[];
2018-07-18 21:15:42 +02:00
2018-08-09 22:07:47 +02:00
active: string;
readonly fraction = Fraction;
constructor(private router: Router,
private route: ActivatedRoute,
private decorationService: DecorationService,
2018-07-28 19:13:30 +02:00
private bottomSheet: MatBottomSheet) {
}
ngOnInit() {
2018-07-18 21:15:42 +02:00
// init decoration data
this.decorationService.findDecorations()
.subscribe(decorations => {
2018-08-09 22:07:47 +02:00
this.decorations = decorations;
this.switchFraction('BLUFOR');
});
};
2018-08-09 22:07:47 +02:00
switchFraction(value: string) {
this.medals = this.decorations.filter(d => d.fraction === value && d.isMedal);
this.ribbons = this.decorations.filter(d => d.fraction === value && !d.isMedal);
this.active = value;
}
select(decoration: Decoration) {
2018-07-28 19:13:30 +02:00
this.bottomSheet.open(UserListSheetComponent, {data: {decoration: decoration}});
}
}