started adjusting the transaction form to support splits.

This commit is contained in:
Bryce Covert
2019-04-17 12:08:10 -07:00
parent d30b0948d4
commit 0081d0aaed
4 changed files with 23 additions and 38 deletions

View File

@@ -4,7 +4,8 @@
[auto-ap.views.components.typeahead :refer [typeahead]]
[auto-ap.views.utils :refer [bind-field dispatch-event]]
[goog.string :as gstring]
[re-frame.core :as re-frame]))
[re-frame.core :as re-frame]
[clojure.string :as str]))
;; EVENTS
@@ -35,13 +36,14 @@
;; VIEWS
(defn expense-accounts-field [{expense-accounts :value max-value :max locations :locations event :event}]
(defn expense-accounts-field [{expense-accounts :value max-value :max locations :locations event :event descriptor :descriptor}]
(let [chooseable-expense-accounts @(re-frame/subscribe [::subs/chooseable-expense-accounts])
accounts-by-id @(re-frame/subscribe [::subs/accounts-for-client-by-id])]
[:div
[:div.columns
[:div.column
[:h1.subtitle.is-4.is-inline "Expense Accounts"]]
[:h1.subtitle.is-4.is-inline (str/capitalize descriptor) "s"]]
[:div.column.is-narrow
[:p.buttons
[:a.button {:on-click (dispatch-event [::add-expense-account event expense-accounts])} "Add"]]]]
@@ -56,19 +58,18 @@
(str (:name account) " - "
location ": "
(gstring/format "$%.2f" (or amount 0) ))
[:i "New expense account"])]]
[:i "New " descriptor])]]
[:div.column.is-narrow
[:a.button {:on-click (dispatch-event [::remove-expense-account event expense-accounts id])} [:span.icon [:i.fa.fa-times]]]]]
[:div.field
[:div.columns
[:div.column
[:p.help "Expense Account"]
[:p.help "Account"]
[:div.control.is-fullwidth
[bind-field
[typeahead {:matches (map (fn [x] [(:id x) (str (:numeric-code x) " - " (:name x))]) chooseable-expense-accounts)
:type "typeahead"
:field [index :account :id]
:text-field [index :account :name]
:event [::expense-account-changed event expense-accounts]
:subscription expense-accounts}]]]]
[:div.column.is-narrow