Use same template for account and all-accounts
This commit is contained in:
parent
4cd81592e4
commit
e0eeaadc60
@ -9,12 +9,13 @@ import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type BudgetData struct {
|
||||
type AllAccountsData struct {
|
||||
AlwaysNeededData
|
||||
Account *postgres.Account
|
||||
Transactions []postgres.GetTransactionsForBudgetRow
|
||||
}
|
||||
|
||||
func (h *Handler) budget(c *gin.Context) {
|
||||
func (h *Handler) allAccounts(c *gin.Context) {
|
||||
budgetID := c.Param("budgetid")
|
||||
budgetUUID, err := uuid.Parse(budgetID)
|
||||
if err != nil {
|
||||
@ -28,12 +29,15 @@ func (h *Handler) budget(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
d := BudgetData{
|
||||
d := AllAccountsData{
|
||||
c.MustGet("data").(AlwaysNeededData),
|
||||
&postgres.Account{
|
||||
Name: "All accounts",
|
||||
},
|
||||
transactions,
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "budget.html", d)
|
||||
c.HTML(http.StatusOK, "account.html", d)
|
||||
}
|
||||
|
||||
func (h *Handler) newBudget(c *gin.Context) {
|
||||
|
@ -58,7 +58,7 @@ func (h *Handler) Serve() {
|
||||
withBudget.Use(h.getImportantData)
|
||||
withBudget.GET("/budget/:budgetid", h.budgeting)
|
||||
withBudget.GET("/budget/:budgetid/:year/:month", h.budgeting)
|
||||
withBudget.GET("/budget/:budgetid/all-accounts", h.budget)
|
||||
withBudget.GET("/budget/:budgetid/all-accounts", h.allAccounts)
|
||||
withBudget.GET("/budget/:budgetid/accounts", h.accounts)
|
||||
withBudget.GET("/budget/:budgetid/account/:accountid", h.account)
|
||||
withBudget.GET("/budget/:budgetid/clear", h.clearBudget)
|
||||
|
@ -1,31 +0,0 @@
|
||||
{{template "base" .}}
|
||||
|
||||
{{define "title"}}Budget{{end}}
|
||||
|
||||
{{define "new"}}
|
||||
{{template "transaction-new"}}
|
||||
{{end}}
|
||||
|
||||
{{define "main"}}
|
||||
<div class="budget-item">
|
||||
<a href="#newtransactionmodal" data-toggle="modal" data-target="#newtransactionmodal">New Transaction</a>
|
||||
<span class="time"></span>
|
||||
</div>
|
||||
<table class="container col-lg-12" id="content">
|
||||
{{range .Transactions}}
|
||||
<tr>
|
||||
<td>{{.Date.Format "02.01.2006"}}</td>
|
||||
<td>
|
||||
{{.Account}}
|
||||
</td>
|
||||
<td>
|
||||
{{.Payee}}
|
||||
</td>
|
||||
<td>
|
||||
<a href="transaction/{{.ID}}">{{.Memo}}</a>
|
||||
</td>
|
||||
{{template "amount-cell" .Amount}}
|
||||
</tr>
|
||||
{{end}}
|
||||
</table>
|
||||
{{end}}
|
Loading…
x
Reference in New Issue
Block a user