forked from trent_larson/crowd-funder-for-time-pwa
do the same for the recipient: allow editing on the details page
This commit is contained in:
@@ -159,58 +159,47 @@
|
|||||||
<!-- Third Column for Recipient -->
|
<!-- Third Column for Recipient -->
|
||||||
<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"
|
||||||
|
>
|
||||||
|
<!-- Recipient Selection Display -->
|
||||||
|
<div
|
||||||
|
v-if="!showRecipientSelection"
|
||||||
|
class="cursor-pointer"
|
||||||
|
@click="openRecipientSelection"
|
||||||
>
|
>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<input
|
<label class="text-sm flex-1">
|
||||||
v-if="recipientDid && !givenToProject"
|
|
||||||
v-model="givenToRecipient"
|
|
||||||
type="checkbox"
|
|
||||||
class="flex-shrink-0 h-6 w-6 mr-2"
|
|
||||||
/>
|
|
||||||
<font-awesome
|
|
||||||
v-else
|
|
||||||
icon="square"
|
|
||||||
class="mr-2 bg-white text-white h-5 w-5 px-0.5 py-0.5 rounded-sm"
|
|
||||||
/>
|
|
||||||
<label class="text-sm truncate">
|
|
||||||
{{
|
{{
|
||||||
recipientDid
|
givenToProjectFunction() && fulfillsProjectName
|
||||||
? "This was given to " + recipientName + "."
|
? "To " + fulfillsProjectName
|
||||||
: "No named individual benefitted."
|
: givenToPersonFunction() && recipientName
|
||||||
|
? "To " + recipientName
|
||||||
|
: "Unnamed recipient"
|
||||||
}}
|
}}
|
||||||
</label>
|
</label>
|
||||||
<font-awesome
|
<span class="text-sm text-blue-500">Change</span>
|
||||||
v-if="!recipientDid || givenToProject"
|
<font-awesome icon="chevron-right" class="text-blue-500 ms-2" />
|
||||||
icon="info-circle"
|
</div>
|
||||||
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;
|
||||||
|
|||||||
Reference in New Issue
Block a user