forked from jsnbuchanan/crowd-funder-for-time-pwa
allow details on a give for a providing project (so we can attach a picture)
This commit is contained in:
@@ -282,6 +282,15 @@
|
||||
>
|
||||
<fa icon="hammer" class="text-blue-500" />
|
||||
</router-link>
|
||||
<router-link
|
||||
v-if="record.providerPlanHandleId"
|
||||
:to="
|
||||
'/project/' +
|
||||
encodeURIComponent(record.providerPlanHandleId)
|
||||
"
|
||||
>
|
||||
<fa icon="hammer" class="text-blue-500" />
|
||||
</router-link>
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="record.image" class="flex justify-center">
|
||||
@@ -359,6 +368,7 @@ interface GiveRecordWithContactInfo extends GiveSummaryRecord {
|
||||
profileImageUrl?: string;
|
||||
};
|
||||
image?: string;
|
||||
providerPlanName?: string;
|
||||
recipientProjectName?: string;
|
||||
receiver: {
|
||||
displayName: string;
|
||||
@@ -554,8 +564,8 @@ export default class HomeView extends Vue {
|
||||
|
||||
// This has indeed proven problematic. See loadMoreGives
|
||||
// We should display it immediately and then get the plan later.
|
||||
const plan = await getPlanFromCache(
|
||||
record.fulfillsPlanHandleId || "",
|
||||
const fulfillsPlan = await getPlanFromCache(
|
||||
record.fulfillsPlanHandleId,
|
||||
this.axios,
|
||||
this.apiServer,
|
||||
this.activeDid,
|
||||
@@ -570,8 +580,13 @@ export default class HomeView extends Vue {
|
||||
if (!anyMatch && this.isFeedFilteredByNearby) {
|
||||
// check if the associated project has a location inside user's search box
|
||||
if (record.fulfillsPlanHandleId) {
|
||||
if (plan?.locLat && plan?.locLon) {
|
||||
if (this.latLongInAnySearchBox(plan.locLat, plan.locLon)) {
|
||||
if (fulfillsPlan?.locLat && fulfillsPlan?.locLon) {
|
||||
if (
|
||||
this.latLongInAnySearchBox(
|
||||
fulfillsPlan.locLat,
|
||||
fulfillsPlan.locLon,
|
||||
)
|
||||
) {
|
||||
anyMatch = true;
|
||||
}
|
||||
}
|
||||
@@ -581,6 +596,17 @@ export default class HomeView extends Vue {
|
||||
continue;
|
||||
}
|
||||
|
||||
// checking for arrays due to legacy data
|
||||
const provider = Array.isArray(claim.provider)
|
||||
? claim.provider[0]
|
||||
: claim.provider;
|
||||
const providedByPlan = await getPlanFromCache(
|
||||
provider?.identifier as string,
|
||||
this.axios,
|
||||
this.apiServer,
|
||||
this.activeDid,
|
||||
);
|
||||
|
||||
const newRecord: GiveRecordWithContactInfo = {
|
||||
...record,
|
||||
giver: didInfoForContact(
|
||||
@@ -590,7 +616,9 @@ export default class HomeView extends Vue {
|
||||
this.allMyDids,
|
||||
),
|
||||
image: claim.image,
|
||||
recipientProjectName: plan?.name as string,
|
||||
providerPlanHandleId: provider?.identifier as string,
|
||||
providerPlanName: providedByPlan?.name as string,
|
||||
recipientProjectName: fulfillsPlan?.name as string,
|
||||
receiver: didInfoForContact(
|
||||
recipientDid,
|
||||
this.activeDid,
|
||||
@@ -684,46 +712,62 @@ export default class HomeView extends Vue {
|
||||
}
|
||||
|
||||
/**
|
||||
* Only show giver and/or receiver info first if they're named.
|
||||
* Only show giver and/or receiver info first if they're named in your contacts.
|
||||
* - If only giver is named, show "... gave"
|
||||
* - If only receiver is named, show "... received"
|
||||
*/
|
||||
|
||||
const giverInfo = giveRecord.giver;
|
||||
const recipientInfo = giveRecord.receiver;
|
||||
|
||||
// any specific names should be shown first
|
||||
if (giverInfo.known && recipientInfo.known) {
|
||||
// both giver and recipient are named
|
||||
return `${giverInfo.displayName} gave to ${recipientInfo.displayName}: ${gaveAmount}`;
|
||||
} else if (giverInfo.known) {
|
||||
// giver is named but recipient is not
|
||||
// giver is known but recipient is not
|
||||
|
||||
// show the project name if to one
|
||||
if (giveRecord.recipientProjectName) {
|
||||
// retrieve the project name
|
||||
return `${giverInfo.displayName} gave: ${gaveAmount} (to the project ${giveRecord.recipientProjectName})`;
|
||||
return `${giverInfo.displayName} gave: ${gaveAmount} (to the project "${giveRecord.recipientProjectName}")`;
|
||||
} else {
|
||||
// it's not to a project
|
||||
return `${giverInfo.displayName} gave: ${gaveAmount} (to ${recipientInfo.displayName})`;
|
||||
}
|
||||
|
||||
// it's not to a project
|
||||
return `${giverInfo.displayName} gave: ${gaveAmount} (to ${recipientInfo.displayName})`;
|
||||
} else if (recipientInfo.known) {
|
||||
// recipient is named but giver is not
|
||||
return `${recipientInfo.displayName} received: ${gaveAmount} (from ${giverInfo.displayName})`;
|
||||
// recipient is known but giver is not
|
||||
|
||||
// show the project name if from one
|
||||
if (giveRecord.providerPlanName) {
|
||||
return `${giverInfo.displayName} received: ${gaveAmount} (from the project "${giveRecord.providerPlanName}")`;
|
||||
} else {
|
||||
// it's not from a project
|
||||
return `${recipientInfo.displayName} received: ${gaveAmount} (from ${giverInfo.displayName})`;
|
||||
}
|
||||
} else {
|
||||
// neither giver nor recipient are named
|
||||
|
||||
// show the project name if to one
|
||||
if (giveRecord.recipientProjectName) {
|
||||
// retrieve the project name
|
||||
return `${gaveAmount} (to the project ${giveRecord.recipientProjectName})`;
|
||||
// create the part in parens
|
||||
let peopleInfo = "";
|
||||
if (giveRecord.providerPlanName || giveRecord.recipientProjectName) {
|
||||
if (giveRecord.providerPlanName) {
|
||||
peopleInfo = `from the project "${giveRecord.providerPlanName}"`;
|
||||
} else {
|
||||
peopleInfo = `from ${giverInfo.displayName}`;
|
||||
}
|
||||
if (giveRecord.recipientProjectName) {
|
||||
peopleInfo += ` to the project "${giveRecord.recipientProjectName}"`;
|
||||
} else {
|
||||
peopleInfo += ` to ${recipientInfo.displayName}`;
|
||||
}
|
||||
} else {
|
||||
if (giverInfo.displayName === recipientInfo.displayName) {
|
||||
peopleInfo = `between two who are ${giverInfo.displayName}`;
|
||||
} else {
|
||||
peopleInfo = `from ${giverInfo.displayName} to ${recipientInfo.displayName}`;
|
||||
}
|
||||
}
|
||||
|
||||
// it's not to a project
|
||||
let peopleInfo;
|
||||
if (giverInfo.displayName === recipientInfo.displayName) {
|
||||
peopleInfo = `between two who are ${giverInfo.displayName}`;
|
||||
} else {
|
||||
peopleInfo = `from ${giverInfo.displayName} to ${recipientInfo.displayName}`;
|
||||
}
|
||||
return gaveAmount + " (" + peopleInfo + ")";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user