forked from trent_larson/crowd-funder-for-time-pwa
fix linting
This commit is contained in:
@@ -341,23 +341,37 @@
|
||||
<div v-else-if="givesTotalsByUnit.length > 0" class="flex-1">
|
||||
<span class="font-semibold mr-2 shrink-0">Totals</span>
|
||||
<span class="whitespace-nowrap overflow-hidden text-ellipsis">
|
||||
<a @click="totalsExpanded = !totalsExpanded" class="cursor-pointer text-blue-500">
|
||||
<a
|
||||
@click="totalsExpanded = !totalsExpanded"
|
||||
class="cursor-pointer text-blue-500"
|
||||
>
|
||||
<!-- just show the hours, or alternatively whatever is first -->
|
||||
<span v-if="givenTotalHours() > 0">
|
||||
{{ givenTotalHours() }} {{ libsUtil.UNIT_SHORT["HUR"] }}
|
||||
</span>
|
||||
<span v-else>
|
||||
{{ givesTotalsByUnit[0].amount }} {{ libsUtil.UNIT_SHORT[givesTotalsByUnit[0].unit] }}
|
||||
{{ givesTotalsByUnit[0].amount }}
|
||||
{{ libsUtil.UNIT_SHORT[givesTotalsByUnit[0].unit] }}
|
||||
</span>
|
||||
<span v-if="givesTotalsByUnit.length > 1">...</span>
|
||||
<span>
|
||||
<fa :icon="totalsExpanded ? 'chevron-up' : 'chevron-right'" class="fa-fw text-xs ml-1" />
|
||||
<fa
|
||||
:icon="totalsExpanded ? 'chevron-up' : 'chevron-right'"
|
||||
class="fa-fw text-xs ml-1"
|
||||
/>
|
||||
</span>
|
||||
</a>
|
||||
<!-- show the full list when expanded -->
|
||||
<div v-if="totalsExpanded">
|
||||
<div v-for="(total, index) in givesTotalsByUnit" :key="total.unit" class="ml-2">
|
||||
<fa :icon="libsUtil.iconForUnitCode(total.unit)" class="fa-fw text-slate-400 mr-1" />
|
||||
<div
|
||||
v-for="(total, index) in givesTotalsByUnit"
|
||||
:key="total.unit"
|
||||
class="ml-2"
|
||||
>
|
||||
<fa
|
||||
:icon="libsUtil.iconForUnitCode(total.unit)"
|
||||
class="fa-fw text-slate-400 mr-1"
|
||||
/>
|
||||
{{ total.amount }} {{ libsUtil.UNIT_LONG[total.unit] }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -365,7 +379,9 @@
|
||||
</div>
|
||||
<div v-else>
|
||||
<span class="font-semibold mr-2 shrink-0">
|
||||
{{ givesToThis.length }}{{ givesHitLimit ? "+" : "" }} record{{ givesToThis.length === 1 ? "" : "s" }}
|
||||
{{ givesToThis.length }}{{ givesHitLimit ? "+" : "" }} record{{
|
||||
givesToThis.length === 1 ? "" : "s"
|
||||
}}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -374,62 +390,71 @@
|
||||
<ul class="mt-2 text-sm border-t border-slate-300">
|
||||
<li
|
||||
v-for="give in givesToThis"
|
||||
:key="give.id"
|
||||
class="py-1.5 border-b border-slate-300"
|
||||
>
|
||||
<div class="flex justify-between gap-4">
|
||||
<span>
|
||||
<fa icon="user" class="fa-fw text-slate-400" />
|
||||
{{
|
||||
serverUtil.didInfo(
|
||||
give.agentDid,
|
||||
activeDid,
|
||||
allMyDids,
|
||||
allContacts,
|
||||
)
|
||||
}}
|
||||
</span>
|
||||
<span v-if="give.amount" class="whitespace-nowrap">
|
||||
<fa
|
||||
:icon="libsUtil.iconForUnitCode(give.unit)"
|
||||
class="fa-fw text-slate-400"
|
||||
/>{{ give.amount }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="text-slate-500">
|
||||
<fa icon="calendar" class="fa-fw text-slate-400" />
|
||||
{{ give.issuedAt?.substring(0, 10) }}
|
||||
</div>
|
||||
<div v-if="give.description" class="text-slate-500">
|
||||
<fa icon="comment" class="fa-fw text-slate-400" />
|
||||
{{ give.description }}
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<a @click="onClickLoadClaim(give.jwtId)">
|
||||
<fa icon="file-lines" class="text-blue-500 cursor-pointer" />
|
||||
</a>
|
||||
:key="give.id"
|
||||
class="py-1.5 border-b border-slate-300"
|
||||
>
|
||||
<div class="flex justify-between gap-4">
|
||||
<span>
|
||||
<fa icon="user" class="fa-fw text-slate-400" />
|
||||
{{
|
||||
serverUtil.didInfo(
|
||||
give.agentDid,
|
||||
activeDid,
|
||||
allMyDids,
|
||||
allContacts,
|
||||
)
|
||||
}}
|
||||
</span>
|
||||
<span v-if="give.amount" class="whitespace-nowrap">
|
||||
<fa
|
||||
:icon="libsUtil.iconForUnitCode(give.unit)"
|
||||
class="fa-fw text-slate-400"
|
||||
/>{{ give.amount }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="text-slate-500">
|
||||
<fa icon="calendar" class="fa-fw text-slate-400" />
|
||||
{{ give.issuedAt?.substring(0, 10) }}
|
||||
</div>
|
||||
<div v-if="give.description" class="text-slate-500">
|
||||
<fa icon="comment" class="fa-fw text-slate-400" />
|
||||
{{ give.description }}
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<a @click="onClickLoadClaim(give.jwtId)">
|
||||
<fa icon="file-lines" class="text-blue-500 cursor-pointer" />
|
||||
</a>
|
||||
|
||||
<a
|
||||
v-if="
|
||||
checkIsConfirmable(give) &&
|
||||
!recentlyCheckedAndUnconfirmableJwts.includes(give.jwtId)
|
||||
"
|
||||
@click="deepCheckConfirmable(give)"
|
||||
>
|
||||
<fa icon="circle-check" class="text-blue-500 cursor-pointer" />
|
||||
</a>
|
||||
<a v-else-if="checkingConfirmationForJwtId === give.jwtId">
|
||||
<fa icon="spinner" class="fa-spin-pulse" />
|
||||
</a>
|
||||
<a v-else @click="shallowNotifyWhyCannotConfirm(give)">
|
||||
<fa icon="circle-check" class="text-slate-500 cursor-pointer" />
|
||||
</a>
|
||||
</div>
|
||||
<div v-if="give.fullClaim.image" class="flex justify-center">
|
||||
<a :href="give.fullClaim.image" target="_blank">
|
||||
<img :src="give.fullClaim.image" class="h-24 mt-2 rounded-xl" />
|
||||
</a>
|
||||
</div>
|
||||
<a
|
||||
v-if="
|
||||
checkIsConfirmable(give) &&
|
||||
!recentlyCheckedAndUnconfirmableJwts.includes(give.jwtId)
|
||||
"
|
||||
@click="deepCheckConfirmable(give)"
|
||||
>
|
||||
<fa
|
||||
icon="circle-check"
|
||||
class="text-blue-500 cursor-pointer"
|
||||
/>
|
||||
</a>
|
||||
<a v-else-if="checkingConfirmationForJwtId === give.jwtId">
|
||||
<fa icon="spinner" class="fa-spin-pulse" />
|
||||
</a>
|
||||
<a v-else @click="shallowNotifyWhyCannotConfirm(give)">
|
||||
<fa
|
||||
icon="circle-check"
|
||||
class="text-slate-500 cursor-pointer"
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
<div v-if="give.fullClaim.image" class="flex justify-center">
|
||||
<a :href="give.fullClaim.image" target="_blank">
|
||||
<img
|
||||
:src="give.fullClaim.image"
|
||||
class="h-24 mt-2 rounded-xl"
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -594,7 +619,7 @@ export default class ProjectViewView extends Vue {
|
||||
givesHitLimit = false;
|
||||
givesProvidedByThis: Array<GiveSummaryRecord> = [];
|
||||
givesProvidedByHitLimit = false;
|
||||
givesTotalsByUnit: Array<{unit: string, amount: number}> = [];
|
||||
givesTotalsByUnit: Array<{ unit: string; amount: number }> = [];
|
||||
imageUrl = "";
|
||||
isRegistered = false;
|
||||
issuer = "";
|
||||
@@ -1254,14 +1279,17 @@ export default class ProjectViewView extends Vue {
|
||||
|
||||
async loadTotals() {
|
||||
this.loadingTotals = true;
|
||||
const url = this.apiServer + "/api/v2/report/givesToPlans?planIds=" + encodeURIComponent(JSON.stringify([this.projectId]));
|
||||
const url =
|
||||
this.apiServer +
|
||||
"/api/v2/report/givesToPlans?planIds=" +
|
||||
encodeURIComponent(JSON.stringify([this.projectId]));
|
||||
const headers = await serverUtil.getHeaders(this.activeDid);
|
||||
|
||||
try {
|
||||
const resp = await this.axios.get(url, { headers });
|
||||
if (resp.status === 200 && resp.data.data) {
|
||||
// Calculate totals by unit
|
||||
const totals: {[key: string]: number} = {};
|
||||
const totals: { [key: string]: number } = {};
|
||||
resp.data.data.forEach((give: GiveSummaryRecord) => {
|
||||
const amount = give.fullClaim.object?.amountOfThisGood;
|
||||
const unit = give.fullClaim.object?.unitCode;
|
||||
@@ -1269,12 +1297,14 @@ export default class ProjectViewView extends Vue {
|
||||
totals[unit] = (totals[unit] || 0) + amount;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Convert totals object to array format
|
||||
this.givesTotalsByUnit = Object.entries(totals).map(([unit, amount]) => ({
|
||||
unit,
|
||||
amount
|
||||
}));
|
||||
this.givesTotalsByUnit = Object.entries(totals).map(
|
||||
([unit, amount]) => ({
|
||||
unit,
|
||||
amount,
|
||||
}),
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error loading totals:", error);
|
||||
@@ -1293,7 +1323,9 @@ export default class ProjectViewView extends Vue {
|
||||
}
|
||||
|
||||
givenTotalHours(): number {
|
||||
return this.givesTotalsByUnit.find(total => total.unit === "HUR")?.amount || 0;
|
||||
return (
|
||||
this.givesTotalsByUnit.find((total) => total.unit === "HUR")?.amount || 0
|
||||
);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user