|
@ -1,21 +1,13 @@ |
|
|
<template> |
|
|
<template> |
|
|
<section id="Content"> |
|
|
<section id="Content"> |
|
|
|
|
|
<div class="flex items-center justify-center h-screen"> |
|
|
<div v-if="claimData"> |
|
|
<div v-if="claimData"> |
|
|
<canvas ref="claimCanvas"></canvas> |
|
|
<canvas class="w-full block mx-auto" ref="claimCanvas"></canvas> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</section> |
|
|
</section> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<style scoped> |
|
|
|
|
|
canvas { |
|
|
|
|
|
position: absolute; |
|
|
|
|
|
top: 0; |
|
|
|
|
|
left: 0; |
|
|
|
|
|
width: 100%; |
|
|
|
|
|
height: 100%; |
|
|
|
|
|
} |
|
|
|
|
|
</style> |
|
|
|
|
|
|
|
|
|
|
|
<script lang="ts"> |
|
|
<script lang="ts"> |
|
|
import { Component, Vue } from "vue-facing-decorator"; |
|
|
import { Component, Vue } from "vue-facing-decorator"; |
|
|
import { nextTick } from "vue"; |
|
|
import { nextTick } from "vue"; |
|
@ -116,7 +108,11 @@ export default class ClaimCertificateView extends Vue { |
|
|
// Draw claim type |
|
|
// Draw claim type |
|
|
ctx.font = "bold 20px Arial"; |
|
|
ctx.font = "bold 20px Arial"; |
|
|
const claimTypeText = |
|
|
const claimTypeText = |
|
|
this.serverUtil.capitalizeAndInsertSpacesBeforeCaps( |
|
|
claimData.claimType === "GiveAction" |
|
|
|
|
|
? "Gift" |
|
|
|
|
|
: claimData.claimType === "PlanAction" |
|
|
|
|
|
? "Project" |
|
|
|
|
|
: this.serverUtil.capitalizeAndInsertSpacesBeforeCaps( |
|
|
claimData.claimType || "", |
|
|
claimData.claimType || "", |
|
|
); |
|
|
); |
|
|
const claimTypeWidth = ctx.measureText(claimTypeText).width; |
|
|
const claimTypeWidth = ctx.measureText(claimTypeText).width; |
|
@ -126,8 +122,8 @@ export default class ClaimCertificateView extends Vue { |
|
|
CANVAS_HEIGHT * 0.33, |
|
|
CANVAS_HEIGHT * 0.33, |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
if (claimData.claim.agent) { |
|
|
if (claimData.claimType === "GiveAction" && claimData.claim.agent) { |
|
|
const presentedText = "Presented to "; |
|
|
const presentedText = "Thanks To "; |
|
|
ctx.font = "14px Arial"; |
|
|
ctx.font = "14px Arial"; |
|
|
const presentedWidth = ctx.measureText(presentedText).width; |
|
|
const presentedWidth = ctx.measureText(presentedText).width; |
|
|
ctx.fillText( |
|
|
ctx.fillText( |
|
@ -146,7 +142,7 @@ export default class ClaimCertificateView extends Vue { |
|
|
ctx.fillText( |
|
|
ctx.fillText( |
|
|
agentText, |
|
|
agentText, |
|
|
(CANVAS_WIDTH - agentWidth) / 2, // Center horizontally |
|
|
(CANVAS_WIDTH - agentWidth) / 2, // Center horizontally |
|
|
CANVAS_HEIGHT * 0.4, |
|
|
CANVAS_HEIGHT * 0.41, |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -162,16 +158,29 @@ export default class ClaimCertificateView extends Vue { |
|
|
ctx.fillText( |
|
|
ctx.fillText( |
|
|
descriptionLine, |
|
|
descriptionLine, |
|
|
(CANVAS_WIDTH - descriptionWidth) / 2, |
|
|
(CANVAS_WIDTH - descriptionWidth) / 2, |
|
|
CANVAS_HEIGHT * 0.45, |
|
|
CANVAS_HEIGHT * 0.495, |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (claimData.claim.object?.amountOfThisGood && claimData.claim.object?.unitCode) { |
|
|
|
|
|
const amount = claimData.claim.object.amountOfThisGood; |
|
|
|
|
|
const unit = claimData.claim.object.unitCode; |
|
|
|
|
|
const amountText = serverUtil.displayAmount(unit, amount); |
|
|
|
|
|
const amountWidth = ctx.measureText(amountText).width; |
|
|
|
|
|
// if there was no description then put this in that spot, otherwise put it below the description |
|
|
|
|
|
const yPos = descriptionText ? CANVAS_HEIGHT * 0.525 : CANVAS_HEIGHT * 0.495; |
|
|
|
|
|
ctx.font = "14px Arial"; |
|
|
|
|
|
ctx.fillText(amountText, (CANVAS_WIDTH - amountWidth) / 2, yPos); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Draw claim issuer & recipient |
|
|
// Draw claim issuer & recipient |
|
|
if (claimData.issuer) { |
|
|
if (claimData.issuer) { |
|
|
ctx.font = "14px Arial"; |
|
|
ctx.font = "14px Arial"; |
|
|
const issuerText = |
|
|
let fullIssuer = serverUtil.didInfoForCertificate(claimData.issuer, allContacts); |
|
|
"Issued by " + |
|
|
if (fullIssuer.length > 15) { |
|
|
serverUtil.didInfoForCertificate(claimData.issuer, allContacts); |
|
|
fullIssuer = fullIssuer.substring(0, 30) + "..."; |
|
|
|
|
|
} |
|
|
|
|
|
const issuerText = "Issued by " + fullIssuer; |
|
|
ctx.fillText(issuerText, CANVAS_WIDTH * 0.3, CANVAS_HEIGHT * 0.6); |
|
|
ctx.fillText(issuerText, CANVAS_WIDTH * 0.3, CANVAS_HEIGHT * 0.6); |
|
|
} |
|
|
} |
|
|
if (confirmerIds.length > 0) { |
|
|
if (confirmerIds.length > 0) { |
|
|