opt-cc/static/src/app/manage/decorations/decoration-list/decoration-item.component.ts

51 lines
1.2 KiB
TypeScript
Raw Normal View History

2018-03-08 09:44:35 +01:00
import {ChangeDetectionStrategy, Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {Decoration} from '../../../models/model-interfaces';
import {Fraction} from '../../../utils/fraction.enum';
2017-05-10 11:04:06 +02:00
@Component({
2017-11-08 19:23:15 +01:00
selector: 'decoration-item',
2017-05-10 11:04:06 +02:00
templateUrl: './decoration-item.component.html',
styleUrls: ['./decoration-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 DecorationItemComponent implements OnInit {
@Input() selected: boolean;
@Input() decoration: Decoration;
@Output() decorationSelected = new EventEmitter();
@Output() decorationDelete = new EventEmitter();
2017-05-10 11:04:06 +02:00
imageSrc;
2017-05-10 11:04:06 +02:00
2018-03-08 09:44:35 +01:00
imgStyle = {width: '', height: '', marginTop: ''};
2017-05-10 11:04:06 +02:00
2017-11-08 19:23:15 +01:00
readonly fraction = Fraction;
constructor() {
}
2017-05-10 11:04:06 +02:00
ngOnInit() {
this.imageSrc = 'resource/decoration/' + this.decoration._id + '.png?' + Date.now();
if (!this.decoration.isMedal) {
this.imgStyle.width = '62px';
2018-03-07 11:56:50 +01:00
this.imgStyle.marginTop = '17px';
} else {
this.imgStyle.height = '50px';
2018-03-07 11:56:50 +01:00
this.imgStyle.marginTop = '3px';
}
2017-05-10 11:04:06 +02:00
}
select() {
2018-03-07 11:56:50 +01:00
this.decorationSelected.emit(this.decoration._id);
2017-05-10 11:04:06 +02:00
}
delete() {
this.decorationDelete.emit(this.decoration);
}
2017-05-10 11:04:06 +02:00
}