diff --git a/src/components/EntityGrid.vue b/src/components/EntityGrid.vue index a2552cd5..f5ab2e01 100644 --- a/src/components/EntityGrid.vue +++ b/src/components/EntityGrid.vue @@ -155,6 +155,7 @@ projects, and special entities with selection. * * @author Matthew Raymer */ :active-did="activeDid" :all-my-dids="allMyDids" :all-contacts="allContacts" + :conflicted="isProjectConflicted(project.handleId)" :notify="notify" :conflict-context="conflictContext" @project-selected="handleProjectSelected" @@ -175,6 +176,7 @@ projects, and special entities with selection. * * @author Matthew Raymer */ :active-did="activeDid" :all-my-dids="allMyDids" :all-contacts="allContacts" + :conflicted="isProjectConflicted(project.handleId)" :notify="notify" :conflict-context="conflictContext" @project-selected="handleProjectSelected" @@ -190,6 +192,7 @@ projects, and special entities with selection. * * @author Matthew Raymer */ :active-did="activeDid" :all-my-dids="allMyDids" :all-contacts="allContacts" + :conflicted="isProjectConflicted(project.handleId)" :notify="notify" :conflict-context="conflictContext" @project-selected="handleProjectSelected" @@ -555,6 +558,13 @@ export default class EntityGrid extends Vue { return this.conflictChecker(did); } + /** + * Check if a project handleId is conflicted + */ + isProjectConflicted(handleId: string): boolean { + return this.conflictChecker(handleId); + } + /** * Handle person selection from PersonCard */ diff --git a/src/components/GiftedDialog.vue b/src/components/GiftedDialog.vue index 1d085c47..a383ca09 100644 --- a/src/components/GiftedDialog.vue +++ b/src/components/GiftedDialog.vue @@ -179,22 +179,56 @@ export default class GiftedDialog extends Vue { return false; } - // Computed property to check if a contact would create a conflict when selected - wouldCreateConflict(contactDid: string) { - // Only check for conflicts when both entities are persons + // Computed property to check if current selection would create a project conflict + get hasProjectConflict() { + // Only check for conflicts when both entities are projects if ( - this.currentGiverEntityType !== "person" || - this.currentRecipientEntityType !== "person" + this.currentGiverEntityType !== "project" || + this.currentRecipientEntityType !== "project" ) { return false; } - if (this.stepType === "giver") { - // If selecting as giver, check if it conflicts with current recipient - return this.receiver?.did === contactDid; - } else if (this.stepType === "recipient") { - // If selecting as recipient, check if it conflicts with current giver - return this.giver?.did === contactDid; + // Check if giver and recipient are the same project + if ( + this.giver?.handleId && + this.receiver?.handleId && + this.giver.handleId === this.receiver.handleId + ) { + return true; + } + + return false; + } + + // Computed property to check if a contact or project would create a conflict when selected + wouldCreateConflict(identifier: string) { + // Check for person conflicts when both entities are persons + if ( + this.currentGiverEntityType === "person" && + this.currentRecipientEntityType === "person" + ) { + if (this.stepType === "giver") { + // If selecting as giver, check if it conflicts with current recipient + return this.receiver?.did === identifier; + } else if (this.stepType === "recipient") { + // If selecting as recipient, check if it conflicts with current giver + return this.giver?.did === identifier; + } + } + + // Check for project conflicts when both entities are projects + if ( + this.currentGiverEntityType === "project" && + this.currentRecipientEntityType === "project" + ) { + if (this.stepType === "giver") { + // If selecting as giver, check if it conflicts with current recipient + return this.receiver?.handleId === identifier; + } else if (this.stepType === "recipient") { + // If selecting as recipient, check if it conflicts with current giver + return this.giver?.handleId === identifier; + } } return false; @@ -363,6 +397,15 @@ export default class GiftedDialog extends Vue { return; } + // Check for project conflict + if (this.hasProjectConflict) { + this.safeNotify.error( + "You cannot select the same project as both giver and recipient.", + TIMEOUTS.STANDARD, + ); + return; + } + this.close(); this.safeNotify.toast( NOTIFY_GIFTED_DETAILS_RECORDING_GIVE.message, diff --git a/src/components/ProjectCard.vue b/src/components/ProjectCard.vue index 4b995a21..19824311 100644 --- a/src/components/ProjectCard.vue +++ b/src/components/ProjectCard.vue @@ -1,11 +1,8 @@ /** * ProjectCard.vue - Individual project display component * * Extracted from -GiftedDialog.vue to handle project entity display * with selection states and -issuer information. * * @author Matthew Raymer */ +GiftedDialog.vue to handle project entity display * with selection states, +conflict detection, and issuer information. * * @author Matthew Raymer */