~whereswaldon/rosebud

bc2c40b0a16cbd85a1f54897e179574a06155f02 — Chris Waldon 1 year, 8 days ago e1342e9
appwidget: populate empty balance on submit

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
1 files changed, 20 insertions(+), 2 deletions(-)

M appwidget/tx-form.go
M appwidget/tx-form.go => appwidget/tx-form.go +20 -2
@@ 23,7 23,13 @@ type TxRow struct {
	Amount  widget.Editor
	Hint    string
	Message string
	Invalid bool
}

func (t *TxRow) Reset() {
	t.Account.Editor.SetText("")
	t.Amount.SetText("")
	t.Hint = ""
	t.Message = ""
}

func (t *TxRow) Populated() bool {


@@ 44,7 50,7 @@ func (t *TxRow) Value() ledger.Account {
}

type TransactionSubmittedEvent struct {
	value ledger.Transaction
	Value ledger.Transaction
}

type TxForm struct {


@@ 73,6 79,16 @@ func (t *TxForm) IsValid() bool {
	return t.valid
}

func (t *TxForm) Reset() {
	for i := range t.Rows {
		t.Rows[i].Reset()
	}
	t.Rows = t.Rows[:2]
	t.DateEditor.SetText("")
	t.PayeeEditor.Editor.SetText("")
	t.valid = false
}

// balance returns whether the transaction is currently balanced. If it is
// balanced, but has an empty amount with an inferred value, the index of
// the empty accound and its inferred value are returned. If there is no


@@ 147,7 163,9 @@ func (t *TxForm) Layout(gtx C, w layout.Widget) D {
		}
	}
	if t.SubmitBtn.Clicked() && t.IsValid() {
		t.value.AccountChanges[emptyIdx].Balance = emptyValue
		t.events = append(t.events, TransactionSubmittedEvent{t.value})
		t.Reset()
	}

	return dims