2017-06-10 22:07:32 +02:00
|
|
|
import {Component} from "@angular/core";
|
|
|
|
import {Award} from "../../models/model-interfaces";
|
2017-10-22 18:06:37 +02:00
|
|
|
import {AwardingService} from "../../services/army-management/awarding.service";
|
|
|
|
import {LoginService} from "../../services/app-user-service/login-service";
|
2017-06-10 22:07:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
templateUrl: './confirm-award.component.html',
|
2017-10-07 19:32:16 +02:00
|
|
|
styleUrls: ['./confirm-award.component.css', '../../style/overview.css'],
|
2017-06-10 22:07:32 +02:00
|
|
|
})
|
|
|
|
export class ConfirmAwardComponent {
|
2017-06-11 13:18:03 +02:00
|
|
|
|
2017-06-10 22:07:32 +02:00
|
|
|
awards: Award[];
|
|
|
|
|
2017-06-11 13:18:03 +02:00
|
|
|
showSuccessLabel = false;
|
|
|
|
|
2017-09-23 11:53:10 +02:00
|
|
|
constructor(private awardingService: AwardingService,
|
|
|
|
private loginService: LoginService) {
|
2017-06-10 22:07:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2017-09-23 11:53:10 +02:00
|
|
|
let currentUser = this.loginService.getCurrentUser();
|
2017-06-10 22:07:32 +02:00
|
|
|
this.awardingService.getUnconfirmedAwards(currentUser.squad.fraction).subscribe(awards => {
|
|
|
|
this.awards = awards;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
confirm(award: Award, decision: boolean) {
|
|
|
|
const updateObject = {
|
|
|
|
_id: award._id,
|
|
|
|
confirmed: decision ? 1 : 2
|
|
|
|
};
|
|
|
|
|
|
|
|
this.awardingService.updateAward(updateObject).subscribe(res => {
|
2017-09-23 11:53:10 +02:00
|
|
|
let currentUser = this.loginService.getCurrentUser();
|
2017-06-10 22:07:32 +02:00
|
|
|
this.awardingService.getUnconfirmedAwards(currentUser.squad.fraction).subscribe(awards => {
|
|
|
|
this.awards = awards;
|
2017-07-23 10:57:46 +02:00
|
|
|
if (awards.length < 1) {
|
|
|
|
this.awardingService.hasUnprocessedAwards = false;
|
|
|
|
}
|
2017-06-11 13:18:03 +02:00
|
|
|
this.showSuccessLabel = true;
|
|
|
|
setTimeout(() => {
|
|
|
|
this.showSuccessLabel = false;
|
|
|
|
}, 2000);
|
2017-06-10 22:07:32 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|