opt-cc/static/src/app/ranks/rank-list/rank-item.component.ts

41 lines
902 B
TypeScript
Raw Normal View History

2018-03-07 11:56:50 +01:00
import {ChangeDetectionStrategy, Component, EventEmitter} from '@angular/core';
import {Rank} from '../../models/model-interfaces';
import {Fraction} from '../../utils/fraction.enum';
2017-05-10 11:04:06 +02:00
@Component({
selector: 'pjm-rank-item',
templateUrl: './rank-item.component.html',
styleUrls: ['./rank-item.component.css', '../../style/list-entry.css'],
2017-05-10 11:04:06 +02:00
changeDetection: ChangeDetectionStrategy.OnPush,
inputs: ['rank', 'selected'],
outputs: ['rankSelected', 'rankDelete'],
})
export class RankItemComponent {
selected: boolean;
rank: Rank;
2017-05-15 15:32:36 +02:00
imageSrc;
2017-05-10 11:04:06 +02:00
rankSelected = new EventEmitter();
rankDelete = new EventEmitter();
2017-11-08 19:27:24 +01:00
readonly fraction = Fraction;
2017-05-10 11:04:06 +02:00
2017-11-08 19:27:24 +01:00
constructor() {
2017-05-10 11:04:06 +02:00
}
2017-05-15 15:32:36 +02:00
ngOnInit() {
this.imageSrc = 'resource/rank/' + this.rank._id + '.png?' + Date.now();
}
2017-05-10 11:04:06 +02:00
select() {
2018-03-07 11:56:50 +01:00
this.rankSelected.emit(this.rank._id);
2017-05-10 11:04:06 +02:00
}
delete() {
this.rankDelete.emit(this.rank);
2017-05-10 11:04:06 +02:00
}
}