Show current user in ContactGiftingView #155

Open
jose wants to merge 8 commits from contact-gifting-current-user into master
  1. 31
      src/components/EntityGrid.vue
  2. 10
      src/components/EntitySelectionStep.vue
  3. 36
      src/components/EntitySummaryButton.vue
  4. 71
      src/components/GiftedDialog.vue
  5. 22
      src/components/PersonCard.vue
  6. 10
      src/components/SpecialEntityCard.vue
  7. 289
      src/views/ContactGiftingView.vue
  8. 62
      src/views/HomeView.vue

31
src/components/EntityGrid.vue

@ -159,6 +159,10 @@ export default class EntityGrid extends Vue {
@Prop({ default: "other party" }) @Prop({ default: "other party" })
conflictContext!: string; conflictContext!: string;
/** Whether to hide the "Show All" navigation */
@Prop({ default: false })
hideShowAll!: boolean;
Review

I see this is only ever set as false. If there are not any cases where it should be true then we can remove this and just set it to the 'false' behavior.

I see this is only ever set as false. If there are not any cases where it should be true then we can remove this and just set it to the 'false' behavior.
/** /**
* Function to determine which entities to display (allows parent control) * Function to determine which entities to display (allows parent control)
* *
@ -245,7 +249,9 @@ export default class EntityGrid extends Vue {
* Whether to show the "Show All" navigation * Whether to show the "Show All" navigation
*/ */
get shouldShowAll(): boolean { get shouldShowAll(): boolean {
return this.entities.length > 0 && this.showAllRoute !== ""; return (
!this.hideShowAll && this.entities.length > 0 && this.showAllRoute !== ""
);
} }
/** /**
@ -304,16 +310,13 @@ export default class EntityGrid extends Vue {
/** /**
* Handle special entity selection from SpecialEntityCard * Handle special entity selection from SpecialEntityCard
* Treat "You" and "Unnamed" as person entities
*/ */
handleEntitySelected(event: { handleEntitySelected(event: { data: { did?: string; name: string } }): void {
type: string; // Convert special entities to person entities since they represent people
entityType: string;
data: { did?: string; name: string };
}): void {
this.emitEntitySelected({ this.emitEntitySelected({
type: "special", type: "person",
entityType: event.entityType, data: event.data as Contact,
data: event.data,
}); });
} }
@ -321,13 +324,11 @@ export default class EntityGrid extends Vue {
@Emit("entity-selected") @Emit("entity-selected")
emitEntitySelected(data: { emitEntitySelected(data: {
type: "person" | "project" | "special"; type: "person" | "project";
entityType?: string; data: Contact | PlanData;
data: Contact | PlanData | { did?: string; name: string };
}): { }): {
type: "person" | "project" | "special"; type: "person" | "project";
entityType?: string; data: Contact | PlanData;
data: Contact | PlanData | { did?: string; name: string };
} { } {
return data; return data;
} }

10
src/components/EntitySelectionStep.vue

@ -27,6 +27,7 @@ Matthew Raymer */
:show-all-query-params="showAllQueryParams" :show-all-query-params="showAllQueryParams"
:notify="notify" :notify="notify"
:conflict-context="conflictContext" :conflict-context="conflictContext"
:hide-show-all="hideShowAll"
@entity-selected="handleEntitySelected" @entity-selected="handleEntitySelected"
/> />
@ -55,9 +56,8 @@ interface EntityData {
* Entity selection event data structure * Entity selection event data structure
*/ */
interface EntitySelectionEvent { interface EntitySelectionEvent {
type: "person" | "project" | "special"; type: "person" | "project";
entityType?: string; data: Contact | PlanData;
data: Contact | PlanData | EntityData;
} }
/** /**
@ -154,6 +154,10 @@ export default class EntitySelectionStep extends Vue {
@Prop() @Prop()
notify?: (notification: NotificationIface, timeout?: number) => void; notify?: (notification: NotificationIface, timeout?: number) => void;
/** Whether to hide the "Show All" navigation */
@Prop({ default: false })
hideShowAll!: boolean;
/** /**
* CSS classes for the cancel button * CSS classes for the cancel button
*/ */

36
src/components/EntitySummaryButton.vue

@ -42,8 +42,8 @@ computed CSS properties * * @author Matthew Raymer */
<p class="text-xs text-slate-500 leading-1 -mb-1 uppercase"> <p class="text-xs text-slate-500 leading-1 -mb-1 uppercase">
{{ label }} {{ label }}
</p> </p>
<h3 class="font-semibold truncate"> <h3 :class="nameClasses">
{{ entity?.name || "Unnamed" }} {{ displayName }}
</h3> </h3>
</div> </div>
@ -138,6 +138,38 @@ export default class EntitySummaryButton extends Vue {
return this.editable ? "text-blue-500" : "text-slate-400"; return this.editable ? "text-blue-500" : "text-slate-400";
} }
/**
* Computed CSS classes for the entity name
*/
get nameClasses(): string {
const baseClasses = "font-semibold truncate";
// Add italic styling for special "Unnamed" or entities without set names
if (!this.entity?.name || this.entity?.did === "") {
return `${baseClasses} italic text-slate-500`;
}
return baseClasses;
}
/**
* Computed display name for the entity
*/
get displayName(): string {
// If the entity has a set name, use that name
if (this.entity?.name) {
return this.entity.name;
}
// If the entity is the special "Unnamed", use "Unnamed"
if (this.entity?.did === "") {
return "Unnamed";
}
// If the entity does not have a set name, but is not the special "Unnamed", use their DID
return this.entity?.did;
}
/** /**
* Handle click event - only call function prop if editable * Handle click event - only call function prop if editable
* Allows parent to control edit behavior and validation * Allows parent to control edit behavior and validation

71
src/components/GiftedDialog.vue

@ -29,6 +29,7 @@
:unit-code="unitCode" :unit-code="unitCode"
:offer-id="offerId" :offer-id="offerId"
:notify="$notify" :notify="$notify"
:hide-show-all="hideShowAll"
@entity-selected="handleEntitySelected" @entity-selected="handleEntitySelected"
@cancel="cancel" @cancel="cancel"
/> />
@ -114,6 +115,7 @@ export default class GiftedDialog extends Vue {
@Prop() fromProjectId = ""; @Prop() fromProjectId = "";
@Prop() toProjectId = ""; @Prop() toProjectId = "";
@Prop() isFromProjectView = false; @Prop() isFromProjectView = false;
@Prop() hideShowAll = false;
@Prop({ default: "person" }) giverEntityType = "person" as @Prop({ default: "person" }) giverEntityType = "person" as
| "person" | "person"
| "project"; | "project";
@ -224,14 +226,7 @@ export default class GiftedDialog extends Vue {
this.allMyDids = await retrieveAccountDids(); this.allMyDids = await retrieveAccountDids();
if (this.giver && !this.giver.name) {
this.giver.name = didInfo(
this.giver.did,
this.activeDid,
this.allMyDids,
this.allContacts,
);
}
if ( if (
this.giverEntityType === "project" || this.giverEntityType === "project" ||
@ -455,7 +450,7 @@ export default class GiftedDialog extends Vue {
if (contact) { if (contact) {
this.giver = { this.giver = {
did: contact.did, did: contact.did,
name: contact.name || contact.did, name: contact.name,
}; };
} else { } else {
// Only set to "Unnamed" if no giver is currently set // Only set to "Unnamed" if no giver is currently set
@ -517,7 +512,7 @@ export default class GiftedDialog extends Vue {
if (contact) { if (contact) {
this.receiver = { this.receiver = {
did: contact.did, did: contact.did,
name: contact.name || contact.did, name: contact.name,
}; };
} else { } else {
// Only set to "Unnamed" if no receiver is currently set // Only set to "Unnamed" if no receiver is currently set
@ -566,20 +561,21 @@ export default class GiftedDialog extends Vue {
/** /**
* Handle entity selection from EntitySelectionStep * Handle entity selection from EntitySelectionStep
* @param entity - The selected entity (person, project, or special) with stepType * @param entity - The selected entity (person or project) with stepType
*/ */
handleEntitySelected(entity: { handleEntitySelected(entity: {
type: "person" | "project" | "special"; type: "person" | "project";
entityType?: string; data: Contact | PlanData;
data: Contact | PlanData | { did?: string; name: string };
stepType: string; stepType: string;
}) { }) {
if (entity.type === "person") { if (entity.type === "person") {
const contact = entity.data as Contact; const contact = entity.data as Contact;
// Apply DID-based logic for person entities
const processedContact = this.processPersonEntity(contact);
if (entity.stepType === "giver") { if (entity.stepType === "giver") {
this.selectGiver(contact); this.selectGiver(processedContact);
} else { } else {
this.selectRecipient(contact); this.selectRecipient(processedContact);
} }
} else if (entity.type === "project") { } else if (entity.type === "project") {
const project = entity.data as PlanData; const project = entity.data as PlanData;
@ -588,33 +584,22 @@ export default class GiftedDialog extends Vue {
} else { } else {
this.selectRecipientProject(project); this.selectRecipientProject(project);
} }
} else if (entity.type === "special") { }
// Handle special entities like "You" and "Unnamed" }
if (entity.entityType === "you") {
// "You" entity selected /**
const youEntity = { * Processes person entities using DID-based logic for "You" and "Unnamed"
did: this.activeDid, */
name: "You", private processPersonEntity(contact: Contact): Contact {
}; if (contact.did === this.activeDid) {
if (entity.stepType === "giver") { // If DID matches active DID, create "You" entity
this.giver = youEntity; return { ...contact, name: "You" };
} else { } else if (!contact.did || contact.did === "") {
this.receiver = youEntity; // If DID is empty/null, create "Unnamed" entity
} return { ...contact, name: "Unnamed" };
this.firstStep = false; } else {
} else if (entity.entityType === "unnamed") { // Return the contact as-is
// "Unnamed" entity selected return contact;
const unnamedEntity = {
did: "",
name: "Unnamed",
};
if (entity.stepType === "giver") {
this.giver = unnamedEntity;
} else {
this.receiver = unnamedEntity;
}
this.firstStep = false;
}
} }
} }

22
src/components/PersonCard.vue

@ -25,7 +25,7 @@ conflict detection. * * @author Matthew Raymer */
</div> </div>
<h3 :class="nameClasses"> <h3 :class="nameClasses">
{{ person.name || person.did || "Unnamed" }} {{ displayName }}
</h3> </h3>
</li> </li>
</template> </template>
@ -98,9 +98,27 @@ export default class PersonCard extends Vue {
return `${baseClasses} text-slate-400`; return `${baseClasses} text-slate-400`;
} }
// Add italic styling for entities without set names
if (!this.person.name) {
return `${baseClasses} italic text-slate-500`;
}
return baseClasses; return baseClasses;
} }
/**
* Computed display name for the person
*/
get displayName(): string {
// If the entity has a set name, use that name
if (this.person.name) {
return this.person.name;
}
// If the entity does not have a set name
return this.person.did;
}
/** /**
* Handle card click - emit if selectable and not conflicted, show warning if conflicted * Handle card click - emit if selectable and not conflicted, show warning if conflicted
*/ */
@ -114,7 +132,7 @@ export default class PersonCard extends Vue {
group: "alert", group: "alert",
type: "warning", type: "warning",
title: "Cannot Select", title: "Cannot Select",
text: `You cannot select "${this.person.name || this.person.did || "Unnamed"}" because they are already selected as the ${this.conflictContext}.`, text: `You cannot select "${this.displayName}" because they are already selected as the ${this.conflictContext}.`,
}, },
3000, 3000,
); );

10
src/components/SpecialEntityCard.vue

@ -124,8 +124,6 @@ export default class SpecialEntityCard extends Vue {
handleClick(): void { handleClick(): void {
if (this.selectable && !this.conflicted) { if (this.selectable && !this.conflicted) {
this.emitEntitySelected({ this.emitEntitySelected({
type: "special",
entityType: this.entityType,
data: this.entityData, data: this.entityData,
}); });
} else if (this.conflicted && this.notify) { } else if (this.conflicted && this.notify) {
@ -145,13 +143,7 @@ export default class SpecialEntityCard extends Vue {
// Emit methods using @Emit decorator // Emit methods using @Emit decorator
@Emit("entity-selected") @Emit("entity-selected")
emitEntitySelected(data: { emitEntitySelected(data: { data: { did?: string; name: string } }): {
type: string;
entityType: string;
data: { did?: string; name: string };
}): {
type: string;
entityType: string;
data: { did?: string; name: string }; data: { did?: string; name: string };
} { } {
return data; return data;

289
src/views/ContactGiftingView.vue

@ -17,20 +17,38 @@
<!-- Results List --> <!-- Results List -->
<ul class="border-t border-slate-300"> <ul class="border-t border-slate-300">
<!-- "You" entity -->
<li v-if="shouldShowYouEntity" class="border-b border-slate-300 py-3">
<h2 class="text-base flex gap-4 items-center">
<span class="grow flex gap-2 items-center font-medium">
<font-awesome icon="hand" class="text-blue-500 text-4xl shrink-0" />
<span class="text-ellipsis overflow-hidden text-blue-500">You</span>
</span>
<span class="text-right">
<button
type="button"
class="block w-full text-center text-sm uppercase bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-3 py-1.5 rounded-md"
@click="openDialog({ did: activeDid, name: 'You' })"
>
<font-awesome icon="gift" class="fa-fw"></font-awesome>
</button>
</span>
</h2>
</li>
<li class="border-b border-slate-300 py-3"> <li class="border-b border-slate-300 py-3">
<h2 class="text-base flex gap-4 items-center"> <h2 class="text-base flex gap-4 items-center">
<span class="grow flex gap-2 items-center font-medium"> <span class="grow flex gap-2 items-center font-medium">
<font-awesome <font-awesome
icon="circle-question" icon="circle-question"
class="text-slate-400 text-4xl" class="text-slate-400 text-4xl shrink-0"
/> />
<span class="italic text-slate-400">(Unnamed/Unknown)</span> <span class="text-ellipsis overflow-hidden italic text-slate-500">(Unnamed/Unknown)</span>
</span> </span>
<span class="text-right"> <span class="text-right">
<button <button
type="button" type="button"
class="block w-full text-center text-sm uppercase bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-3 py-1.5 rounded-md" class="block w-full text-center text-sm uppercase bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-3 py-1.5 rounded-md"
@click="openDialog('Unnamed')" @click="openDialog({ did: '', name: 'Unnamed' })"
> >
<font-awesome icon="gift" class="fa-fw"></font-awesome> <font-awesome icon="gift" class="fa-fw"></font-awesome>
</button> </button>
@ -43,14 +61,14 @@
class="border-b border-slate-300 py-3" class="border-b border-slate-300 py-3"
> >
<h2 class="text-base flex gap-4 items-center"> <h2 class="text-base flex gap-4 items-center">
<span class="grow flex gap-2 items-center font-medium"> <span class="grow flex gap-2 items-center font-medium overflow-hidden">
<EntityIcon <EntityIcon
:contact="contact" :contact="contact"
:icon-size="34" :icon-size="34"
class="inline-block align-middle border border-slate-300 rounded-full overflow-hidden" class="inline-block align-middle border border-slate-300 rounded-full overflow-hidden shrink-0"
/> />
<span v-if="contact.name">{{ contact.name }}</span> <span v-if="contact.name" class="text-ellipsis overflow-hidden">{{ contact.name }}</span>
<span v-else class="italic text-slate-400">(No name)</span> <span v-else class="text-ellipsis overflow-hidden italic text-slate-500">{{ contact.did }}</span>
</span> </span>
<span class="text-right"> <span class="text-right">
<button <button
@ -72,6 +90,7 @@
:from-project-id="fromProjectId" :from-project-id="fromProjectId"
:to-project-id="toProjectId" :to-project-id="toProjectId"
:is-from-project-view="isFromProjectView" :is-from-project-view="isFromProjectView"
:hide-show-all="true"
/> />
</section> </section>
</template> </template>
@ -188,147 +207,143 @@ export default class ContactGiftingView extends Vue {
} }
} }
openDialog(contact?: GiverReceiverInputInfo | "Unnamed") { openDialog(contact?: GiverReceiverInputInfo) {
if (contact === "Unnamed") { // Determine the selected entity based on contact type
// Special case: Handle "Unnamed" contacts for both givers and recipients const selectedEntity = this.createEntityFromContact(contact);
let recipient: GiverReceiverInputInfo;
let giver: GiverReceiverInputInfo | undefined;
if (this.stepType === "giver") { // Create giver and recipient based on step type and selected entity
// We're selecting a giver, so preserve the existing recipient from context const { giver, recipient } = this.createGiverAndRecipient(selectedEntity);
if (this.recipientEntityType === "project") {
recipient = {
did: this.recipientProjectHandleId,
name: this.recipientProjectName,
image: this.recipientProjectImage,
handleId: this.recipientProjectHandleId,
};
} else {
// Preserve the existing recipient from context
if (this.recipientDid === this.activeDid) {
// Recipient was "You"
recipient = { did: this.activeDid, name: "You" };
} else if (this.recipientDid) {
// Recipient was a regular contact
recipient = {
did: this.recipientDid,
name: this.recipientProjectName || "Someone",
};
} else {
// Fallback to "You" if no recipient was previously selected
recipient = { did: this.activeDid, name: "You" };
}
}
giver = undefined; // Will be set to "Unnamed" in GiftedDialog
} else {
// We're selecting a recipient, so recipient is "Unnamed" and giver is preserved from context
recipient = { did: "", name: "Unnamed" };
// Preserve the existing giver from the context // Open the dialog
if (this.giverEntityType === "project") { (this.$refs.giftedDialog as GiftedDialog).open(
giver = { giver,
did: this.giverProjectHandleId, recipient,
name: this.giverProjectName, this.offerId,
image: this.giverProjectImage, this.prompt,
handleId: this.giverProjectHandleId, this.description,
}; this.amountInput,
} else if (this.giverDid) { this.unitCode,
giver = { );
did: this.giverDid,
name: this.giverProjectName || "Someone",
};
} else {
giver = { did: this.activeDid, name: "You" };
}
}
(this.$refs.giftedDialog as GiftedDialog).open( // Move to Step 2 - entities are already set by the open() call
giver, (this.$refs.giftedDialog as GiftedDialog).moveToStep2();
recipient, }
this.offerId,
this.prompt, /**
this.description, * Creates an entity object from the contact parameter
this.amountInput, * Uses DID-based logic to determine "You" and "Unnamed" entities
this.unitCode, */
); private createEntityFromContact(
trentlarson marked this conversation as resolved
Review

Let's change this logic a little bit, because there are redundant potential states:

  • The "contact" could be null/undefined. That is the case where "Unnamed" would be used, so we don't need a separate "Unnamed" value. (If we have both potential cases then we have to include similar logic to work with both cases, which makes it more complex.)

  • The contact could be the current user's activeDid, so that's what we should use in the openDialog instead of the word "You". (We should be checking here for the activeDid... and if we also have to check "You" then there is duplicate logic again... again adding to the complexity and difficulty of maintenance.)

Let's change this logic a little bit, because there are redundant potential states: * The "contact" could be null/undefined. That is the case where "Unnamed" would be used, so we don't need a separate "Unnamed" value. (If we have both potential cases then we have to include similar logic to work with both cases, which makes it more complex.) * The contact could be the current user's activeDid, so that's what we should use in the openDialog instead of the word "You". (We should be checking here for the activeDid... and if we also have to check "You" then there is duplicate logic again... again adding to the complexity and difficulty of maintenance.)
contact?: GiverReceiverInputInfo,
): GiverReceiverInputInfo | undefined {
if (!contact) {
return undefined;
}
// Move to Step 2 - entities are already set by the open() call // Handle GiverReceiverInputInfo object
(this.$refs.giftedDialog as GiftedDialog).moveToStep2(); if (contact.did === this.activeDid) {
// If DID matches active DID, create "You" entity
return { did: this.activeDid, name: "You" };
} else if (!contact.did || contact.did === "") {
// If DID is empty/null, create "Unnamed" entity
return { did: "", name: "Unnamed" };
} else { } else {
// Regular case: contact is a GiverReceiverInputInfo // Create a copy of the contact to avoid modifying the original
let giver: GiverReceiverInputInfo; return { ...contact };
let recipient: GiverReceiverInputInfo; }
}
if (this.stepType === "giver") { /**
// We're selecting a giver, so the contact becomes the giver * Creates giver and recipient objects based on step type and selected entity
giver = contact as GiverReceiverInputInfo; // Safe because we know contact is not "Unnamed" or undefined */
private createGiverAndRecipient(selectedEntity?: GiverReceiverInputInfo): {
giver: GiverReceiverInputInfo | undefined;
recipient: GiverReceiverInputInfo;
} {
if (this.stepType === "giver") {
// We're selecting a giver, so the selected entity becomes the giver
const giver = selectedEntity;
const recipient = this.createRecipientFromContext();
return { giver, recipient };
} else {
// We're selecting a recipient, so the selected entity becomes the recipient
const recipient = selectedEntity || { did: "", name: "Unnamed" };
const giver = this.createGiverFromContext();
return { giver, recipient };
}
}
// Preserve the existing recipient from the context /**
if (this.recipientEntityType === "project") { * Creates recipient object from context (preserves existing recipient)
recipient = { */
did: this.recipientProjectHandleId, private createRecipientFromContext(): GiverReceiverInputInfo {
name: this.recipientProjectName, if (this.recipientEntityType === "project") {
image: this.recipientProjectImage, return {
handleId: this.recipientProjectHandleId, did: this.recipientProjectHandleId,
}; name: this.recipientProjectName,
} else { image: this.recipientProjectImage,
// Check if the preserved recipient was "You" or a regular contact handleId: this.recipientProjectHandleId,
if (this.recipientDid === this.activeDid) { };
// Recipient was "You" } else {
recipient = { did: this.activeDid, name: "You" }; if (this.recipientDid === this.activeDid) {
} else if (this.recipientDid) { return { did: this.activeDid, name: "You" };
// Recipient was a regular contact } else if (this.recipientDid) {
recipient = { return {
did: this.recipientDid, did: this.recipientDid,
name: this.recipientProjectName || "Someone", name: this.recipientProjectName,
}; };
} else {
// Fallback to "Unnamed"
recipient = { did: "", name: "Unnamed" };
}
}
} else { } else {
// We're selecting a recipient, so the contact becomes the recipient return { did: "", name: "Unnamed" };
recipient = contact as GiverReceiverInputInfo; // Safe because we know contact is not "Unnamed" or undefined
// Preserve the existing giver from the context
if (this.giverEntityType === "project") {
giver = {
did: this.giverProjectHandleId,
name: this.giverProjectName,
image: this.giverProjectImage,
handleId: this.giverProjectHandleId,
};
} else {
// Check if the preserved giver was "You" or a regular contact
if (this.giverDid === this.activeDid) {
// Giver was "You"
giver = { did: this.activeDid, name: "You" };
} else if (this.giverDid) {
// Giver was a regular contact
giver = {
did: this.giverDid,
name: this.giverProjectName || "Someone",
};
} else {
// Fallback to "Unnamed"
giver = { did: "", name: "Unnamed" };
}
}
} }
}
}
(this.$refs.giftedDialog as GiftedDialog).open( /**
giver, * Creates giver object from context (preserves existing giver)
recipient, */
this.offerId, private createGiverFromContext(): GiverReceiverInputInfo {
this.prompt, if (this.giverEntityType === "project") {
this.description, return {
this.amountInput, did: this.giverProjectHandleId,
this.unitCode, name: this.giverProjectName,
); image: this.giverProjectImage,
handleId: this.giverProjectHandleId,
};
} else {
if (this.giverDid === this.activeDid) {
return { did: this.activeDid, name: "You" };
} else if (this.giverDid) {
return {
did: this.giverDid,
name: this.giverProjectName,
};
} else {
return { did: "", name: "Unnamed" };
}
}
}
// Move to Step 2 - entities are already set by the open() call get shouldShowYouEntity(): boolean {
(this.$refs.giftedDialog as GiftedDialog).moveToStep2(); if (this.stepType === "giver") {
// When selecting a giver, show "You" if the current recipient is not "You"
// This prevents selecting yourself as both giver and recipient
if (this.recipientEntityType === "project") {
// If recipient is a project, we can select "You" as giver
return true;
} else {
// If recipient is a person, check if it's not "You"
return this.recipientDid !== this.activeDid;
}
} else {
// When selecting a recipient, show "You" if the current giver is not "You"
// This prevents selecting yourself as both giver and recipient
if (this.giverEntityType === "project") {
// If giver is a project, we can select "You" as recipient
return true;
} else {
// If giver is a person, check if it's not "You"
return this.giverDid !== this.activeDid;
}
} }
} }
} }

62
src/views/HomeView.vue

@ -1475,30 +1475,41 @@ export default class HomeView extends Vue {
* @param giver Optional contact info for giver * @param giver Optional contact info for giver
* @param description Optional gift description * @param description Optional gift description
*/ */
openDialog(giver?: GiverReceiverInputInfo | "Unnamed", prompt?: string) { openDialog(giver?: GiverReceiverInputInfo, prompt?: string) {
if (giver === "Unnamed") { // Determine the giver entity based on DID logic
// Special case: Pass undefined to trigger Step 1, but with "Unnamed" pre-selected const giverEntity = this.createGiverEntity(giver);
(this.$refs.giftedDialog as GiftedDialog).open(
undefined, (this.$refs.giftedDialog as GiftedDialog).open(
{ giverEntity,
did: this.activeDid, {
name: "You", did: this.activeDid,
} as GiverReceiverInputInfo, name: "You", // In HomeView, we always use "You" as the giver
undefined, } as GiverReceiverInputInfo,
prompt, undefined,
); prompt,
// Immediately select "Unnamed" and move to Step 2 );
(this.$refs.giftedDialog as GiftedDialog).selectGiver(); }
/**
* Creates giver entity using DID-based logic
*/
private createGiverEntity(
giver?: GiverReceiverInputInfo,
): GiverReceiverInputInfo | undefined {
if (!giver) {
return undefined;
}
// Handle GiverReceiverInputInfo object
if (giver.did === this.activeDid) {
// If DID matches active DID, create "You" entity
return { did: this.activeDid, name: "You" };
} else if (!giver.did || giver.did === "") {
// If DID is empty/null, create "Unnamed" entity
return { did: "", name: "Unnamed" };
} else { } else {
(this.$refs.giftedDialog as GiftedDialog).open( // Return the giver as-is
giver, return giver;
{
did: this.activeDid,
name: "You",
} as GiverReceiverInputInfo,
undefined,
prompt,
);
} }
} }
@ -1627,10 +1638,7 @@ export default class HomeView extends Vue {
} }
} }
openPersonDialog( openPersonDialog(giver?: GiverReceiverInputInfo, prompt?: string) {
giver?: GiverReceiverInputInfo | "Unnamed",
prompt?: string,
) {
this.showProjectsDialog = false; this.showProjectsDialog = false;
this.openDialog(giver, prompt); this.openDialog(giver, prompt);
} }

Loading…
Cancel
Save