From 323bfc437e01b553a5fd99c2c769a96cf1a7d763 Mon Sep 17 00:00:00 2001 From: Muhammed Tareq Aziz Date: Sun, 7 Aug 2016 18:51:17 +0600 Subject: [PATCH] #111 task.Duration is trimmed --- app/job/job-track/job-track.component.html | 2 +- app/job/job-track/job-track.component.ts | 12 ++++++++---- app/job/shared/jobtasks.ts | 2 +- app/job/shared/orderInfo.service.ts | 19 +++++++++++++++++-- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/app/job/job-track/job-track.component.html b/app/job/job-track/job-track.component.html index 21b1b55..bb493ef 100644 --- a/app/job/job-track/job-track.component.html +++ b/app/job/job-track/job-track.component.html @@ -66,7 +66,7 @@

{{ orderStatusHeading }} -

+

diff --git a/app/job/job-track/job-track.component.ts b/app/job/job-track/job-track.component.ts index db4143d..d0d7a36 100644 --- a/app/job/job-track/job-track.component.ts +++ b/app/job/job-track/job-track.component.ts @@ -68,11 +68,9 @@ export class JobTrackComponent implements OnInit { .subscribe((job) => { this.status = "SUCCESSFUL"; this.job = job; - this.fixingServerText(this.job); this.orderStatusHeading = this.orderInfoService.orderInfo(job).orderStatusHeading; this.orderStatusDesc = this.orderInfoService.orderInfo(job).orderStatusDesc; this.coordinateInfo = new CoordinateInfo(this.job); - this.job.Tasks.forEach(element => { if(element.Type !== "FetchDeliveryMan"){ this.tasksTiming.push(element); @@ -91,6 +89,7 @@ export class JobTrackComponent implements OnInit { }) } + this.fixingServerText(); // this should be called at the end }, (error) => { this.status = "FAILED"; @@ -108,16 +107,21 @@ export class JobTrackComponent implements OnInit { }); } - fixingServerText(job: Job) { + fixingServerText() { // this weird function is to streamline server responses // like, CashOnDelivery to Cash On Deliver || // IN_PROGRESS to IN PROGRESS // Not sure whether it will stay here finally this.job.Order.PaymentMethod = "Cash On Delivery"; - this.job.Tasks.forEach(task => { + this.tasksTiming.forEach(task => { if(task.Type === "PackagePickUp") task.Type = "Pickup"; if(task.Type === "SecureDelivery") task.Type = "Secured Delivery"; + + if(task.Duration){ + task.Duration = task.Duration.substr(0,8) + } + }) } } \ No newline at end of file diff --git a/app/job/shared/jobtasks.ts b/app/job/shared/jobtasks.ts index ced4566..28df7dd 100644 --- a/app/job/shared/jobtasks.ts +++ b/app/job/shared/jobtasks.ts @@ -11,7 +11,7 @@ export class JobTask { InitiationTime: Date; ModifiedTime: Date; CompletionTime: Date; - Duration: any; + Duration: string; IsReadytoMoveToNextTask: boolean; IsDependencySatisfied: boolean; IsStartingTask: boolean; diff --git a/app/job/shared/orderInfo.service.ts b/app/job/shared/orderInfo.service.ts index baf6b88..eb913e8 100644 --- a/app/job/shared/orderInfo.service.ts +++ b/app/job/shared/orderInfo.service.ts @@ -24,7 +24,15 @@ export class OrderInfoService { _orderStatusDesc = "Your Pickup is completed, Delivery is in progress. Come back to this page for updates on your Order status."; break; case 4: - _orderStatusHeading = "You Delivery has been completed!"; + _orderStatusHeading = "Your Delivery has been completed!"; + _orderStatusDesc = "Thank you for using our service"; + break; + case 5: + _orderStatusHeading = "Your Delivery has been completed, Secured Delivery is in progress!"; + _orderStatusDesc = "Your Delivery is completed, Secured Delivery is in progress. Come back to this page for updates on your Order status."; + break; + case 6: + _orderStatusHeading = "Your Secured Delivery has been completed!"; _orderStatusDesc = "Thank you for using our service"; break; default: @@ -37,7 +45,6 @@ export class OrderInfoService { } } - // INFO: This is shamefully ugly private findOrderStatus(job: Job): number { let status = 0; job.Tasks.forEach(task => { @@ -55,6 +62,14 @@ export class OrderInfoService { status = 4; } } + else if (task.Type === "SecureDelivery"){ + if (task.State === "IN_PROGRESS") { + status = 5; + } + else if (task.State === "COMPLETED") { + status = 6; + } + } }); return status; }