opt-cc/static/src/app/request/confirm-award/confirm-award.component.ts

51 lines
1.4 KiB
TypeScript
Raw Normal View History

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',
styleUrls: ['./confirm-award.component.css', '../../style/overview.css'],
2017-06-10 22:07:32 +02:00
})
export class ConfirmAwardComponent {
2017-06-10 22:07:32 +02:00
awards: Award[];
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;
if (awards.length < 1) {
this.awardingService.hasUnprocessedAwards = false;
}
this.showSuccessLabel = true;
setTimeout(() => {
this.showSuccessLabel = false;
}, 2000);
2017-06-10 22:07:32 +02:00
});
});
}
}