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

49 lines
1.2 KiB
TypeScript

import {ChangeDetectionStrategy, Component, EventEmitter} from '@angular/core';
import {Decoration} from '../../models/model-interfaces';
import {Fraction} from '../../utils/fraction.enum';
@Component({
selector: 'decoration-item',
templateUrl: './decoration-item.component.html',
styleUrls: ['./decoration-item.component.css', '../../style/list-entry.css'],
changeDetection: ChangeDetectionStrategy.OnPush,
inputs: ['decoration', 'selected'],
outputs: ['decorationDelete', 'decorationSelected'],
})
export class DecorationItemComponent {
selected: boolean;
decoration: Decoration;
imageSrc;
imgStyle = {width: '', height: '', marginTop: ''};
decorationSelected = new EventEmitter();
decorationDelete = new EventEmitter();
readonly fraction = Fraction;
constructor() {
}
ngOnInit() {
this.imageSrc = 'resource/decoration/' + this.decoration._id + '.png?' + Date.now();
if (!this.decoration.isMedal) {
this.imgStyle.width = '62px';
this.imgStyle.marginTop = '17px';
} else {
this.imgStyle.height = '50px';
this.imgStyle.marginTop = '3px';
}
}
select() {
this.decorationSelected.emit(this.decoration._id);
}
delete() {
this.decorationDelete.emit(this.decoration);
}
}