77 lines
2.5 KiB
TypeScript
77 lines
2.5 KiB
TypeScript
|
|
import { Component, OnInit } from '@angular/core';
|
||
|
|
import { environment } from "../../../environments/environment";
|
||
|
|
import { Fault } from "../shared/fault";
|
||
|
|
import { FaultManagerService } from "../fault-manager.service";
|
||
|
|
import { Title } from "@angular/platform-browser";
|
||
|
|
import { ActivatedRoute, Router } from "@angular/router";
|
||
|
|
|
||
|
|
@Component({
|
||
|
|
selector: 'app-repair-complete',
|
||
|
|
templateUrl: './repair-complete.component.html',
|
||
|
|
styleUrls: ['./repair-complete.component.css']
|
||
|
|
})
|
||
|
|
export class RepairCompleteComponent implements OnInit {
|
||
|
|
private attachmentUrl = environment.apiUrl + '/show-attachment';
|
||
|
|
|
||
|
|
public fault: Fault = null;
|
||
|
|
public rejectReason: string = '';
|
||
|
|
public submitInProgress: boolean = false;
|
||
|
|
|
||
|
|
constructor(private faultManager: FaultManagerService,
|
||
|
|
private titleService: Title,
|
||
|
|
private route: ActivatedRoute,
|
||
|
|
private router: Router) {
|
||
|
|
}
|
||
|
|
|
||
|
|
ngOnInit() {
|
||
|
|
this.titleService.setTitle('Webnapló : Javítás visszaigazolása');
|
||
|
|
this.route.data.subscribe((data: { fault: Fault }) => this.fault = data.fault);
|
||
|
|
}
|
||
|
|
|
||
|
|
public confirm() {
|
||
|
|
this.submitInProgress = true;
|
||
|
|
this.faultManager.acknowledgeRepair(this.fault)
|
||
|
|
.finally(() => this.submitInProgress = false)
|
||
|
|
.subscribe(() => this.router.navigate(['/hiba/feladat-lista']));
|
||
|
|
}
|
||
|
|
|
||
|
|
public reject() {
|
||
|
|
this.submitInProgress = true;
|
||
|
|
this.faultManager.reject(this.fault, 'cnf', this.rejectReason)
|
||
|
|
.finally(() => this.submitInProgress = false)
|
||
|
|
.subscribe(() => this.router.navigate(['/hiba/feladat-lista']));
|
||
|
|
}
|
||
|
|
|
||
|
|
get hasDetailedCalculation(): boolean {
|
||
|
|
return this.fault.workCostEstimate > 100000
|
||
|
|
|| this.fault.materialCostEstimate > 200000;
|
||
|
|
}
|
||
|
|
|
||
|
|
get expensePdfDownloadUrl(): string {
|
||
|
|
let expensePdfId = this.fault.attachments.filter(attachment => attachment.type == 'expense');
|
||
|
|
if (expensePdfId.length > 0) {
|
||
|
|
return this.attachmentUrl + '/' + expensePdfId[0].id;
|
||
|
|
}
|
||
|
|
return "";
|
||
|
|
}
|
||
|
|
|
||
|
|
get imageAttachments() {
|
||
|
|
return this.fault.attachments.filter(attachment => attachment.type == 'image');
|
||
|
|
}
|
||
|
|
|
||
|
|
public imageUrl(image: number): string {
|
||
|
|
return this.attachmentUrl + '/' + image;
|
||
|
|
}
|
||
|
|
|
||
|
|
get canReject(): boolean {
|
||
|
|
return this.rejectReason.length > 0
|
||
|
|
&& !this.submitInProgress;
|
||
|
|
}
|
||
|
|
|
||
|
|
get numericMaterialCostEstimate(): number {
|
||
|
|
return this.fault.materialCostEstimate
|
||
|
|
? this.fault.materialCostEstimate
|
||
|
|
: 0;
|
||
|
|
}
|
||
|
|
}
|