Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

download proof of delivery #113

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
20 changes: 20 additions & 0 deletions addon/controllers/operations/orders/index/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export default class OperationsOrdersIndexViewController extends BaseController
@tracked commentInput = '';
@tracked customFieldGroups = [];
@tracked customFields = [];
@tracked proofs;
@tracked uploadQueue = [];
acceptedFileTypes = [
'application/vnd.ms-excel',
Expand Down Expand Up @@ -245,6 +246,7 @@ export default class OperationsOrdersIndexViewController extends BaseController
yield order.loadPurchaseRate();
yield order.loadFiles();
this.loadCustomFields.perform(order);
this.viewProofLabel.perform(order.id);
}

/**
Expand Down Expand Up @@ -842,6 +844,24 @@ export default class OperationsOrdersIndexViewController extends BaseController
fileReader.readAsDataURL(blob);
}

/**
* View proof label
*/
@task *viewProofLabel(orderId) {
const response = yield this.fetch.get('proofs', { subject_uuid: orderId });
this.proofs = response.proofs;
}

@action downloadImage(proof) {
const base64Data = proof.raw;
const link = document.createElement('a');
link.href = base64Data;
link.download = 'downloaded_image.png';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}

/**
* Reloads tracking activity for this order.
*
Expand Down
12 changes: 12 additions & 0 deletions addon/templates/operations/orders/index/view.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,18 @@
<div class="field-info-container space-y-2">
<div class="field-name">{{t "fleet-ops.operations.orders.index.view.proof-of-delivery"}}</div>
<div class="field-value">{{n-a (smart-humanize @model.pod_method)}}</div>
{{#if this.proofs}}
{{#each this.proofs as |proof|}}
{{#if proof.raw}}
<Button @size="xs" @type="default" {{on "click" (fn this.downloadImage proof)}} title="{{t 'fleet-ops.operations.orders.index.view.download'}}">
{{t "fleet-ops.operations.orders.index.view.download"}}
</Button>
{{else}}
<div class="text-sm">{{format-date proof.created_at "d MMM yyyy"}}</div>

{{/if}}
{{/each}}
{{/if}}
</div>
{{/if}}
</div>
Expand Down
1 change: 1 addition & 0 deletions translations/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,7 @@ fleet-ops:
order-title: Order Label
waypoint-title: Waypoint Label
proof-of-delivery: Proof of Delivery
download: Download Image
notes-placeholder: Enter order notes here....
save-order-note: Save Order Note
order-notes-updated: Order notes updated.
Expand Down
Loading