Skip to content

Commit

Permalink
#111 task.Duration is trimmed
Browse files Browse the repository at this point in the history
  • Loading branch information
tareq89 committed Aug 7, 2016
1 parent f357d77 commit 323bfc4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/job/job-track/job-track.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h3 class="panel-title col-md-11">
<div class="col-md-12">
<strong>{{ orderStatusHeading }}</strong>
<!--injected html here because I wanted to highlight the email address substring! in the orderInfoDesc-->
<p [innerHtml]="orderInfoDesc"></p>
<p [innerHtml]="orderStatusDesc"></p>
</div>
<div class="row">
<div class="col-md-6">
Expand Down
12 changes: 8 additions & 4 deletions app/job/job-track/job-track.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -91,6 +89,7 @@ export class JobTrackComponent implements OnInit {

})
}
this.fixingServerText(); // this should be called at the end
},
(error) => {
this.status = "FAILED";
Expand All @@ -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)
}

})
}
}
2 changes: 1 addition & 1 deletion app/job/shared/jobtasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class JobTask {
InitiationTime: Date;
ModifiedTime: Date;
CompletionTime: Date;
Duration: any;
Duration: string;
IsReadytoMoveToNextTask: boolean;
IsDependencySatisfied: boolean;
IsStartingTask: boolean;
Expand Down
19 changes: 17 additions & 2 deletions app/job/shared/orderInfo.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -37,7 +45,6 @@ export class OrderInfoService {
}
}

// INFO: This is shamefully ugly
private findOrderStatus(job: Job): number {
let status = 0;
job.Tasks.forEach(task => {
Expand All @@ -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;
}
Expand Down

0 comments on commit 323bfc4

Please sign in to comment.