Add edit project flow in anticipation of API method. Ugly Edit button needs to be replaced.
This commit is contained in:
@@ -67,6 +67,48 @@ import { useAppStore } from "@/store/app";
|
|||||||
export default class NewEditProjectView extends Vue {
|
export default class NewEditProjectView extends Vue {
|
||||||
projectName = "";
|
projectName = "";
|
||||||
description = "";
|
description = "";
|
||||||
|
projectId =
|
||||||
|
localStorage.getItem("projectId") === null
|
||||||
|
? ""
|
||||||
|
: localStorage.getItem("projectId");
|
||||||
|
|
||||||
|
async created() {
|
||||||
|
if (this.projectId === "") {
|
||||||
|
console.log("This is a new project");
|
||||||
|
} else {
|
||||||
|
await db.open();
|
||||||
|
const num_accounts = await db.accounts.count();
|
||||||
|
if (num_accounts === 0) {
|
||||||
|
console.log("Problem! Should have a profile!");
|
||||||
|
} else {
|
||||||
|
const accounts = await db.accounts.toArray();
|
||||||
|
const identity = JSON.parse(accounts[0].identity);
|
||||||
|
this.LoadProject(identity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async LoadProject(identity: IIdentifier) {
|
||||||
|
const endorserApiServer = AppString.DEFAULT_ENDORSER_API_SERVER;
|
||||||
|
const url = endorserApiServer + "/api/claim/" + this.projectId;
|
||||||
|
const token = await accessToken(identity);
|
||||||
|
const headers = {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Authorization: "Bearer " + token,
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const resp = await this.axios.get(url, { headers });
|
||||||
|
console.log(resp.status, resp.data);
|
||||||
|
if (resp.status === 200) {
|
||||||
|
const claim = resp.data.claim;
|
||||||
|
this.projectName = claim.name;
|
||||||
|
this.description = claim.description;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async SaveProject(identity: IIdentifier) {
|
private async SaveProject(identity: IIdentifier) {
|
||||||
const address = identity.did;
|
const address = identity.did;
|
||||||
|
|||||||
@@ -93,6 +93,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<button
|
||||||
|
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()"
|
||||||
|
>
|
||||||
|
Edit
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Commit -->
|
<!-- Commit -->
|
||||||
@@ -155,6 +162,15 @@ export default class ProjectViewView extends Vue {
|
|||||||
? ""
|
? ""
|
||||||
: localStorage.getItem("projectId");
|
: localStorage.getItem("projectId");
|
||||||
|
|
||||||
|
onEditClick() {
|
||||||
|
localStorage.setItem("projectId", this.projectId as string);
|
||||||
|
const route = {
|
||||||
|
name: "new-edit-project",
|
||||||
|
};
|
||||||
|
console.log(route);
|
||||||
|
this.$router.push(route);
|
||||||
|
}
|
||||||
|
|
||||||
expandText() {
|
expandText() {
|
||||||
this.expanded = true;
|
this.expanded = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ export default class ProjectsView extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onClickNewProject(): void {
|
onClickNewProject(): void {
|
||||||
|
localStorage.removeItem("projectId");
|
||||||
const route = {
|
const route = {
|
||||||
name: "new-edit-project",
|
name: "new-edit-project",
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user