Add Getter for on/offbudget accounts and remove from backend
This commit is contained in:
parent
27298a9860
commit
0e3ece9830
@ -9,10 +9,8 @@ import (
|
||||
)
|
||||
|
||||
type AlwaysNeededData struct {
|
||||
Budget postgres.Budget
|
||||
Accounts []postgres.GetAccountsWithBalanceRow
|
||||
OnBudgetAccounts []postgres.GetAccountsWithBalanceRow
|
||||
OffBudgetAccounts []postgres.GetAccountsWithBalanceRow
|
||||
Budget postgres.Budget
|
||||
Accounts []postgres.GetAccountsWithBalanceRow
|
||||
}
|
||||
|
||||
func (h *Handler) getImportantData(c *gin.Context) {
|
||||
@ -36,20 +34,9 @@ func (h *Handler) getImportantData(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
var onBudgetAccounts, offBudgetAccounts []postgres.GetAccountsWithBalanceRow
|
||||
for _, account := range accounts {
|
||||
if account.OnBudget {
|
||||
onBudgetAccounts = append(onBudgetAccounts, account)
|
||||
} else {
|
||||
offBudgetAccounts = append(offBudgetAccounts, account)
|
||||
}
|
||||
}
|
||||
|
||||
base := AlwaysNeededData{
|
||||
Accounts: accounts,
|
||||
OnBudgetAccounts: onBudgetAccounts,
|
||||
OffBudgetAccounts: offBudgetAccounts,
|
||||
Budget: budget,
|
||||
Accounts: accounts,
|
||||
Budget: budget,
|
||||
}
|
||||
|
||||
c.Set("data", base)
|
||||
|
@ -8,6 +8,51 @@ export default {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<h1>
|
||||
<a href="/dashboard">⌂</a>
|
||||
{{$store.getters.CurrentBudget.Name}}
|
||||
</h1>
|
||||
<ul>
|
||||
<li><a href="/budget/{{$store.getters.CurrentBudget.ID}}">Budget</a></li>
|
||||
<li>Reports (Coming Soon)</li>
|
||||
<li><a href="/budget/{{$store.getters.CurrentBudget.ID}}/all-accounts">All Accounts</a></li>
|
||||
<li>
|
||||
On-Budget Accounts
|
||||
<ul v-for="account in $store.getters.OnBudgetAccounts" class="two-valued">
|
||||
<li>
|
||||
<a href="/budget/{{$store.getters.CurrentBudget.ID}}/account/{{.ID}}">{{account.Name}}</a>
|
||||
<span>{{account.Balance.Int / 100}}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
Off-Budget Accounts
|
||||
<ul v-for="account in $store.getters.OffBudgetAccounts" class="two-valued">
|
||||
<li>
|
||||
<a href="/budget/{{$store.getters.CurrentBudget.ID}}/account/{{.ID}}">{{account.Name}}</a>
|
||||
<span>{{account.Balance.Int / 100}}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
Closed Accounts
|
||||
</li>
|
||||
<li>
|
||||
<a href="/budget/{{$.Budget.ID}}/accounts">Edit accounts</a>
|
||||
</li>
|
||||
<li>
|
||||
+ Add Account
|
||||
</li>
|
||||
<li>
|
||||
<a href="/budget/{{.Budget.ID}}/settings">Budget-Settings</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/admin">Admin</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/api/v1/user/logout">Logout</a>
|
||||
</li>
|
||||
</ul>
|
||||
<h1>Budget</h1>
|
||||
<p>{{ $route.params.budgetid }}</p>
|
||||
<p v-for="account in $store.getters.Accounts">{{ account.Name }} / {{ account.Balance.Int / 100 }}</p>
|
||||
|
@ -15,7 +15,13 @@ const budget = {
|
||||
getters: {
|
||||
Accounts(state) {
|
||||
return state.Accounts || [];
|
||||
}
|
||||
},
|
||||
OnBudgetAccounts(state) {
|
||||
return (state.Accounts || []).filter(x => x.OnBudget);
|
||||
},
|
||||
OffBudgetAccounts(state) {
|
||||
return (state.Accounts || []).filter(x => !x.OnBudget);
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
fetchBudget ({state, commit, rootState}, budgetid) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user