add settings table to store names (and other things soon)

This commit is contained in:
2023-03-18 19:56:57 -06:00
parent 315cdc0cf1
commit afc175e3e7
4 changed files with 77 additions and 35 deletions

View File

@@ -50,6 +50,8 @@
<script lang="ts">
import { Options, Vue } from "vue-class-component";
import { db } from "@/db";
import { MASTER_SETTINGS } from "@/db/tables";
@Options({
components: {},
@@ -64,13 +66,24 @@ export default class NewEditAccountView extends Vue {
? "--"
: localStorage.getItem("lastName");
// 'created' hook runs when the Vue instance is first created
async created() {
await db.open();
const settings = await db.settings.get(MASTER_SETTINGS);
if (settings) {
this.firstName = settings.firstName || "";
this.lastName = settings.lastName || "";
}
}
onClickSaveChanges() {
db.settings.update(MASTER_SETTINGS, {
firstName: this.firstName,
lastName: this.lastName,
});
localStorage.setItem("firstName", this.firstName as string);
localStorage.setItem("lastName", this.lastName as string);
const route = {
name: "account",
};
this.$router.push(route);
this.$router.push({ name: "account" });
}
onClickCancel() {