Browse Source

Subject: workflow for saving of project

* Changed from passing parameters since this isn't supported anymore by Vue
* Added new AppStore values for a projectId which are accessible in the ProjectView View
kb/add-usage-guide
Matthew Aaron Raymer 2 years ago
parent
commit
1c0881fe14
  1. 8
      src/store/app.ts
  2. 3
      src/views/NewEditProjectView.vue
  3. 2
      src/views/ProjectViewView.vue

8
src/store/app.ts

@ -12,9 +12,14 @@ export const useAppStore = defineStore({
typeof localStorage["lastView"] == "undefined" typeof localStorage["lastView"] == "undefined"
? "/start" ? "/start"
: localStorage["lastView"], : localStorage["lastView"],
_projectId:
typeof localStorage.getItem("projectId") === "undefined"
? ""
: localStorage.getItem("projectId"),
}), }),
getters: { getters: {
condition: (state) => state._condition, condition: (state) => state._condition,
projectId: (state): string => state._projectId as string,
}, },
actions: { actions: {
reset() { reset() {
@ -23,5 +28,8 @@ export const useAppStore = defineStore({
setCondition(newCondition: string) { setCondition(newCondition: string) {
localStorage.setItem("condition", newCondition); localStorage.setItem("condition", newCondition);
}, },
setProjectId(newProjectId: string) {
localStorage.setItem("projectId", newProjectId);
},
}, },
}); });

3
src/views/NewEditProjectView.vue

@ -76,6 +76,7 @@ import { db } from "../db";
import { accessToken, SimpleSigner } from "@/libs/crypto"; import { accessToken, SimpleSigner } from "@/libs/crypto";
import * as didJwt from "did-jwt"; import * as didJwt from "did-jwt";
import { IIdentifier } from "@veramo/core"; import { IIdentifier } from "@veramo/core";
import { useAppStore } from "@/store/app";
@Options({ @Options({
components: {}, components: {},
@ -133,9 +134,9 @@ export default class NewEditProjectView extends Vue {
try { try {
const resp = await this.axios.post(url, payload, { headers }); const resp = await this.axios.post(url, payload, { headers });
console.log(resp.status, resp.data); console.log(resp.status, resp.data);
useAppStore().setProjectId(resp.data);
const route = { const route = {
name: "project", name: "project",
params: { projectId: resp.data },
}; };
console.log(route); console.log(route);
this.$router.push(route); this.$router.push(route);

2
src/views/ProjectViewView.vue

@ -126,6 +126,7 @@
<script lang="ts"> <script lang="ts">
import { Options, Vue } from "vue-class-component"; import { Options, Vue } from "vue-class-component";
import { useAppStore } from "@/store/app";
@Options({ @Options({
components: {}, components: {},
@ -133,6 +134,7 @@ import { Options, Vue } from "vue-class-component";
export default class ProjectViewView extends Vue { export default class ProjectViewView extends Vue {
projectId = ""; projectId = "";
created(): void { created(): void {
this.projectId = useAppStore().projectId;
console.log(this.projectId); console.log(this.projectId);
} }
} }

Loading…
Cancel
Save