diff --git a/src/components/GiftedDialog.vue b/src/components/GiftedDialog.vue index 754c9bf6..4f44bb8d 100644 --- a/src/components/GiftedDialog.vue +++ b/src/components/GiftedDialog.vue @@ -1,99 +1,477 @@ + + + + + + + +
+
+ + +
+
+ + +
+ +
+

+ {{ + giverEntityType === "project" + ? "Benefited from:" + : "Received from:" + }} +

+

+ {{ giver?.name || "Unnamed" }} +

+
+ +

+ +

+
+ + + +
+
+ +
+ +
+

+ Given to project: +

+

+ {{ receiver?.name || "Unnamed" }} +

+
+ +

+ +

+
-
+ + + + + +
+ - + Photo & more options… + +

+ Sign & Send to publish to the world + +

+ + +
+

+ + Cannot record: Same person selected as both giver and recipient +

-
-
- - +
-

- Sign & Send to publish to the world - -

-
- - + Sign & Send + + +
diff --git a/src/libs/fontawesome.ts b/src/libs/fontawesome.ts index 37b5343c..4fa56f0a 100644 --- a/src/libs/fontawesome.ts +++ b/src/libs/fontawesome.ts @@ -29,6 +29,7 @@ import { faCircleCheck, faCircleInfo, faCircleQuestion, + faCircleRight, faCircleUser, faClock, faCoins, @@ -60,6 +61,7 @@ import { faLightbulb, faLink, faLocationDot, + faLock, faLongArrowAltLeft, faLongArrowAltRight, faMagnifyingGlass, @@ -79,6 +81,7 @@ import { faSquareCaretDown, faSquareCaretUp, faSquarePlus, + faThumbtack, faTrashCan, faTriangleExclamation, faUser, @@ -111,6 +114,7 @@ library.add( faCircleCheck, faCircleInfo, faCircleQuestion, + faCircleRight, faCircleUser, faClock, faCoins, @@ -142,6 +146,7 @@ library.add( faLightbulb, faLink, faLocationDot, + faLock, faLongArrowAltLeft, faLongArrowAltRight, faMagnifyingGlass, @@ -161,6 +166,7 @@ library.add( faSquareCaretDown, faSquareCaretUp, faSquarePlus, + faThumbtack, faTrashCan, faTriangleExclamation, faUser, diff --git a/src/libs/util.ts b/src/libs/util.ts index 3bc86866..81d04835 100644 --- a/src/libs/util.ts +++ b/src/libs/util.ts @@ -49,6 +49,8 @@ import { insertDidSpecificSettings, parseJsonField } from "../db/databaseUtil"; export interface GiverReceiverInputInfo { did?: string; name?: string; + image?: string; + handleId?: string; } export enum OnboardPage { diff --git a/src/views/ContactGiftingView.vue b/src/views/ContactGiftingView.vue index c359a817..03241073 100644 --- a/src/views/ContactGiftingView.vue +++ b/src/views/ContactGiftingView.vue @@ -11,7 +11,7 @@ class="text-lg text-center px-2 py-1 absolute -left-2 -top-1" > - Given by... + {{ stepType === "giver" ? "Given by..." : "Given to..." }} @@ -31,7 +31,7 @@ @@ -65,7 +65,13 @@ - + @@ -97,6 +103,24 @@ export default class ContactGiftingView extends Vue { description = ""; projectId = ""; prompt = ""; + recipientProjectName = ""; + recipientProjectImage = ""; + recipientProjectHandleId = ""; + + // New context parameters + stepType = "giver"; + giverEntityType = "person" as "person" | "project"; + recipientEntityType = "person" as "person" | "project"; + giverProjectId = ""; + giverProjectName = ""; + giverProjectImage = ""; + giverProjectHandleId = ""; + giverDid = ""; + recipientDid = ""; + fromProjectId = ""; + toProjectId = ""; + showProjects = false; + isFromProjectView = false; async created() { try { @@ -124,9 +148,41 @@ export default class ContactGiftingView extends Vue { ); } - this.projectId = (this.$route.query["projectId"] as string) || ""; + this.projectId = + (this.$route.query["recipientProjectId"] as string) || ""; + this.recipientProjectName = + (this.$route.query["recipientProjectName"] as string) || ""; + this.recipientProjectImage = + (this.$route.query["recipientProjectImage"] as string) || ""; + this.recipientProjectHandleId = + (this.$route.query["recipientProjectHandleId"] as string) || ""; this.prompt = (this.$route.query["prompt"] as string) ?? this.prompt; + // Read new context parameters + this.stepType = (this.$route.query["stepType"] as string) || "giver"; + this.giverEntityType = + (this.$route.query["giverEntityType"] as "person" | "project") || + "person"; + this.recipientEntityType = + (this.$route.query["recipientEntityType"] as "person" | "project") || + "person"; + this.giverProjectId = + (this.$route.query["giverProjectId"] as string) || ""; + this.giverProjectName = + (this.$route.query["giverProjectName"] as string) || ""; + this.giverProjectImage = + (this.$route.query["giverProjectImage"] as string) || ""; + this.giverProjectHandleId = + (this.$route.query["giverProjectHandleId"] as string) || ""; + this.giverDid = (this.$route.query["giverDid"] as string) || ""; + this.recipientDid = (this.$route.query["recipientDid"] as string) || ""; + this.fromProjectId = (this.$route.query["fromProjectId"] as string) || ""; + this.toProjectId = (this.$route.query["toProjectId"] as string) || ""; + this.showProjects = + (this.$route.query["showProjects"] as string) === "true"; + this.isFromProjectView = + (this.$route.query["isFromProjectView"] as string) === "true"; + // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (err: any) { logger.error("Error retrieving settings & contacts:", err); @@ -144,17 +200,108 @@ export default class ContactGiftingView extends Vue { } } - openDialog(giver?: GiverReceiverInputInfo) { - const recipient = this.projectId - ? undefined - : { did: this.activeDid, name: "you" }; - (this.$refs.customDialog as GiftedDialog).open( - giver, - recipient, - undefined, - "Given by " + (giver?.name || "someone not named"), - this.prompt, - ); + openDialog(contact?: GiverReceiverInputInfo | "Unnamed") { + if (contact === "Unnamed") { + // Special case: Pass undefined to trigger Step 1, but with "Unnamed" pre-selected + let recipient: GiverReceiverInputInfo; + let giver: GiverReceiverInputInfo | undefined; + + if (this.stepType === "giver") { + // We're selecting a giver, so recipient is either a project or the current user + if (this.recipientEntityType === "project") { + recipient = { + did: this.recipientProjectHandleId, + name: this.recipientProjectName, + image: this.recipientProjectImage, + handleId: this.recipientProjectHandleId, + }; + } else { + 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 + if (this.giverEntityType === "project") { + giver = { + did: this.giverProjectHandleId, + name: this.giverProjectName, + image: this.giverProjectImage, + handleId: this.giverProjectHandleId, + }; + } else if (this.giverDid) { + giver = { + did: this.giverDid, + name: this.giverProjectName || "Someone", + }; + } else { + giver = { did: this.activeDid, name: "You" }; + } + } + + (this.$refs.customDialog as GiftedDialog).open( + giver, + recipient, + undefined, + this.stepType === "giver" ? "Given by Unnamed" : "Given to Unnamed", + this.prompt, + ); + // Immediately select "Unnamed" and move to Step 2 + (this.$refs.customDialog as GiftedDialog).selectGiver(); + } else { + // Regular case: contact is a GiverReceiverInputInfo + let giver: GiverReceiverInputInfo; + let recipient: GiverReceiverInputInfo; + + if (this.stepType === "giver") { + // We're selecting a giver, so the contact becomes the giver + giver = contact as GiverReceiverInputInfo; // Safe because we know contact is not "Unnamed" or undefined + + // Recipient is either a project or the current user + if (this.recipientEntityType === "project") { + recipient = { + did: this.recipientProjectHandleId, + name: this.recipientProjectName, + image: this.recipientProjectImage, + handleId: this.recipientProjectHandleId, + }; + } else { + recipient = { did: this.activeDid, name: "You" }; + } + } else { + // We're selecting a recipient, so the contact becomes the recipient + 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 if (this.giverDid) { + giver = { + did: this.giverDid, + name: this.giverProjectName || "Someone", + }; + } else { + giver = { did: this.activeDid, name: "You" }; + } + } + + (this.$refs.customDialog as GiftedDialog).open( + giver, + recipient, + undefined, + this.stepType === "giver" + ? "Given by " + (contact?.name || "someone not named") + : "Given to " + (contact?.name || "someone not named"), + this.prompt, + ); + } } } diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 24ce8255..1a145a1c 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -117,101 +117,73 @@ Raymer * @version 1.0.0 */
- - - -
-

What have you seen someone do?

- -
- -
    -
  • - -

    +
    +
    +

    Record something given by:

    +

    -
  • -
  • - (Add friends to see more people worthy of recognition.) -
  • -
  • - -

    + +

+ +
+ + +
+ - + -
- -
-
-
-

- Latest Activity - - -

+
+

Latest Activity

+ +
= new Map(); + showProjectsDialog = false; /** * Initializes the component on mount @@ -1637,17 +1610,33 @@ export default class HomeView extends Vue { * @param giver Optional contact info for giver * @param description Optional gift description */ - openDialog(giver?: GiverReceiverInputInfo, description?: string) { - (this.$refs.customDialog as GiftedDialog).open( - giver, - { - did: this.activeDid, - name: "you", - } as GiverReceiverInputInfo, - undefined, - "Given by " + (giver?.name || "someone not named"), - description, - ); + openDialog(giver?: GiverReceiverInputInfo | "Unnamed", description?: string) { + if (giver === "Unnamed") { + // Special case: Pass undefined to trigger Step 1, but with "Unnamed" pre-selected + (this.$refs.customDialog as GiftedDialog).open( + undefined, + { + did: this.activeDid, + name: "You", + } as GiverReceiverInputInfo, + undefined, + "Given by Unnamed", + description, + ); + // Immediately select "Unnamed" and move to Step 2 + (this.$refs.customDialog as GiftedDialog).selectGiver(); + } else { + (this.$refs.customDialog as GiftedDialog).open( + giver, + { + did: this.activeDid, + name: "You", + } as GiverReceiverInputInfo, + undefined, + "Given by " + (giver?.name || "someone not named"), + description, + ); + } } /** @@ -1881,5 +1870,18 @@ export default class HomeView extends Vue { this.$router.push({ name: "contact-qr" }); } } + + openDialogPerson( + giver?: GiverReceiverInputInfo | "Unnamed", + description?: string, + ) { + this.showProjectsDialog = false; + this.openDialog(giver, description); + } + + openProjectDialog() { + this.showProjectsDialog = true; + (this.$refs.customDialog as any).open(); + } } diff --git a/src/views/ProjectViewView.vue b/src/views/ProjectViewView.vue index 0aaacc98..e86abcd9 100644 --- a/src/views/ProjectViewView.vue +++ b/src/views/ProjectViewView.vue @@ -196,63 +196,11 @@
-
-
-

Record a contribution from:

-
-
    -
  • - -

    - You -

    -
  • -
  • - -

    - Unnamed/Unknown -

    -
  • -
  • - -

    - {{ contact.name || "(no name)" }} -

    -
  • -
  • - - ... or someone else... - -
  • -
-
- +
@@ -518,7 +466,12 @@
- +

Benefitted From This Project @@ -1229,21 +1182,53 @@ export default class ProjectViewView extends Vue { ); } - openGiftDialogToProject(contact?: libsUtil.GiverReceiverInputInfo) { - (this.$refs.giveDialogToThis as GiftedDialog).open( - contact, - undefined, - undefined, - (contact?.name || "Someone not named") + ` gave to this project`, - ); + openGiftDialogToProject( + contact?: libsUtil.GiverReceiverInputInfo | "Unnamed", + ) { + if (contact === "Unnamed") { + // Special case: Pass undefined to trigger Step 1, but with "Unnamed" pre-selected + (this.$refs.giveDialogToThis as GiftedDialog).open( + undefined, + undefined, + undefined, + "Given by Unnamed to this project", + ); + // Immediately select "Unnamed" and move to Step 2 + (this.$refs.giveDialogToThis as GiftedDialog).selectGiver(); + } else { + // Open straight to Step 2 with current user as giver and current project as recipient + (this.$refs.giveDialogToThis as GiftedDialog).open( + { + did: this.activeDid, + name: "You", + }, + { + did: this.issuer, + name: this.name, + handleId: this.projectId, + image: this.imageUrl, + }, + undefined, + `Given to ${this.name}`, + ); + } } openGiftDialogFromProject() { + // Set the project as giver and the current user as recipient (this.$refs.giveDialogFromThis as GiftedDialog).open( - undefined, + { + did: undefined, + name: this.name, + handleId: this.projectId, + image: this.imageUrl, + }, { did: this.activeDid, name: "You" }, undefined, - `This project gave to you`, + `${this.name} gave to you`, + undefined, + undefined, + true, ); }