Browse Source

allow to deselect the giver & refactor dialog to group giver vs recipient

split_build_process
Trent Larson 2 months ago
parent
commit
9861a1388e
  1. 262
      src/views/GiftedDetailsView.vue
  2. 6
      src/views/ProjectViewView.vue
  3. 4
      test-playwright/35-record-gift-from-image-share.spec.ts

262
src/views/GiftedDetailsView.vue

@ -95,73 +95,127 @@
</div> </div>
<ImageMethodDialog ref="imageDialog" /> <ImageMethodDialog ref="imageDialog" />
<div class="h-7 mt-4 flex"> <div class="mt-4 flex justify-between gap-2">
<input <!-- First Column for Giver -->
v-if="providerProjectId && !providedByGiver" <div class="flex-grow border border-slate-400 p-2 rounded-md">
type="checkbox" <div class="flex">
class="h-6 w-6 mr-2" <input
v-model="providedByProject" v-if="giverDid && !providedByProject"
/> type="checkbox"
<fa class="h-6 w-6 mr-2"
v-else v-model="providedByGiver"
icon="square" />
class="bg-slate-500 text-slate-500 h-5 w-5 px-0.5 py-0.5 mr-2 rounded" <fa
@click="notifyUserOfProvidingProject()" v-else
/> icon="square"
<label class="text-sm mt-1"> class="mr-2 bg-white text-white h-5 w-5 px-0.5 py-0.5 rounded-sm"
{{ />
providerProjectId <label class="text-sm mt-1">
? "This was provided by " + providerProjectName {{
: "This was not provided by a project" giverDid
}} ? "This was provided by " + giverName
</label> : "No individual gave"
</div> }}
</label>
<fa
v-if="!giverDid || providedByProject"
icon="info-circle"
class="-mt-1 bg-white text-slate-500 h-5 w-5 px-0.5 py-0.5 rounded-sm"
@click="notifyUserOfGiver()"
/>
</div>
<div class="flex">
<input
v-if="providerProjectId && !providedByGiver"
type="checkbox"
class="h-6 w-6 mr-2"
v-model="providedByProject"
/>
<fa
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 mt-1">
{{
providerProjectId
? "This was provided by " + providerProjectName
: "This was not provided by a project"
}}
</label>
<fa
v-if="!providerProjectId || providedByGiver"
icon="info-circle"
class="-mt-1 bg-white text-slate-500 h-5 w-5 px-0.5 py-0.5 rounded-sm"
@click="notifyUserOfProvidingProject()"
/>
</div>
</div>
<div class="h-7 mt-4 flex"> <div class="flex-shrink flex justify-center items-center">
<input <fa icon="arrow-right" class="fa-fw h-7" />
v-if="fulfillsProjectId && !givenToRecipient" </div>
type="checkbox"
class="h-6 w-6 mr-2"
v-model="givenToProject"
/>
<fa
v-else
icon="square"
class="bg-slate-500 text-slate-500 h-5 w-5 px-0.5 py-0.5 mr-2 rounded"
@click="notifyUserFulfillsProject()"
/>
<label class="text-sm mt-1">
{{
fulfillsProjectId
? "This was given to " + fulfillsProjectName
: "No recipient project was chosen"
}}
</label>
</div>
<div class="h-7 mt-4 flex"> <!-- Third Column for Recipient -->
<input <div class="flex-grow border border-slate-400 p-2 rounded-md">
v-if="recipientDid && !givenToProject" <div class="flex">
type="checkbox" <input
class="h-6 w-6 mr-2" v-if="recipientDid && !givenToProject"
v-model="givenToRecipient" type="checkbox"
/> class="h-6 w-6 mr-2"
<fa v-model="givenToRecipient"
v-else />
icon="square" <fa
class="bg-slate-500 text-slate-500 h-5 w-5 px-0.5 py-0.5 mr-2 rounded" v-else
@click="notifyUserOfRecipient()" 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 mt-1"> />
{{ <label class="text-sm mt-1">
recipientDid {{
? "This was given to " + recipientName recipientDid
: "No recipient was chosen." ? "This was given to " + recipientName
}} : "No individual benefitted"
</label> }}
</label>
<fa
v-if="!recipientDid || givenToProject"
icon="info-circle"
class="-mt-1 bg-white text-slate-500 h-5 w-5 px-0.5 py-0.5 rounded-sm"
@click="notifyUserOfRecipient()"
/>
</div>
<div class="flex">
<input
v-if="fulfillsProjectId && !givenToRecipient"
type="checkbox"
class="h-6 w-6 mr-2"
v-model="givenToProject"
/>
<fa
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 mt-1">
{{
fulfillsProjectId
? "This was given to " + fulfillsProjectName
: "No project benefitted"
}}
</label>
<fa
v-if="!fulfillsProjectId || givenToRecipient"
icon="info-circle"
class="-mt-1 bg-white text-slate-500 h-5 w-5 px-0.5 py-0.5 rounded-sm"
@click="notifyUserFulfillsProject()"
/>
</div>
</div>
</div> </div>
<div class="mt-4 flex"> <div class="mt-8 flex">
<input type="checkbox" class="h-6 w-6 mr-2" v-model="isTrade" /> <input type="checkbox" class="h-6 w-6 mr-2" v-model="isTrade" />
<label class="text-sm mt-1">This was a trade (not a gift)</label> <label class="text-sm mt-1">This was a trade (not a gift)</label>
</div> </div>
@ -176,7 +230,7 @@
}" }"
class="text-blue-500" class="text-blue-500"
> >
Edit & Submit Raw Edit Raw Data
</router-link> </router-link>
</div> </div>
@ -247,7 +301,7 @@ export default class GiftedDetails extends Vue {
fulfillsProjectName = "a project"; fulfillsProjectName = "a project";
givenToProject = false; // basically static, based on input; if we allow changing then let's fix things (see below) givenToProject = false; // basically static, based on input; if we allow changing then let's fix things (see below)
givenToRecipient = false; // basically static, based on input; if we allow changing then let's fix things (see below) givenToRecipient = false; // basically static, based on input; if we allow changing then let's fix things (see below)
giverDid: string | undefined; giverDid = "";
giverName = ""; giverName = "";
hideBackButton = false; hideBackButton = false;
imageUrl = ""; imageUrl = "";
@ -602,77 +656,101 @@ export default class GiftedDetails extends Vue {
await this.recordGive(); await this.recordGive();
} }
notifyUserOfProvidingProject() { notifyUserOfGiver() {
// we're here because they clicked and either there is no provider project or there is a giver chosen if (!this.giverDid) {
if (!this.providerProjectId) {
this.$notify( this.$notify(
{ {
group: "alert", group: "alert",
type: "warning", type: "warning",
title: "Error", title: "Go To The Contacts Page",
text: "To select a project as a provider, you must open this page through a project.", text: "To assign a giver, you must open this page from a contact.",
}, },
3000, 3000,
); );
} else { } else {
// no providing project was chosen
this.$notify( this.$notify(
{ {
group: "alert", group: "alert",
type: "warning", type: "warning",
title: "Error", title: "Unavailable",
text: "You cannot select both a giving project and person.", text: "You cannot assign both a giver and a project.",
}, },
3000, 3000,
); );
} }
} }
notifyUserFulfillsProject() { notifyUserOfRecipient() {
// we're here because they clicked and either there is no fulfills project or there is a recipient chosen if (!this.recipientDid) {
if (!this.fulfillsProjectId) {
this.$notify( this.$notify(
{ {
group: "alert", group: "alert",
type: "warning", type: "warning",
title: "Error", title: "Go To The Contacts Page",
text: "To assign to a project, you must open this page through a project.", text: "To assign to a recipient, you must open this page from a contact.",
}, },
3000, 3000,
); );
} else { } else {
// no fulfills project was chosen // must be because givenToProject is true
this.$notify( this.$notify(
{ {
group: "alert", group: "alert",
type: "warning", type: "warning",
title: "Error", title: "Unavailable",
text: "You cannot assign both to a project and to a recipient.", text: "You cannot assign both to a recipient and to a project.",
}, },
3000, 3000,
); );
} }
} }
notifyUserOfRecipient() { notifyUserOfProvidingProject() {
if (!this.recipientDid) { // we're here because they clicked and either there is no provider project or there is a giver chosen
if (!this.providerProjectId) {
this.$notify( this.$notify(
{ {
group: "alert", group: "alert",
type: "warning", type: "warning",
title: "Error", title: "Go To The Project Page",
text: "To assign to a recipient, you must open this page from a contact.", text: "To select a project as a provider, you must open this page through a project.",
}, },
3000, 3000,
); );
} else { } else {
// must be because givenToProject is true // no providing project was chosen
this.$notify( this.$notify(
{ {
group: "alert", group: "alert",
type: "warning", type: "warning",
title: "Error", title: "Unavailable",
text: "You cannot assign both to a recipient and to a project.", text: "You cannot select both a giving project and person.",
},
3000,
);
}
}
notifyUserFulfillsProject() {
// we're here because they clicked and either there is no fulfills project or there is a recipient chosen
if (!this.fulfillsProjectId) {
this.$notify(
{
group: "alert",
type: "warning",
title: "Go To The Project Page",
text: "To assign to a project, you must open this page through a project.",
},
3000,
);
} else {
// no fulfills project was chosen
this.$notify(
{
group: "alert",
type: "warning",
title: "Unavailable",
text: "You cannot assign both to a project and to a recipient.",
}, },
3000, 3000,
); );
@ -688,6 +766,7 @@ export default class GiftedDetails extends Vue {
*/ */
public async recordGive() { public async recordGive() {
try { try {
const giverDid = this.providedByGiver ? this.giverDid : undefined;
const recipientDid = this.givenToRecipient const recipientDid = this.givenToRecipient
? this.recipientDid ? this.recipientDid
: undefined; : undefined;
@ -702,7 +781,7 @@ export default class GiftedDetails extends Vue {
this.apiServer, this.apiServer,
this.prevCredToEdit, this.prevCredToEdit,
this.activeDid, this.activeDid,
this.giverDid, giverDid,
recipientDid, recipientDid,
this.description, this.description,
parseFloat(this.amountInput), parseFloat(this.amountInput),
@ -718,7 +797,7 @@ export default class GiftedDetails extends Vue {
this.axios, this.axios,
this.apiServer, this.apiServer,
this.activeDid, this.activeDid,
this.giverDid, giverDid,
recipientDid, recipientDid,
this.description, this.description,
parseFloat(this.amountInput), parseFloat(this.amountInput),
@ -783,13 +862,14 @@ export default class GiftedDetails extends Vue {
} }
constructGiveParam() { constructGiveParam() {
const giverDid = this.providedByGiver ? this.giverDid : undefined;
const recipientDid = this.givenToRecipient ? this.recipientDid : undefined; const recipientDid = this.givenToRecipient ? this.recipientDid : undefined;
const fulfillsProjectId = this.givenToProject const fulfillsProjectId = this.givenToProject
? this.fulfillsProjectId ? this.fulfillsProjectId
: undefined; : undefined;
const giveClaim = hydrateGive( const giveClaim = hydrateGive(
this.prevCredToEdit?.claim as GiveVerifiableCredential, this.prevCredToEdit?.claim as GiveVerifiableCredential,
this.giverDid, giverDid,
recipientDid, recipientDid,
this.description, this.description,
parseFloat(this.amountInput), parseFloat(this.amountInput),

6
src/views/ProjectViewView.vue

@ -224,7 +224,7 @@
<button <button
data-testId="offerButton" data-testId="offerButton"
@click="openOfferDialog()" @click="openOfferDialog()"
class="block w-full bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white rounded-md" class="block w-full 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-1 rounded-md"
> >
Offer to this (maybe with conditions)... Offer to this (maybe with conditions)...
</button> </button>
@ -305,7 +305,7 @@
<div class="text-center"> <div class="text-center">
<button <button
@click="openGiftDialogToProject()" @click="openGiftDialogToProject()"
class="block w-full bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white rounded-md" class="block w-full 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-1rounded-md"
> >
Given To This... Given To This...
</button> </button>
@ -392,7 +392,7 @@
<div class="text-center"> <div class="text-center">
<button <button
@click="openGiftDialogFromProject()" @click="openGiftDialogFromProject()"
class="block w-full bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white rounded-md" class="block w-full 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-1 rounded-md"
> >
Given By This... Given By This...
</button> </button>

4
test-playwright/35-record-gift-from-image-share.spec.ts

@ -27,6 +27,10 @@ test('Record item given from image-share', async ({ page }) => {
await page.getByPlaceholder('What was received').fill(finalTitle); await page.getByPlaceholder('What was received').fill(finalTitle);
await page.getByRole('spinbutton').fill('2'); await page.getByRole('spinbutton').fill('2');
await page.getByRole('button', { name: 'Sign & Send' }).click(); await page.getByRole('button', { name: 'Sign & Send' }).click();
// we end up on a page with the onboarding info
await page.getByTestId('closeOnboardingAndFinish').click();
await expect(page.getByText('That gift was recorded.')).toBeVisible(); await expect(page.getByText('That gift was recorded.')).toBeVisible();
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert

Loading…
Cancel
Save