Recommends a name

This commit is contained in:
Bryce Covert
2019-06-05 21:38:02 -07:00
parent 303068f1fc
commit 16e1ce998e
3 changed files with 37 additions and 9 deletions

View File

@@ -8,8 +8,7 @@
(s/def ::amount-lte (s/nilable double?))
(s/def ::dom-gte (s/nilable int?))
(s/def ::dom-lte (s/nilable int?))
(s/def ::note (s/and string?
#(not (str/blank? %))))
(s/def ::note (s/nilable string?))
(s/def ::bank-account (s/nilable map?))
(s/def ::vendor (s/nilable map?))
(s/def ::yodlee-merchant (s/nilable map?))

View File

@@ -21,6 +21,27 @@
;; SUBS
(re-frame/reg-sub
::default-note
:<- [::forms/form ::form]
(fn [{{:keys [client description amount-lte amount-gte dom-lte dom-gte]} :data}]
(str/join " - " (filter (complement str/blank?)
[(:code client)
description
(when (or amount-lte amount-gte)
(str (when amount-gte
(str amount-gte "<"))
"amt"
(when amount-lte
(str "<" amount-lte))))
(when (or dom-lte dom-gte)
(str (when dom-gte
(str dom-gte "<"))
"dom"
(when dom-lte
(str "<" dom-lte))))]))))
(re-frame/reg-sub
::can-submit
@@ -45,6 +66,9 @@
:dom-gte
:accounts
:note])
(update :note #(if (str/blank? %)
@(re-frame/subscribe [::default-note])
%))
(assoc :vendor-id (:id (:vendor data)))
(assoc :yodlee-merchant-id (:id (:yodlee-merchant data)))
(update :accounts (fn [as]
@@ -195,19 +219,17 @@
[layouts/side-bar {:on-close (dispatch-event [::forms/form-closing ::form ])}
(let [{:keys [data active? error id]} @(re-frame/subscribe [::forms/form ::form])
{:keys [form field raw-field error-notification submit-button ]} rule-form
default-note @(re-frame/subscribe [::default-note])
exists? (:id data)
chooseable-expense-accounts @(re-frame/subscribe [::subs/chooseable-expense-accounts])
accounts-by-id @(re-frame/subscribe [::subs/accounts-for-client-by-id])]
^{:key id}
[form (assoc params :title "New Transaction Rule")
[field "Note"
[:input.input {:type "text"
:auto-focus true
:field [:note]
:spec ::entity/note}]]
[field "Client"
[typeahead-entity {:matches @(re-frame/subscribe [::subs/clients])
:auto-focus true
:match->text :name
:type "typeahead-entity"
:field [:client]
@@ -299,6 +321,11 @@
[:approved "Approved"]
[:excluded "Excluded from Ledger"]]}]]
[field "Note"
[:input.input {:type "text"
:field [:note]
:placeholder default-note
:spec (s/nilable ::entity/note)}]]
[:div.is-divider]
[error-notification]

View File

@@ -21,13 +21,15 @@
(re-frame/reg-sub
::checked
(fn [db]
(::checked db ::checked)))
(::checked db)))
(re-frame/reg-sub
::checked-count
:<- [::checked]
(fn [checked]
(count checked)))
(if (seq checked)
(count checked)
0)))
(re-frame/reg-event-fx
::opening