forked from trent_larson/crowd-funder-for-time-pwa
Fix: handle special "You" entity
This commit is contained in:
@@ -11,17 +11,18 @@ details step with edit functionality. * * @author Matthew Raymer */
|
|||||||
<div>
|
<div>
|
||||||
<template v-if="entityType === 'project'">
|
<template v-if="entityType === 'project'">
|
||||||
<ProjectIcon
|
<ProjectIcon
|
||||||
v-if="entity?.handleId"
|
v-if="entity && 'handleId' in entity && entity.handleId"
|
||||||
:entity-id="entity.handleId"
|
:entity-id="entity.handleId"
|
||||||
:icon-size="32"
|
:icon-size="32"
|
||||||
:image-url="entity.image"
|
:image-url="'image' in entity ? entity.image : ''"
|
||||||
class="rounded-full bg-white overflow-hidden !size-[2rem] object-cover"
|
class="rounded-full bg-white overflow-hidden !size-[2rem] object-cover"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<EntityIcon
|
<EntityIcon
|
||||||
v-if="entity?.did"
|
v-if="entity?.did"
|
||||||
:contact="entity"
|
:entity-id="entity.did"
|
||||||
|
:contact="isContactEntity ? entity : undefined"
|
||||||
class="rounded-full bg-white overflow-hidden !size-[2rem] object-cover"
|
class="rounded-full bg-white overflow-hidden !size-[2rem] object-cover"
|
||||||
/>
|
/>
|
||||||
<font-awesome
|
<font-awesome
|
||||||
@@ -101,6 +102,13 @@ export default class EntitySummaryButton extends Vue {
|
|||||||
@Prop({ default: true })
|
@Prop({ default: true })
|
||||||
editable!: boolean;
|
editable!: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the entity is a Contact object
|
||||||
|
*/
|
||||||
|
get isContactEntity(): boolean {
|
||||||
|
return this.entity !== null && "profileImageUrl" in this.entity;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computed CSS classes for the edit/lock icon
|
* Computed CSS classes for the edit/lock icon
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
|
|||||||
mixins: [PlatformServiceMixin],
|
mixins: [PlatformServiceMixin],
|
||||||
})
|
})
|
||||||
export default class GiftedDialog extends Vue {
|
export default class GiftedDialog extends Vue {
|
||||||
|
$notify!: (notification: any, timeout?: number) => void;
|
||||||
notify!: ReturnType<typeof createNotifyHelpers>;
|
notify!: ReturnType<typeof createNotifyHelpers>;
|
||||||
|
|
||||||
@Prop() fromProjectId = "";
|
@Prop() fromProjectId = "";
|
||||||
@@ -564,11 +565,12 @@ export default class GiftedDialog extends Vue {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle entity selection from EntitySelectionStep
|
* Handle entity selection from EntitySelectionStep
|
||||||
* @param entity - The selected entity (person or project) with stepType
|
* @param entity - The selected entity (person, project, or special) with stepType
|
||||||
*/
|
*/
|
||||||
handleEntitySelected(entity: {
|
handleEntitySelected(entity: {
|
||||||
type: "person" | "project";
|
type: "person" | "project" | "special";
|
||||||
data: Contact | PlanData;
|
entityType?: string;
|
||||||
|
data: Contact | PlanData | { did?: string; name: string };
|
||||||
stepType: string;
|
stepType: string;
|
||||||
}) {
|
}) {
|
||||||
if (entity.type === "person") {
|
if (entity.type === "person") {
|
||||||
@@ -578,13 +580,40 @@ export default class GiftedDialog extends Vue {
|
|||||||
} else {
|
} else {
|
||||||
this.selectRecipient(contact);
|
this.selectRecipient(contact);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (entity.type === "project") {
|
||||||
const project = entity.data as PlanData;
|
const project = entity.data as PlanData;
|
||||||
if (entity.stepType === "giver") {
|
if (entity.stepType === "giver") {
|
||||||
this.selectProject(project);
|
this.selectProject(project);
|
||||||
} 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 = {
|
||||||
|
did: this.activeDid,
|
||||||
|
name: "You",
|
||||||
|
};
|
||||||
|
if (entity.stepType === "giver") {
|
||||||
|
this.giver = youEntity;
|
||||||
|
} else {
|
||||||
|
this.receiver = youEntity;
|
||||||
|
}
|
||||||
|
this.firstStep = false;
|
||||||
|
} else if (entity.entityType === "unnamed") {
|
||||||
|
// "Unnamed" entity selected
|
||||||
|
const unnamedEntity = {
|
||||||
|
did: "",
|
||||||
|
name: "Unnamed",
|
||||||
|
};
|
||||||
|
if (entity.stepType === "giver") {
|
||||||
|
this.giver = unnamedEntity;
|
||||||
|
} else {
|
||||||
|
this.receiver = unnamedEntity;
|
||||||
|
}
|
||||||
|
this.firstStep = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user