2017-05-10 11:04:06 +02:00
|
|
|
import {ChangeDetectionStrategy, Component, EventEmitter} from "@angular/core";
|
|
|
|
import {Router} from "@angular/router";
|
|
|
|
import {Decoration} from "../../models/model-interfaces";
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'pjm-decoration-item',
|
|
|
|
templateUrl: './decoration-item.component.html',
|
|
|
|
styleUrls: ['./decoration-item.component.css'],
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
|
|
inputs: ['decoration', 'selected'],
|
2017-05-16 20:06:00 +02:00
|
|
|
outputs: ['decorationDelete','decorationSelected'],
|
2017-05-10 11:04:06 +02:00
|
|
|
})
|
|
|
|
export class DecorationItemComponent {
|
|
|
|
|
|
|
|
selected: boolean;
|
|
|
|
decoration: Decoration;
|
2017-05-16 20:06:00 +02:00
|
|
|
imageSrc;
|
2017-05-16 23:51:03 +02:00
|
|
|
imgStyle = {width: '', height: '', marginTop: ''};
|
2017-05-10 11:04:06 +02:00
|
|
|
|
|
|
|
decorationSelected = new EventEmitter();
|
2017-05-16 20:06:00 +02:00
|
|
|
decorationDelete = new EventEmitter();
|
2017-05-10 11:04:06 +02:00
|
|
|
|
|
|
|
constructor(private router: Router) {
|
2017-05-16 20:06:00 +02:00
|
|
|
}
|
2017-05-10 11:04:06 +02:00
|
|
|
|
2017-05-16 20:06:00 +02:00
|
|
|
ngOnInit() {
|
|
|
|
this.imageSrc = 'resource/decoration/' + this.decoration._id + '.png?' + Date.now();
|
|
|
|
if (!this.decoration.isMedal) {
|
2017-05-16 23:51:03 +02:00
|
|
|
this.imgStyle.width = '62px';
|
|
|
|
this.imgStyle.marginTop = '17px'
|
|
|
|
} else {
|
|
|
|
this.imgStyle.height = '50px';
|
|
|
|
this.imgStyle.marginTop = '3px'
|
2017-05-16 20:06:00 +02:00
|
|
|
}
|
2017-05-10 11:04:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
select() {
|
|
|
|
this.decorationSelected.emit(this.decoration._id)
|
|
|
|
}
|
|
|
|
|
2017-05-16 20:06:00 +02:00
|
|
|
delete() {
|
|
|
|
this.decorationDelete.emit(this.decoration);
|
|
|
|
}
|
|
|
|
|
2017-05-10 11:04:06 +02:00
|
|
|
ngAfterViewChecked() {
|
|
|
|
//var taskId = (this.task ? this.task.id : '');
|
|
|
|
// console.log(`Task ${taskId} checked ${++this.checkCounter} times`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|