Browse Source

allow an agent to edit a project

starred-projects
Trent Larson 10 months ago
parent
commit
fa72d38d18
  1. 2
      package.json
  2. 4
      project.task.yaml
  3. 3
      src/libs/endorserServer.ts
  4. 7
      src/views/HelpView.vue
  5. 2
      src/views/ImportAccountView.vue
  6. 55
      src/views/NewEditProjectView.vue
  7. 4
      src/views/ProjectViewView.vue

2
package.json

@ -1,6 +1,6 @@
{
"name": "TimeSafari_Test",
"version": "0.2.7",
"version": "0.2.8-beta",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",

4
project.task.yaml

@ -1,7 +1,9 @@
tasks:
- allow agent to edit a project
- choose an agent - make a contact chooser
- remove fullIri
- eliminate setTimeout calls (like we did in NewEditProjectView.vue)
- make set-name request yellow
- make the "give" on contact screen work like other give (allowing donation vs current blank)
- create an identifier automatically, with a message that they can import a different one

3
src/libs/endorserServer.ts

@ -116,7 +116,8 @@ export interface PlanVerifiableCredential {
"@context": "https://schema.org";
"@type": "PlanAction";
name: string;
description: string;
agent?: { identifier: string };
description?: string;
identifier?: string;
location?: {
geo: { "@type": "GeoCoordinates"; latitude: number; longitude: number };

7
src/views/HelpView.vue

@ -232,6 +232,13 @@
>
</p>
<h2 class="text-xl font-semibold">
How do I get higher limits?
</h2>
<p>
Let's talk. Contact us (below).
</p>
<h2 class="text-xl font-semibold">
How do I access even more functionality?
</h2>

2
src/views/ImportAccountView.vue

@ -25,7 +25,7 @@
class="block w-full rounded border border-slate-400 mb-4 px-3 py-2"
v-model="mnemonic"
/>
{{ mnemonic }}
<h3
class="text-sm uppercase font-semibold mb-3"
@click="showAdvanced = !showAdvanced"

55
src/views/NewEditProjectView.vue

@ -29,6 +29,23 @@
v-model="fullClaim.name"
/>
<input
type="text"
placeholder="Other Authorized Representative"
class="block w-full rounded border border-slate-400 px-3 py-2"
v-model="agentDid"
/>
<div class="mb-4">
<p v-if="activeDid != projectIssuerDid && agentDid != projectIssuerDid">
<span class="text-red-500">Beware!</span>
If you save this, the original project owner will no longer be able to
edit it.
<button @click="agentDid = projectIssuerDid" class="text-blue-500">
Click here to make the original owner an authorized representative.
</button>
</p>
</div>
<textarea
placeholder="Description"
class="block w-full rounded border border-slate-400 mb-4 px-3 py-2"
@ -57,8 +74,8 @@
</div>
<div v-if="includeLocation" style="height: 600px; width: 800px">
<div class="px-2 py-2">
For your security, we recommend you choose a location nearby but not
exactly at the place.
For your security, choose a location nearby but not exactly at the
place.
</div>
<l-map
@ -98,7 +115,7 @@
<span :class="{ hidden: isHiddenSpinner }">
<!-- icon no worky? -->
<i class="fa-solid fa-spinner fa-spin-pulse"></i>
Saving&hellip;</span
Saving...</span
>
</button>
<button
@ -141,6 +158,7 @@ export default class NewEditProjectView extends Vue {
$notify!: (notification: Notification, timeout?: number) => void;
activeDid = "";
agentDid = "";
apiServer = "";
errorMessage = "";
fullClaim: PlanVerifiableCredential = {
@ -153,6 +171,7 @@ export default class NewEditProjectView extends Vue {
latitude = 0;
longitude = 0;
numAccounts = 0;
projectIssuerDid = "";
zoom = 2;
async beforeCreate() {
@ -224,12 +243,16 @@ export default class NewEditProjectView extends Vue {
try {
const resp = await this.axios.get(url, { headers });
if (resp.status === 200) {
this.projectIssuerDid = resp.data.issuer;
this.fullClaim = resp.data.claim;
if (this.fullClaim?.location) {
this.includeLocation = true;
this.latitude = this.fullClaim.location.geo.latitude;
this.longitude = this.fullClaim.location.geo.longitude;
}
if (this.fullClaim?.agent?.identifier) {
this.agentDid = this.fullClaim.agent.identifier;
}
}
} catch (error) {
console.error("Got error retrieving that project", error);
@ -242,6 +265,11 @@ export default class NewEditProjectView extends Vue {
if (this.projectId) {
vcClaim.identifier = this.projectId;
}
if (this.agentDid) {
vcClaim.agent = {
identifier: this.agentDid,
};
}
if (this.includeLocation) {
vcClaim.location = {
geo: {
@ -290,18 +318,15 @@ export default class NewEditProjectView extends Vue {
// handleId is new in server v release-1.6.0; remove fullIri when that
// version shows up here: https://api.endorser.ch/api-docs/
useAppStore().setProjectId(
resp.data.success.handleId || resp.data.success.fullIri,
);
setTimeout(
function (that: NewEditProjectView) {
that.$router.push({ name: "project" });
},
2000,
this,
);
useAppStore()
.setProjectId(
resp.data.success.handleId || resp.data.success.fullIri,
)
.then(() => {
this.$router.push({ name: "project" });
});
} else {
console.log(
console.error(
"Got unexpected 'data' inside response from server",
resp,
);
@ -321,7 +346,7 @@ export default class NewEditProjectView extends Vue {
error?: { message?: string };
}>;
if (serverError) {
console.log("Got error from server", serverError);
console.error("Got error from server", serverError);
if (Object.prototype.hasOwnProperty.call(serverError, "message")) {
userMessage = serverError.response?.data?.error?.message || ""; // This is info for the user.
this.$notify(

4
src/views/ProjectViewView.vue

@ -82,7 +82,7 @@
</div>
</div>
<button
v-if="issuer == activeDid"
v-if="activeDid === issuer || activeDid === agentDid"
type="button"
class="block w-full text-center text-md uppercase bg-slate-500 text-white px-1.5 py-2 rounded-md"
@click="onEditClick()"
@ -318,6 +318,7 @@ export default class ProjectViewView extends Vue {
$notify!: (notification: Notification, timeout?: number) => void;
activeDid = "";
agentDid = "";
allMyDids: Array<string> = [];
allContacts: Array<Contact> = [];
apiServer = "";
@ -425,6 +426,7 @@ export default class ProjectViewView extends Vue {
const now = moment.now();
this.timeSince = moment.utc(now).to(eventDate);
}
this.agentDid = resp.data.claim?.agent?.identifier;
this.issuer = resp.data.issuer;
this.name = resp.data.claim?.name || "(no name)";
this.description = resp.data.claim?.description || "(no description)";

Loading…
Cancel
Save