Browse Source

allow editing of an offer

pull/123/head
Trent Larson 3 months ago
parent
commit
a9b12f4d7c
  1. 45
      src/components/OfferDialog.vue
  2. 23
      src/libs/endorserServer.ts
  3. 7
      src/router/index.ts
  4. 56
      src/views/ClaimView.vue
  5. 9
      src/views/ContactsView.vue
  6. 6
      src/views/GiftedDetailsView.vue
  7. 2
      src/views/NewEditProjectView.vue
  8. 168
      src/views/OfferDetailsView.vue
  9. 6
      src/views/ProjectViewView.vue

45
src/components/OfferDialog.vue

@ -36,18 +36,27 @@
<fa icon="chevron-right" /> <fa icon="chevron-right" />
</div> </div>
</div> </div>
<div class="flex flex-row mt-2"> <div class="mt-4 flex justify-center">
<span <span>
class="rounded-l border border-r-0 border-slate-400 bg-slate-200 text-center px-2 py-2" <router-link
> :to="{
Expiration name: 'offer-details',
query: {
amountInput,
description,
offererDid: activeDid,
projectId,
projectName,
recipientDid,
recipientName,
unitCode: amountUnitCode,
},
}"
class="text-blue-500"
>
Conditions, expiration...
</router-link>
</span> </span>
<input
type="text"
class="w-full border border-slate-400 px-2 py-2 rounded-r"
:placeholder="datePlaceholder()"
v-model="expirationDateInput"
/>
</div> </div>
<p class="text-center mt-6 mb-2 italic"> <p class="text-center mt-6 mb-2 italic">
Sign & Send to publish to the world Sign & Send to publish to the world
@ -71,7 +80,6 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { DateTime } from "luxon";
import { Vue, Component, Prop } from "vue-facing-decorator"; import { Vue, Component, Prop } from "vue-facing-decorator";
import { NotificationIface } from "@/constants/app"; import { NotificationIface } from "@/constants/app";
@ -84,7 +92,8 @@ import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings";
export default class OfferDialog extends Vue { export default class OfferDialog extends Vue {
$notify!: (notification: NotificationIface, timeout?: number) => void; $notify!: (notification: NotificationIface, timeout?: number) => void;
@Prop projectId? = ""; @Prop projectId?;
@Prop projectName?;
activeDid = ""; activeDid = "";
apiServer = ""; apiServer = "";
@ -94,13 +103,15 @@ export default class OfferDialog extends Vue {
description = ""; description = "";
expirationDateInput = ""; expirationDateInput = "";
recipientDid? = ""; recipientDid? = "";
recipientName? = "";
visible = false; visible = false;
libsUtil = libsUtil; libsUtil = libsUtil;
async open(recipientDid?: string) { async open(recipientDid?: string, recipientName?: string) {
try { try {
this.recipientDid = recipientDid; this.recipientDid = recipientDid;
this.recipientName = recipientName;
await db.open(); await db.open();
const settings = (await db.settings.get(MASTER_SETTINGS_KEY)) as Settings; const settings = (await db.settings.get(MASTER_SETTINGS_KEY)) as Settings;
@ -146,12 +157,6 @@ export default class OfferDialog extends Vue {
)}`; )}`;
} }
datePlaceholder() {
return (
"Date, eg. " + DateTime.now().plus({ month: 1 }).toISO().slice(0, 10)
);
}
cancel() { cancel() {
this.close(); this.close();
this.eraseValues(); this.eraseValues();

23
src/libs/endorserServer.ts

@ -62,6 +62,7 @@ export interface GenericCredWrapper<T extends GenericVerifiableCredential> {
id: string; id: string;
issuedAt: string; issuedAt: string;
issuer: string; issuer: string;
publicUrls?: Record<string, string>; // only for IDs that want to be public
} }
export const BLANK_GENERIC_SERVER_RECORD: GenericCredWrapper<GenericVerifiableCredential> = export const BLANK_GENERIC_SERVER_RECORD: GenericCredWrapper<GenericVerifiableCredential> =
{ {
@ -734,10 +735,10 @@ export function hydrateOffer(
vcClaimOrig?: OfferVerifiableCredential, vcClaimOrig?: OfferVerifiableCredential,
fromDid?: string, fromDid?: string,
toDid?: string, toDid?: string,
conditionDescription?: string, itemDescription?: string,
amount?: number, amount?: number,
unitCode?: string, unitCode?: string,
offeringDescription?: string, conditionDescription?: string,
fulfillsProjectHandleId?: string, fulfillsProjectHandleId?: string,
validThrough?: string, validThrough?: string,
lastClaimId?: string, lastClaimId?: string,
@ -766,9 +767,9 @@ export function hydrateOffer(
? { amountOfThisGood: amount, unitCode: unitCode || "HUR" } ? { amountOfThisGood: amount, unitCode: unitCode || "HUR" }
: undefined; : undefined;
if (offeringDescription || fulfillsProjectHandleId) { if (itemDescription || fulfillsProjectHandleId) {
vcClaim.itemOffered = vcClaim.itemOffered || {}; vcClaim.itemOffered = vcClaim.itemOffered || {};
vcClaim.itemOffered.description = offeringDescription || undefined; vcClaim.itemOffered.description = itemDescription || undefined;
if (fulfillsProjectHandleId) { if (fulfillsProjectHandleId) {
vcClaim.itemOffered.isPartOf = { vcClaim.itemOffered.isPartOf = {
"@type": "PlanAction", "@type": "PlanAction",
@ -794,9 +795,10 @@ export async function createAndSubmitOffer(
axios: Axios, axios: Axios,
apiServer: string, apiServer: string,
issuerDid: string, issuerDid: string,
description?: string, itemDescription: string,
amount?: number, amount?: number,
unitCode?: string, unitCode?: string,
conditionDescription?: string,
validThrough?: string, validThrough?: string,
recipientDid?: string, recipientDid?: string,
fulfillsProjectHandleId?: string, fulfillsProjectHandleId?: string,
@ -805,10 +807,10 @@ export async function createAndSubmitOffer(
undefined, undefined,
issuerDid, issuerDid,
recipientDid, recipientDid,
description, itemDescription,
amount, amount,
unitCode, unitCode,
description, conditionDescription,
fulfillsProjectHandleId, fulfillsProjectHandleId,
validThrough, validThrough,
undefined, undefined,
@ -826,9 +828,10 @@ export async function editAndSubmitOffer(
apiServer: string, apiServer: string,
fullClaim: GenericCredWrapper<OfferVerifiableCredential>, fullClaim: GenericCredWrapper<OfferVerifiableCredential>,
issuerDid: string, issuerDid: string,
description?: string, itemDescription: string,
amount?: number, amount?: number,
unitCode?: string, unitCode?: string,
conditionDescription?: string,
validThrough?: string, validThrough?: string,
recipientDid?: string, recipientDid?: string,
fulfillsProjectHandleId?: string, fulfillsProjectHandleId?: string,
@ -837,10 +840,10 @@ export async function editAndSubmitOffer(
fullClaim.claim, fullClaim.claim,
issuerDid, issuerDid,
recipientDid, recipientDid,
description, itemDescription,
amount, amount,
unitCode, unitCode,
description, conditionDescription,
fulfillsProjectHandleId, fulfillsProjectHandleId,
validThrough, validThrough,
fullClaim.id, fullClaim.id,

7
src/router/index.ts

@ -91,7 +91,7 @@ const routes: Array<RouteRecordRaw> = [
{ {
path: "/gifted-details", path: "/gifted-details",
name: "gifted-details", name: "gifted-details",
component: () => import("../views/GiftedDetails.vue"), component: () => import("@/views/GiftedDetailsView.vue"),
}, },
{ {
path: "/help", path: "/help",
@ -143,6 +143,11 @@ const routes: Array<RouteRecordRaw> = [
name: "new-identifier", name: "new-identifier",
component: () => import("../views/NewIdentifierView.vue"), component: () => import("../views/NewIdentifierView.vue"),
}, },
{
path: "/offer-details/:id?",
name: "offer-details",
component: () => import("../views/OfferDetailsView.vue"),
},
{ {
path: "/project/:id?", path: "/project/:id?",
name: "project", name: "project",

56
src/views/ClaimView.vue

@ -24,8 +24,9 @@
{{ capitalizeAndInsertSpacesBeforeCaps(veriClaim.claimType) }} {{ capitalizeAndInsertSpacesBeforeCaps(veriClaim.claimType) }}
<button <button
v-if=" v-if="
veriClaim.claimType === 'GiveAction' && ['GiveAction', 'Offer'].includes(
veriClaim.issuer === activeDid veriClaim.claimType as string,
) && veriClaim.issuer === activeDid
" "
@click="onClickEditClaim" @click="onClickEditClaim"
title="Edit" title="Edit"
@ -402,7 +403,7 @@
<!-- Keep the dump contents directly between > and < to avoid weird spacing. --> <!-- Keep the dump contents directly between > and < to avoid weird spacing. -->
<pre <pre
v-if="showVeriClaimDump" v-if="showVeriClaimDump"
class="text-sm overflow-x-scroll px-4 py-3 bg-slate-100 rounded-md" class="text-sm overflow-x-scroll bg-slate-100 px-4 py-3 rounded-md"
>{{ veriClaimDump }}</pre >{{ veriClaimDump }}</pre
> >
</div> </div>
@ -425,7 +426,10 @@
</button> </button>
</div> </div>
<div v-else> <div v-else>
<pre>{{ fullClaimDump }}</pre> <pre
class="text-sm overflow-x-scroll bg-slate-100 px-4 py-3 rounded-md"
>{{ fullClaimDump }}</pre
>
</div> </div>
<a <a
@ -843,15 +847,41 @@ export default class ClaimView extends Vue {
} }
onClickEditClaim() { onClickEditClaim() {
const route = { if (this.veriClaim.claimType === "GiveAction") {
name: "gifted-details", const route = {
query: { name: "gifted-details",
prevCredToEdit: JSON.stringify(this.veriClaim), query: {
destinationPathAfter: prevCredToEdit: JSON.stringify(this.veriClaim),
"/claim/" + encodeURIComponent(this.veriClaim.handleId), destinationPathAfter:
}, "/claim/" + encodeURIComponent(this.veriClaim.handleId),
}; },
(this.$router as Router).push(route); };
(this.$router as Router).push(route);
} else if (this.veriClaim.claimType === "Offer") {
const route = {
name: "offer-details",
query: {
prevCredToEdit: JSON.stringify(this.veriClaim),
destinationPathAfter:
"/claim/" + encodeURIComponent(this.veriClaim.handleId),
},
};
(this.$router as Router).push(route);
} else {
console.error(
"Unrecognized claim type for edit:",
this.veriClaim.claimType,
);
this.$notify(
{
group: "alert",
type: "danger",
title: "Error",
text: "This is an unrecognized claim type.",
},
3000,
);
}
} }
} }
</script> </script>

9
src/views/ContactsView.vue

@ -271,7 +271,7 @@
<button <button
class="text-sm 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-2 py-1.5 rounded-md border border-blue-400" class="text-sm 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-2 py-1.5 rounded-md border border-blue-400"
@click="openOfferDialog(contact.did)" @click="openOfferDialog(contact.did, contact.name)"
> >
Offer Offer
</button> </button>
@ -1131,8 +1131,11 @@ export default class ContactsView extends Vue {
); );
} }
openOfferDialog(recipientDid: string) { openOfferDialog(recipientDid: string, recipientName: string) {
(this.$refs.customOfferDialog as OfferDialog).open(recipientDid); (this.$refs.customOfferDialog as OfferDialog).open(
recipientDid,
recipientName,
);
} }
private async onClickCancelName() { private async onClickCancelName() {

6
src/views/GiftedDetails.vue → src/views/GiftedDetailsView.vue

@ -269,6 +269,7 @@ export default class GiftedDetails extends Vue {
this.hideBackButton = this.hideBackButton =
(this.$route as Router).query["hideBackButton"] === "true"; (this.$route as Router).query["hideBackButton"] === "true";
this.message = ((this.$route as Router).query["message"] as string) || ""; this.message = ((this.$route as Router).query["message"] as string) || "";
// find any offer ID // find any offer ID
const fulfills = this.prevCredToEdit?.claim?.fulfills; const fulfills = this.prevCredToEdit?.claim?.fulfills;
const fulfillsArray = Array.isArray(fulfills) const fulfillsArray = Array.isArray(fulfills)
@ -351,6 +352,7 @@ export default class GiftedDetails extends Vue {
); );
} }
} }
// these should be functions but something's wrong with the syntax in the <> conditional
this.givenToProject = !!this.projectId; this.givenToProject = !!this.projectId;
this.givenToRecipient = !this.givenToProject && !!this.recipientDid; this.givenToRecipient = !this.givenToProject && !!this.recipientDid;
@ -549,7 +551,7 @@ export default class GiftedDetails extends Vue {
group: "alert", group: "alert",
type: "warning", type: "warning",
title: "Error", title: "Error",
text: "To assign to a project, you must open this dialog through a project.", text: "To assign to a project, you must open this page through a project.",
}, },
3000, 3000,
); );
@ -574,7 +576,7 @@ export default class GiftedDetails extends Vue {
group: "alert", group: "alert",
type: "warning", type: "warning",
title: "Error", title: "Error",
text: "To assign to a recipient, you must open this dialog from a contact.", text: "To assign to a recipient, you must open this page from a contact.",
}, },
3000, 3000,
); );

2
src/views/NewEditProjectView.vue

@ -91,14 +91,12 @@
<div class="flex mb-4 columns-3 w-full"> <div class="flex mb-4 columns-3 w-full">
<input <input
v-model="startDateInput" v-model="startDateInput"
placeholder="Start Date"
type="date" type="date"
class="col-span-1 w-full rounded border border-slate-400 px-3 py-2" class="col-span-1 w-full rounded border border-slate-400 px-3 py-2"
/> />
<input <input
:disabled="!startDateInput" :disabled="!startDateInput"
v-model="startTimeInput" v-model="startTimeInput"
placeholder="Start Time"
type="time" type="time"
class="col-span-1 w-full rounded border border-slate-400 ml-2 px-3 py-2" class="col-span-1 w-full rounded border border-slate-400 ml-2 px-3 py-2"
/> />

168
src/views/OfferDetails.vue → src/views/OfferDetailsView.vue

@ -21,9 +21,8 @@
<h1 class="text-4xl text-center font-light px-4 mb-4">What Was Offered</h1> <h1 class="text-4xl text-center font-light px-4 mb-4">What Was Offered</h1>
<h1 class="text-xl font-bold text-center mb-4"> <h1 class="text-xl font-bold text-center mb-4">
<span>From {{ giverName }}</span>
<span> <span>
to Offer to
{{ {{
offeredToProject offeredToProject
? projectName ? projectName
@ -36,7 +35,7 @@
<textarea <textarea
class="block w-full rounded border border-slate-400 mb-2 px-3 py-2" class="block w-full rounded border border-slate-400 mb-2 px-3 py-2"
placeholder="What was offered" placeholder="What was offered"
v-model="description" v-model="itemDescription"
/> />
<div class="flex flex-row justify-center"> <div class="flex flex-row justify-center">
<span <span
@ -64,6 +63,32 @@
</div> </div>
</div> </div>
<div class="flex flex-row mt-2">
<span
class="rounded-l border border-r-0 border-slate-400 bg-slate-200 text-center px-2 py-2"
>
Conditions
</span>
<textarea
class="w-full border border-slate-400 px-3 py-2 rounded-r"
placeholder="Prerequisites, other people to include, etc."
v-model="conditionDescription"
/>
</div>
<div class="flex flex-row mt-2">
<span
class="rounded-l border border-r-0 border-slate-400 bg-slate-200 text-center px-2 py-2"
>
{{ validThroughDateInput ? "" : "No" }}&nbsp;Expiration
</span>
<input
v-model="validThroughDateInput"
type="date"
class="w-full rounded border border-slate-400 px-3 py-2 rounded-r"
/>
</div>
<div class="h-7 mt-4 flex"> <div class="h-7 mt-4 flex">
<input <input
v-if="projectId && !offeredToRecipient" v-if="projectId && !offeredToRecipient"
@ -131,6 +156,12 @@
/> />
</p> </p>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-2"> <div class="grid grid-cols-1 sm:grid-cols-2 gap-2">
<button
class="block w-full text-center text-lg font-bold uppercase 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-2 py-3 rounded-md"
@click="confirm"
>
Sign &amp; Send
</button>
<button <button
class="block w-full text-center text-md uppercase bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-1.5 py-2 rounded-md" class="block w-full text-center text-md uppercase bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-1.5 py-2 rounded-md"
@click="cancel" @click="cancel"
@ -142,6 +173,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { DateTime } from "luxon";
import { Component, Vue } from "vue-facing-decorator"; import { Component, Vue } from "vue-facing-decorator";
import { Router } from "vue-router"; import { Router } from "vue-router";
@ -168,21 +200,20 @@ import { Contact } from "@/db/tables/contacts";
TopMessage, TopMessage,
}, },
}) })
export default class OfferDetails extends Vue { export default class OfferDetailsView extends Vue {
$notify!: (notification: NotificationIface, timeout?: number) => void; $notify!: (notification: NotificationIface, timeout?: number) => void;
activeDid = ""; activeDid = "";
apiServer = ""; apiServer = "";
amountInput = "0"; amountInput = "0";
description = ""; conditionDescription = "";
itemDescription = "";
destinationPathAfter = ""; destinationPathAfter = "";
offeredToProject = false; offeredToProject = false;
offeredToRecipient = false; offeredToRecipient = false;
giverDid: string | undefined; offererDid: string | undefined;
giverName = "";
hideBackButton = false; hideBackButton = false;
isTrade = false;
message = ""; message = "";
offerId = ""; offerId = "";
prevCredToEdit?: GenericCredWrapper<OfferVerifiableCredential>; prevCredToEdit?: GenericCredWrapper<OfferVerifiableCredential>;
@ -191,7 +222,7 @@ export default class OfferDetails extends Vue {
recipientDid = ""; recipientDid = "";
recipientName = ""; recipientName = "";
unitCode = "HUR"; unitCode = "HUR";
validThroughDate = null; validThroughDateInput = "";
libsUtil = libsUtil; libsUtil = libsUtil;
@ -214,67 +245,54 @@ export default class OfferDetails extends Vue {
); );
} }
const prevAmount = this.prevCredToEdit?.claim?.object?.amountOfThisGood; const prevAmount =
this.prevCredToEdit?.claim?.includesObject?.amountOfThisGood;
this.amountInput = this.amountInput =
(this.$route as Router).query["amountInput"] || (this.$route as Router).query["amountInput"] ||
(prevAmount ? String(prevAmount) : "") || (prevAmount ? String(prevAmount) : "") ||
this.amountInput; this.amountInput;
this.description = this.unitCode = ((this.$route as Router).query["unitCode"] ||
this.prevCredToEdit?.claim?.includesObject?.unitCode ||
this.unitCode) as string;
this.conditionDescription =
this.prevCredToEdit?.claim?.description || this.conditionDescription;
this.itemDescription =
(this.$route as Router).query["description"] || (this.$route as Router).query["description"] ||
this.prevCredToEdit?.claim?.description || this.prevCredToEdit?.claim?.itemOffered?.description ||
this.description; this.itemDescription;
this.destinationPathAfter = (this.$route as Router).query[ this.destinationPathAfter = (this.$route as Router).query[
"destinationPathAfter" "destinationPathAfter"
]; ];
this.giverDid = ((this.$route as Router).query["giverDid"] || this.offererDid = ((this.$route as Router).query["offererDid"] ||
this.prevCredToEdit?.claim?.agent?.identifier || this.prevCredToEdit?.claim?.agent?.identifier ||
this.giverDid) as string; this.offererDid) as string;
this.giverName =
((this.$route as Router).query["giverName"] as string) || "";
this.hideBackButton = this.hideBackButton =
(this.$route as Router).query["hideBackButton"] === "true"; (this.$route as Router).query["hideBackButton"] === "true";
this.message = ((this.$route as Router).query["message"] as string) || ""; this.message = ((this.$route as Router).query["message"] as string) || "";
// find any offer ID
const fulfills = this.prevCredToEdit?.claim?.fulfills;
const fulfillsArray = Array.isArray(fulfills)
? fulfills
: fulfills
? [fulfills]
: [];
const offer = fulfillsArray.find((rec) => rec["@type"] === "Offer");
this.offerId = ((this.$route as Router).query["offerId"] ||
offer?.identifier ||
this.offerId) as string;
// find any project ID // find any project ID
const project = fulfillsArray.find((rec) => rec["@type"] === "PlanAction"); let project;
if (
this.prevCredToEdit?.claim?.itemOffered?.isPartOf["@type"] ===
"PlanAction"
) {
project = this.prevCredToEdit?.claim?.itemOffered?.isPartOf;
}
this.projectId = ((this.$route as Router).query["projectId"] || this.projectId = ((this.$route as Router).query["projectId"] ||
project?.identifier || project?.identifier ||
this.projectId) as string; this.projectId) as string;
this.projectName = ((this.$route as Router).query["projectName"] ||
project?.name ||
this.projectName) as string;
this.recipientDid = ((this.$route as Router).query["recipientDid"] || this.recipientDid = ((this.$route as Router).query["recipientDid"] ||
this.prevCredToEdit?.claim?.recipient?.identifier) as string; this.prevCredToEdit?.claim?.recipient?.identifier) as string;
this.recipientName = this.recipientName =
((this.$route as Router).query["recipientName"] as string) || ""; ((this.$route as Router).query["recipientName"] as string) || "";
this.unitCode = ((this.$route as Router).query["unitCode"] ||
this.prevCredToEdit?.claim?.object?.unitCode ||
this.unitCode) as string;
// this is an endpoint for sharing project info to highlight something given this.validThroughDateInput =
// https://developer.mozilla.org/en-US/docs/Web/Manifest/share_target this.prevCredToEdit?.claim?.validThrough || this.validThroughDateInput;
if ((this.$route as Router).query["shareTitle"]) {
this.description =
((this.$route as Router).query["shareTitle"] as string) +
(this.description ? "\n" + this.description : "");
}
if ((this.$route as Router).query["shareText"]) {
this.description =
(this.description ? this.description + "\n" : "") +
((this.$route as Router).query["shareText"] as string);
}
if ((this.$route as Router).query["shareUrl"]) {
this.imageUrl = (this.$route as Router).query["shareUrl"] as string;
}
try { try {
await db.open(); await db.open();
@ -284,32 +302,20 @@ export default class OfferDetails extends Vue {
let allContacts: Contact[] = []; let allContacts: Contact[] = [];
let allMyDids: string[] = []; let allMyDids: string[] = [];
if ( if (this.recipientDid && !this.recipientName) {
(this.giverDid && !this.giverName) ||
(this.recipientDid && !this.recipientName)
) {
allContacts = await db.contacts.toArray(); allContacts = await db.contacts.toArray();
await accountsDB.open(); await accountsDB.open();
const allAccounts = await accountsDB.accounts.toArray(); const allAccounts = await accountsDB.accounts.toArray();
allMyDids = allAccounts.map((acc) => acc.did); allMyDids = allAccounts.map((acc) => acc.did);
if (this.giverDid && !this.giverName) { this.recipientName = didInfo(
this.giverName = didInfo( this.recipientDid,
this.giverDid, this.activeDid,
this.activeDid, allMyDids,
allMyDids, allContacts,
allContacts, );
);
}
if (this.recipientDid && !this.recipientName) {
this.recipientName = didInfo(
this.recipientDid,
this.activeDid,
allMyDids,
allContacts,
);
}
} }
// these should be functions but something's wrong with the syntax in the <> conditional
this.offeredToProject = !!this.projectId; this.offeredToProject = !!this.projectId;
this.offeredToRecipient = !this.offeredToProject && !!this.recipientDid; this.offeredToRecipient = !this.offeredToProject && !!this.recipientDid;
@ -327,7 +333,7 @@ export default class OfferDetails extends Vue {
); );
} }
if (this.projectId) { if (this.projectId && !this.projectName) {
// console.log("Getting project name from cache", this.projectId); // console.log("Getting project name from cache", this.projectId);
const project = await getPlanFromCache( const project = await getPlanFromCache(
this.projectId, this.projectId,
@ -395,7 +401,7 @@ export default class OfferDetails extends Vue {
); );
return; return;
} }
if (!this.description && !parseFloat(this.amountInput)) { if (!this.itemDescription && !parseFloat(this.amountInput)) {
this.$notify( this.$notify(
{ {
group: "alert", group: "alert",
@ -431,7 +437,7 @@ export default class OfferDetails extends Vue {
group: "alert", group: "alert",
type: "warning", type: "warning",
title: "Error", title: "Error",
text: "To assign to a project, you must open this dialog through a project.", text: "To assign to a project, you must open this page through a project.",
}, },
3000, 3000,
); );
@ -456,7 +462,7 @@ export default class OfferDetails extends Vue {
group: "alert", group: "alert",
type: "warning", type: "warning",
title: "Error", title: "Error",
text: "To assign to a recipient, you must open this dialog from a contact.", text: "To assign to a recipient, you must open this page from a contact.",
}, },
3000, 3000,
); );
@ -476,7 +482,7 @@ export default class OfferDetails extends Vue {
/** /**
* *
* @param giverDid may be null * @param offererDid may be null
* @param description may be an empty string * @param description may be an empty string
* @param amountInput may be 0 * @param amountInput may be 0
* @param unitCode may be omitted, defaults to "HUR" * @param unitCode may be omitted, defaults to "HUR"
@ -495,10 +501,11 @@ export default class OfferDetails extends Vue {
this.apiServer, this.apiServer,
this.prevCredToEdit, this.prevCredToEdit,
this.activeDid, this.activeDid,
this.description, this.itemDescription,
parseFloat(this.amountInput), parseFloat(this.amountInput),
this.unitCode, this.unitCode,
this.validThroughDate, this.conditionDescription,
this.validThroughDateInput,
recipientDid, recipientDid,
projectId, projectId,
); );
@ -507,10 +514,11 @@ export default class OfferDetails extends Vue {
this.axios, this.axios,
this.apiServer, this.apiServer,
this.activeDid, this.activeDid,
this.description, this.itemDescription,
parseFloat(this.amountInput), parseFloat(this.amountInput),
this.unitCode, this.unitCode,
this.validThroughDate, this.conditionDescription,
this.validThroughDateInput,
recipientDid, recipientDid,
projectId, projectId,
); );
@ -534,7 +542,7 @@ export default class OfferDetails extends Vue {
group: "alert", group: "alert",
type: "success", type: "success",
title: "Success", title: "Success",
text: `That ${this.isTrade ? "trade" : "gift"} was recorded.`, text: `That offer was recorded.`,
}, },
5000, 5000,
); );
@ -573,12 +581,12 @@ export default class OfferDetails extends Vue {
this.prevCredToEdit?.claim as OfferVerifiableCredential, this.prevCredToEdit?.claim as OfferVerifiableCredential,
this.activeDid, this.activeDid,
recipientDid, recipientDid,
this.description, this.itemDescription,
parseFloat(this.amountInput), parseFloat(this.amountInput),
this.unitCode, this.unitCode,
"", this.conditionDescription,
projectId, projectId,
this.validThroughDate, this.validThroughDateInput,
this.prevCredToEdit?.id as string, this.prevCredToEdit?.id as string,
); );
const claimStr = JSON.stringify(giveClaim); const claimStr = JSON.stringify(giveClaim);

6
src/views/ProjectViewView.vue

@ -170,7 +170,11 @@
</button> </button>
</div> </div>
</div> </div>
<OfferDialog ref="customOfferDialog" :projectId="this.projectId" /> <OfferDialog
ref="customOfferDialog"
:projectId="this.projectId"
:projectName="this.name"
/>
<div v-if="activeDid && isRegistered"> <div v-if="activeDid && isRegistered">
<div class="text-center"> <div class="text-center">

Loading…
Cancel
Save