Implement dummy Budget-Settings and extract setTitle mutation

This commit is contained in:
Jan Bader 2022-01-25 20:40:00 +00:00
parent 74c4c7cb02
commit ffed94f586
5 changed files with 9 additions and 13 deletions

View File

@ -1,9 +1,6 @@
<script> <script>
// This starter template is using Vue 3 <script setup> SFCs
import { LOGOUT } from "./store/mutation-types"; import { LOGOUT } from "./store/mutation-types";
// Check out https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup
export default { export default {
data() { data() {
return { return {

View File

@ -1,12 +1,7 @@
<script> <script>
import { LOGIN_SUCCESS } from "../store/mutation-types"; import { LOGIN_SUCCESS, TITLE } from "../store/mutation-types";
export default { export default {
computed: {
dashboard () {
return this.$store.state;
}
},
data() { data() {
return { return {
error: [], error: [],
@ -18,7 +13,7 @@ export default {
} }
}, },
mounted () { mounted () {
this.$store.commit("setTitle", "Login"); this.$store.commit(TITLE, "Login");
}, },
methods: { methods: {
formSubmit (e) { formSubmit (e) {

View File

@ -4,6 +4,7 @@ import Dashboard from '../pages/Dashboard.vue';
import Login from '../pages/Login.vue'; import Login from '../pages/Login.vue';
import Register from '../pages/Register.vue'; import Register from '../pages/Register.vue';
import Account from '../pages/Account.vue'; import Account from '../pages/Account.vue';
import Settings from '../pages/Settings.vue';
const routes = [ const routes = [
{ path: '/', name: 'Index', component: Dashboard }, { path: '/', name: 'Index', component: Dashboard },
@ -11,6 +12,7 @@ const routes = [
{ path: '/login', name: 'Login', component: Login }, { path: '/login', name: 'Login', component: Login },
{ path: '/register', name: 'Register', component: Register }, { path: '/register', name: 'Register', component: Register },
{ path: '/budget/:budgetid', name: 'Budget', components: { default: Dashboard, sidebar: BudgetSidebar }, props: true }, { path: '/budget/:budgetid', name: 'Budget', components: { default: Dashboard, sidebar: BudgetSidebar }, props: true },
{ path: '/budget/:budgetid/Settings', name: 'Budget Settings', components: { default: Settings, sidebar: BudgetSidebar }, props: true },
{ path: '/budget/:budgetid/account/:accountid', name: 'Account', components: { default: Account, sidebar: BudgetSidebar }, props: true }, { path: '/budget/:budgetid/account/:accountid', name: 'Account', components: { default: Account, sidebar: BudgetSidebar }, props: true },
] ]

View File

@ -1,3 +1,5 @@
import { TITLE } from "../mutation-types";
const budget = { const budget = {
state () { state () {
return { return {
@ -62,7 +64,7 @@ const budget = {
continue continue
commit("setCurrentAccount", element); commit("setCurrentAccount", element);
commit("setTitle", element.Name); commit(TITLE, element.Name);
break break
} }
} }

View File

@ -1,7 +1,7 @@
import { createStore } from 'vuex' import { createStore } from 'vuex'
import dashboard from './dashboard/index' import dashboard from './dashboard/index'
import budget from './budget/index' import budget from './budget/index'
import { LOGIN_SUCCESS, LOGOUT } from './mutation-types' import { LOGIN_SUCCESS, LOGOUT, TITLE } from './mutation-types'
const store = createStore({ const store = createStore({
state () { state () {
@ -21,7 +21,7 @@ const store = createStore({
); );
} }
}, },
setTitle (state, title) { [TITLE](state, title) {
document.title = "Budgeteer - " + title; document.title = "Budgeteer - " + title;
}, },
[LOGIN_SUCCESS](state, session) { [LOGIN_SUCCESS](state, session) {