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

42 lines
884 B
TypeScript
Raw Normal View History

2018-03-08 09:44:35 +01:00
import {ChangeDetectionStrategy, Component, EventEmitter, Input, OnInit, Output} 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: 'cc-rank-item',
2017-05-10 11:04:06 +02:00
templateUrl: './rank-item.component.html',
styleUrls: ['./rank-item.component.scss'],
2018-03-08 09:44:35 +01:00
changeDetection: ChangeDetectionStrategy.OnPush
2017-05-10 11:04:06 +02:00
})
2018-03-08 09:44:35 +01:00
export class RankItemComponent implements OnInit {
2017-05-10 11:04:06 +02:00
2018-03-08 09:44:35 +01:00
@Input() selected: boolean;
@Input() rank: Rank;
@Output() rankSelected = new EventEmitter();
2017-05-10 11:04:06 +02:00
2018-03-08 09:44:35 +01:00
@Output() rankDelete = new EventEmitter();
imageSrc;
2017-05-10 11:04:06 +02:00
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
}
}