do the same for the recipient: allow editing on the details page

This commit is contained in:
2026-01-18 20:03:54 -07:00
parent b500a1e7c0
commit 1fc7e4726d

View File

@@ -160,57 +160,46 @@
<div <div
class="sm:flex-grow sm:w-1/2 border border-slate-400 p-2 rounded-md overflow-hidden" class="sm:flex-grow sm:w-1/2 border border-slate-400 p-2 rounded-md overflow-hidden"
> >
<div class="flex items-center"> <!-- Recipient Selection Display -->
<input <div
v-if="recipientDid && !givenToProject" v-if="!showRecipientSelection"
v-model="givenToRecipient" class="cursor-pointer"
type="checkbox" @click="openRecipientSelection"
class="flex-shrink-0 h-6 w-6 mr-2" >
/> <div class="flex items-center">
<font-awesome <label class="text-sm flex-1">
v-else {{
icon="square" givenToProjectFunction() && fulfillsProjectName
class="mr-2 bg-white text-white h-5 w-5 px-0.5 py-0.5 rounded-sm" ? "To " + fulfillsProjectName
/> : givenToPersonFunction() && recipientName
<label class="text-sm truncate"> ? "To " + recipientName
{{ : "Unnamed recipient"
recipientDid }}
? "This was given to " + recipientName + "." </label>
: "No named individual benefitted." <span class="text-sm text-blue-500">Change</span>
}} <font-awesome icon="chevron-right" class="text-blue-500 ms-2" />
</label> </div>
<font-awesome
v-if="!recipientDid || givenToProject"
icon="info-circle"
class="text-base cursor-pointer bg-white text-slate-500 ms-1"
@click="notifyUserOfRecipient()"
/>
</div> </div>
<div class="flex items-center"> <!-- Recipient Selection Interface -->
<input <div v-if="showRecipientSelection">
v-if="fulfillsProjectId && !givenToRecipient" <EntitySelectionStep
v-model="givenToProject" step-type="recipient"
type="checkbox" :all-contacts="allContacts"
class="flex-shrink-0 h-6 w-6 mr-2" :active-did="activeDid"
/> :all-my-dids="allMyDids"
<font-awesome :conflict-checker="wouldCreateConflict"
v-else :from-project-id="providerProjectId"
icon="square" :to-project-id="fulfillsProjectId"
class="mr-2 bg-white text-white h-5 w-5 px-0.5 py-0.5 rounded-sm" :giver="currentGiver"
/> :receiver="currentReceiver"
<label class="text-sm truncate"> :description="description"
{{ :amount-input="amountInput"
fulfillsProjectId :unit-code="unitCode"
? "This was given to " + fulfillsProjectName + ". " :offer-id="offerId"
: "No project benefitted." :notify="$notify"
}} @entity-selected="handleRecipientEntitySelected"
</label> @cancel="closeRecipientSelection"
<font-awesome
v-if="!fulfillsProjectId || givenToRecipient"
icon="info-circle"
class="text-base cursor-pointer bg-white text-slate-500 ms-1"
@click="notifyUserFulfillsProject()"
/> />
</div> </div>
</div> </div>
@@ -335,6 +324,7 @@ export default class GiftedDetails extends Vue {
recipientName = ""; recipientName = "";
showGeneralAdvanced = false; showGeneralAdvanced = false;
showGiverSelection = false; showGiverSelection = false;
showRecipientSelection = false;
unitCode = "HUR"; unitCode = "HUR";
libsUtil = libsUtil; libsUtil = libsUtil;
@@ -743,12 +733,12 @@ export default class GiftedDetails extends Vue {
this.axios, this.axios,
this.apiServer, this.apiServer,
this.activeDid, this.activeDid,
giverDid, this.giverDid,
recipientDid, this.recipientDid,
this.description, this.description,
parseFloat(this.amountInput), parseFloat(this.amountInput),
this.unitCode, this.unitCode,
fulfillsProjectId, this.fulfillsProjectId,
this.offerId, this.offerId,
false, false,
this.imageUrl, this.imageUrl,
@@ -887,7 +877,6 @@ export default class GiftedDetails extends Vue {
const contact = entity.data as Contact; const contact = entity.data as Contact;
this.giverDid = contact.did; this.giverDid = contact.did;
this.giverName = contact.name || ""; this.giverName = contact.name || "";
this.providedByGiver = true;
this.providerProjectId = ""; this.providerProjectId = "";
} else if (entity.type === "project") { } else if (entity.type === "project") {
const project = entity.data as PlanData; const project = entity.data as PlanData;
@@ -895,21 +884,65 @@ export default class GiftedDetails extends Vue {
this.providerProjectName = project.name this.providerProjectName = project.name
? `the project "${project.name}"` ? `the project "${project.name}"`
: "a project"; : "a project";
this.providedByGiver = false;
this.giverDid = ""; this.giverDid = "";
} }
this.showGiverSelection = false; this.showGiverSelection = false;
} }
/**
* Open recipient selection interface
*/
openRecipientSelection() {
this.showRecipientSelection = true;
}
/**
* Close recipient selection interface
*/
closeRecipientSelection() {
this.showRecipientSelection = false;
}
/**
* Handle recipient entity selection
*/
handleRecipientEntitySelected(entity: {
type: "person" | "project";
data: Contact | PlanData;
stepType: "giver" | "recipient";
}) {
if (entity.type === "person") {
const contact = entity.data as Contact;
this.recipientDid = contact.did;
this.recipientName = contact.name || "";
this.fulfillsProjectId = "";
} else if (entity.type === "project") {
const project = entity.data as PlanData;
this.fulfillsProjectId = project.handleId || "";
this.fulfillsProjectName = project.name
? `the project "${project.name}"`
: "a project";
this.recipientDid = "";
}
this.showRecipientSelection = false;
}
/** /**
* Check if selecting an entity would create a conflict * Check if selecting an entity would create a conflict
*/ */
wouldCreateConflict(identifier: string): boolean { wouldCreateConflict(identifier: string): boolean {
// Check if it would conflict with recipient // Check if it would conflict with giver
if (this.givenToRecipient && this.recipientDid === identifier) { if (this.giverDid === identifier) {
return true; return true;
} }
if (this.givenToProject && this.fulfillsProjectId === identifier) { if (this.providerProjectId === identifier) {
return true;
}
// Check if it would conflict with recipient
if (this.recipientDid === identifier) {
return true;
}
if (this.fulfillsProjectId === identifier) {
return true; return true;
} }
return false; return false;