tells you about potential matches.

This commit is contained in:
Bryce Covert
2019-04-24 07:35:19 -07:00
parent deef4eb4a4
commit f547911c5b
6 changed files with 104 additions and 34 deletions

View File

@@ -67,7 +67,7 @@
;; VIEWS
(defn expense-accounts-field [{expense-accounts :value max-value :max locations :locations event :event descriptor :descriptor}]
(defn expense-accounts-field [{expense-accounts :value max-value :max locations :locations event :event descriptor :descriptor disabled :disabled}]
(let [chooseable-expense-accounts @(re-frame/subscribe [::subs/chooseable-expense-accounts])
accounts-by-id @(re-frame/subscribe [::subs/accounts-for-client-by-id])]
[:div
@@ -76,9 +76,10 @@
[:h1.subtitle.is-4.is-inline (str/capitalize descriptor) "s"]
[:p.help "Remaining " (->$ (- max-value (reduce + 0 (map (comp js/parseFloat :amount) expense-accounts))))]]
[:div.column.is-narrow
[:p.buttons
[:a.button {:on-click (dispatch-event [::spread-evenly event expense-accounts max-value])} "Spread evenly"]
[:a.button {:on-click (dispatch-event [::add-expense-account event expense-accounts])} "Add"]]]]
(when-not disabled
[:p.buttons
[:a.button {:on-click (dispatch-event [::spread-evenly event expense-accounts max-value])} "Spread evenly"]
[:a.button {:on-click (dispatch-event [::add-expense-account event expense-accounts])} "Add"]])]]
(for [[index {:keys [account id location amount amount-mode] :as expense-account}] (map vector (range) expense-accounts)
:let [account (accounts-by-id (:id account))]]
@@ -92,7 +93,8 @@
(gstring/format "$%.2f" (or amount 0) ))
[: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]]]]]
(when-not disabled
[: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
@@ -100,6 +102,7 @@
[:div.control.is-fullwidth
[bind-field
[typeahead {:matches (map (fn [x] [(:id x) (str (:numeric-code x) " - " (:name x))]) chooseable-expense-accounts)
:disabled disabled
:type "typeahead"
:field [index :account :id]
#_#_:text-field [index :account :name]
@@ -115,9 +118,8 @@
[:div.select
[bind-field
[:select {:type "select"
:disabled (if (:location account)
"disabled"
"")
:disabled (boolean (or (:location account)
disabled))
:style {:width "5em"}
:field [index :location]
:allow-nil? true
@@ -134,6 +136,7 @@
[:p.control [:span.select
[bind-field
[:select {:type "select"
:disabled disabled
:field [index :amount-mode]
:allow-nil? false
:event [::expense-account-changed event expense-accounts max-value]
@@ -147,6 +150,7 @@
:field [index :amount]
:style {:text-align "right" :width "7em"}
:event [::expense-account-changed event expense-accounts max-value]
:disabled disabled
:subscription expense-accounts
:precision 2
:value (get-in expense-account [:amount])
@@ -156,6 +160,7 @@
[:input.input {:type "number"
:field [index :amount-percentage]
:style {:text-align "right" :width "7em"}
:disabled disabled
:event [::expense-account-changed event expense-accounts max-value]
:precision 2
:subscription expense-accounts