diff --git a/db/db.go b/db/db.go index f15ab05..d9de3b9 100644 --- a/db/db.go +++ b/db/db.go @@ -85,7 +85,7 @@ func GetUserAccounts(userID int) ([]types.Account, error) { user_accounts[1] = types.Account { Id: 2, DisplayName: sql.NullString { - String: "Svngs", + String: "BECU Credit Card", Valid: true, } , Description: sql.NullString { @@ -97,6 +97,27 @@ func GetUserAccounts(userID int) ([]types.Account, error) { return user_accounts, nil; } +func GetUserBuckets(userID int) ([]types.Bucket, error) { + bucket1 := types.Bucket{ + Id: 1, + DisplayCode: sql.NullString{String: "SVNG", Valid: true}, + DisplayName: sql.NullString{String: "Savings", Valid: true}, + Description: sql.NullString{String: "The Savings Bucket", Valid: true}, + } + + bucket2 := types.Bucket{ + Id: 2, + DisplayCode: sql.NullString{String: "SPND", Valid: true}, + DisplayName: sql.NullString{String: "Spending", Valid: true}, + Description: sql.NullString{String: "The Spending Bucket", Valid: true}, + } + + // Creating a slice of length two and populating it with the two structs + buckets := []types.Bucket{bucket1, bucket2} + + return buckets, nil; +} + func GetTransPaneEntries(userID int) ([]types.QuickTransactionType, error) { transaction_types := make([]types.QuickTransactionType, 1); @@ -106,3 +127,4 @@ func GetTransPaneEntries(userID int) ([]types.QuickTransactionType, error) { return transaction_types, nil; } + diff --git a/tests/testdb.go b/tests/testdb.go index c920c05..883a4d4 100644 --- a/tests/testdb.go +++ b/tests/testdb.go @@ -51,14 +51,14 @@ func Init_testdb(DB_TYPE string, DB_CONNECTION_STRING string) { init_sql := ` CREATE TABLE accounts ( acnt_id Integer PRIMARY KEY, - acnt_dsply_name varchar(50) NOT NULL, + acnt_display_name varchar(50) NOT NULL, acnt_description varchar(250) NULL ); CREATE TABLE buckets ( bkt_id Integer PRIMARY KEY, - bkt_dsply_code varchar(5) NOT NULL, - bkt_dsply_name varchar(50) NULL, + bkt_display_code varchar(5) NOT NULL, + bkt_display_name varchar(50) NULL, bkt_description varchar(250) NULL ); @@ -96,13 +96,13 @@ CREATE TABLE transaction_breakdown ( CREATE TABLE transaction_categories ( trns_ctgry_id Integer PRIMARY KEY, - trns_ctgry_dsply_code varchar(5) NOT NULL, - trns_ctgry_dsply_name varchar(50) NOT NULL, + trns_ctgry_display_code varchar(5) NOT NULL, + trns_ctgry_display_name varchar(50) NOT NULL, trns_ctgry_description varchar(250) NULL ); -INSERT INTO accounts (acnt_dsply_name, acnt_description) VALUES ("BECU Saving", "Savings Account"); -INSERT INTO buckets (bkt_dsply_code, bkt_dsply_name, bkt_description) VALUES +INSERT INTO accounts (acnt_display_name, acnt_description) VALUES ("BECU Saving", "Savings Account"); +INSERT INTO buckets (bkt_display_code, bkt_display_name, bkt_description) VALUES ("SVNGS", "Savings", "Savings Bucket"); INSERT INTO transactions (trns_amount, trns_description, trns_account, trns_bucket, trns_date) VALUES ("50.00", "Money", 1, 1, "2023-11-10"); diff --git a/types/types.go b/types/types.go index 270f07a..51584e9 100644 --- a/types/types.go +++ b/types/types.go @@ -17,10 +17,17 @@ type Transaction struct { type Account struct { Id int `db:"acnt_id" json:"Id"` - DisplayName sql.NullString `db:"acnt_dsply_name" json:"DisplayName"` + DisplayName sql.NullString `db:"acnt_display_name" json:"DisplayName"` Description sql.NullString `db:"acnt_description" json:"Description"` } +type Bucket struct { + Id int `db:"bkt_id" json:"id"` + DisplayCode sql.NullString `db:"bkt_display_code" json:"DisplayCode"` + DisplayName sql.NullString `db:"bkt_display_name" json:"DisplayName"` + Description sql.NullString `db:"bkt_description" json:"Description"` +} + type HumanLegibleTransaction struct { Id int `db:"trns_id" json:"Id"` Amount string `db:"trns_amount" json:"Amount"` diff --git a/web/router.go b/web/router.go index 2c3dbdd..a0a8605 100644 --- a/web/router.go +++ b/web/router.go @@ -74,9 +74,19 @@ func renderFullPage(w http.ResponseWriter, c templ.Component, pageName string) { var new_tp bytes.Buffer; quick_trans_types, err := db.GetTransPaneEntries(0); + if err != nil { + log.Fatal().Err(err).Msg("Could not get transaction pane entries for user"); + } user_acnts, err := db.GetUserAccounts(0); + if err != nil { + log.Fatal().Err(err).Msg("Could not get accounts for user"); + } + user_bkts, err := db.GetUserBuckets(0); + if err != nil { + log.Fatal().Err(err).Msg("Could not get buckets for user"); + } - err = templates.NewTransactionPane(&quick_trans_types, &user_acnts).Render(context.Background(), &new_tp); + err = templates.NewTransactionPane(&quick_trans_types, &user_acnts, &user_bkts).Render(context.Background(), &new_tp); if err != nil { log.Fatal().Err(err).Msg("Could not render new transaction pane for index"); } diff --git a/web/sass/buttons.scss b/web/sass/buttons.scss index df319b1..85c0fb6 100644 --- a/web/sass/buttons.scss +++ b/web/sass/buttons.scss @@ -48,7 +48,7 @@ $button_sizes: ( .borderless-btn { @include btn; color: var(--#{$prefix}-text); - background-color: var(--#{$prefix}-surface2); + background-color: var(--#{$prefix}-surface1); } .borderless-btn:hover { background-color: var(--#{$prefix}-overlay1); diff --git a/web/sass/utility-classes.scss b/web/sass/utility-classes.scss index 3d7469b..07bc72c 100644 --- a/web/sass/utility-classes.scss +++ b/web/sass/utility-classes.scss @@ -197,59 +197,61 @@ table.table-striped { } .input-sizer { - display: inline-grid; - vertical-align: top; - align-items: center; - position: relative; - border: solid 1px; - padding: .25em .5em; - margin: 5px; - - &.stacked { - padding: .5em; - align-items: stretch; - + background-color: var(--#{$prefix}-overlay1); + color: var(--#{$prefix}-base); + display: inline-grid; + vertical-align: top; + align-items: center; + position: relative; + border: solid 1px; + border-radius: $border-radius * 2; + margin: 5px; + + &.stacked { + padding: .5em; + align-items: stretch; + + &::after, + input, + textarea { + grid-area: 2 / 1; + } + } + &::after, input, textarea { - grid-area: 2 / 1; + color: inherit; + width: auto; + min-width: 1em; + // grid-area: 1 / 1; + grid-area: 1 / 2; + font: inherit; + padding: 0.25em; + margin: 0; + resize: none; + background: none; + appearance: none; + border: none; } - } - - &::after, - input, - textarea { - width: auto; - min-width: 1em; - grid-area: 1 / 2; - font: inherit; - padding: 0.25em; - margin: 0; - resize: none; - background: none; - appearance: none; - border: none; - } - - span { - padding: 0.25em; - } - - &::after { - content: attr(data-value) ' '; - visibility: hidden; - white-space: pre-wrap; - } - - &:focus-within { - outline: solid 1px blue; - box-shadow: 4px 4px 0px blue; - - > span { color: blue; } - - textarea:focus, - input:focus { - outline: none; + + span { + padding: 0.25em; + // grid-area: 1 / 2; + } + + &::after { + content: attr(data-value) ' '; + visibility: hidden; + white-space: pre-wrap; + } + + &:focus-within { + // outline: solid 1px blue; + textarea:focus, + input:focus { + outline: none; + } + } - } } diff --git a/web/sass/variables.scss b/web/sass/variables.scss index f95d1f5..5e637b0 100644 --- a/web/sass/variables.scss +++ b/web/sass/variables.scss @@ -20,9 +20,9 @@ --#{$prefix}-maroon: #{map-get($color, 'maroon')}; --#{$prefix}-mauve: #{map-get($color, 'mauve')}; - --#{$prefix}-nav-bg: #{map-get($color, 'crust')}; - --#{$prefix}-nav-color: #{map-get($color, 'text')}; - --#{$prefix}-nav-logo-bg: #{map-get($color, 'rosewater')}; + --#{$prefix}-nav-bg: #{map-get($color, 'sky')}; + --#{$prefix}-nav-color: #{map-get($color, 'base')}; + --#{$prefix}-nav-logo-bg: #{map-get($color, 'teal')}; --#{$prefix}-nav-hover: #{map-get($color, 'surface2')}; --#{$prefix}-nav-active-bg: #{map-get($color, 'mauve')}; --#{$prefix}-nav-active-color: #{map-get($color, 'base')}; diff --git a/web/static/index.js b/web/static/index.js index e49bb03..c358456 100644 --- a/web/static/index.js +++ b/web/static/index.js @@ -1,6 +1,10 @@ import {fill_chart} from "./chart_functions.js"; import {register_dropdowns} from "./dropdowns.js"; -import {open_new_transaction_pane, close_new_transaction_pane} from "./new_transactions.js"; +import { + open_new_transaction_pane + , close_new_transaction_pane + , add_new_breakdown +} from "./new_transactions.js"; function debounce(func, delay) { @@ -61,6 +65,7 @@ function register_handlers() { document.querySelector(".input-sizer > input").addEventListener("input", (event) => { event.target.parentNode.dataset.value = event.target.value }); + document.getElementById("new-breakdown-btn").addEventListener("click", add_new_breakdown); close_new_transaction_pane(); } diff --git a/web/static/new_transactions.js b/web/static/new_transactions.js index 9b81d17..271052f 100644 --- a/web/static/new_transactions.js +++ b/web/static/new_transactions.js @@ -48,4 +48,15 @@ function close_new_transaction_pane() { } -export {open_new_transaction_pane, close_new_transaction_pane} +function add_new_breakdown() { + let source = document.querySelector("#breakdown-template-row tr").cloneNode(true); + source.style.removeProperty("display"); + console.log(source.querySelector("input[type='number']")); + document.getElementById("breakdown-tbody").appendChild(source); +} + +function update_breakdown_amount() { + +} + +export {open_new_transaction_pane, close_new_transaction_pane, add_new_breakdown} diff --git a/web/templates/new_transaction_pane.templ b/web/templates/new_transaction_pane.templ index 52c11db..5385ede 100644 --- a/web/templates/new_transaction_pane.templ +++ b/web/templates/new_transaction_pane.templ @@ -4,7 +4,19 @@ import "nickiel.net/recount_server/types" import "strconv" -templ NewTransactionPane(entry_types *[]types.QuickTransactionType, acnts *[]types.Account) { +templ NewTransactionPane(entry_types *[]types.QuickTransactionType, acnts *[]types.Account, buckets *[]types.Bucket) { +

New Transaction

@@ -12,12 +24,20 @@ templ NewTransactionPane(entry_types *[]types.QuickTransactionType, acnts *[]typ
-
- for _, value := range *entry_types { - + } +
+
+ - } +
@@ -43,24 +63,24 @@ templ NewTransactionPane(entry_types *[]types.QuickTransactionType, acnts *[]typ
-
-
-
+ +
+ Tag:

Breakdown

- @@ -71,7 +91,19 @@ templ NewTransactionPane(entry_types *[]types.QuickTransactionType, acnts *[]typ
+ + + + + + + + + + + +
BucketDescriptionAmount