Supports editing the approval status.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
:amount-lte
|
||||
:dom-gte
|
||||
:dom-lte
|
||||
:transaction-approval-status
|
||||
[:vendor [:name :id]]
|
||||
[:client [:name :id]]
|
||||
[:bank-account [:name :id]]
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
{:transaction-rule (-> data
|
||||
(select-keys [:id
|
||||
:description
|
||||
:transaction-approval-status
|
||||
:amount-lte
|
||||
:amount-gte
|
||||
:dom-lte
|
||||
@@ -115,7 +116,8 @@
|
||||
:dom-lte
|
||||
:dom-gte
|
||||
:vendor
|
||||
:accounts])
|
||||
:accounts
|
||||
:transaction-approval-status])
|
||||
(update :accounts (fn [xs]
|
||||
(println xs)
|
||||
(mapv #(assoc % :amount-percentage (* (:percentage %) 100.0))
|
||||
@@ -173,6 +175,17 @@
|
||||
:submit-event [::saving ]
|
||||
:id ::form}))
|
||||
|
||||
(defn button-radio [{:keys [options on-change value]}]
|
||||
[:div.control
|
||||
[:div.field.has-addons
|
||||
(for [[k v] options]
|
||||
^{:key k}
|
||||
[:p.control
|
||||
[:a.button {:class (if (= value k)
|
||||
"is-primary"
|
||||
"")
|
||||
:on-click (fn [] (on-change k))} v]])]])
|
||||
|
||||
(defn form [{:keys [can-change-amount?] :as params}]
|
||||
[layouts/side-bar {:on-close (dispatch-event [::forms/form-closing ::form ])}
|
||||
(let [{:keys [data active? error id]} @(re-frame/subscribe [::forms/form ::form])
|
||||
@@ -268,7 +281,17 @@
|
||||
:max 100
|
||||
:field [:accounts]}]]
|
||||
|
||||
[field "Approval Status"
|
||||
[button-radio
|
||||
{:type "button-radio"
|
||||
:field [:transaction-approval-status]
|
||||
:options [[:unapproved "Unapproved"]
|
||||
[:requires-feedback "Client Review"]
|
||||
[:approved "Approved"]
|
||||
]}]]
|
||||
|
||||
|
||||
[:div.is-divider]
|
||||
[error-notification]
|
||||
|
||||
[:div.columns
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
(-> which
|
||||
(select-keys [:vendor :amount :payment :client :description-original
|
||||
:yodlee-merchant :id :potential-payment-matches
|
||||
:exclude-from-ledger :location :accounts])
|
||||
:exclude-from-ledger :location :accounts :transaction-approval-status])
|
||||
(assoc :potential-payment-matches potential-payment-matches)
|
||||
(update :accounts expense-accounts-field/from-graphql (:amount which) locations))))))
|
||||
|
||||
@@ -183,6 +183,8 @@
|
||||
{:type "checkbox"
|
||||
:field [:exclude-from-ledger]}]]
|
||||
" Exclude from ledger"]]
|
||||
|
||||
[:hr]
|
||||
|
||||
[error-notification]
|
||||
[submit-button "Save"]])])])
|
||||
|
||||
@@ -191,6 +191,20 @@
|
||||
keys (dissoc keys :field :subscription :spec)]
|
||||
(into [dom keys] (with-keys rest))))
|
||||
|
||||
|
||||
(defmethod do-bind "button-radio" [dom {:keys [field event subscription class spec] :as keys} & rest]
|
||||
(let [field (if (keyword? field) [field] field)
|
||||
event (if (keyword? event) [event] event)
|
||||
keys (assoc keys
|
||||
:value (get-in subscription field)
|
||||
:on-change (fn [v]
|
||||
(re-frame/dispatch (-> event (conj field) (conj v))))
|
||||
:class (str class
|
||||
(when (and spec (not (s/valid? spec (get-in subscription field))))
|
||||
" is-danger")))
|
||||
keys (dissoc keys :field :event :subscription :spec)]
|
||||
(into [dom keys] (with-keys rest))))
|
||||
|
||||
(defmethod do-bind "number" [dom {:keys [field precision event subscription class spec] :as keys :or {precision 2}} & rest]
|
||||
(let [field (if (keyword? field) [field] field)
|
||||
event (if (keyword? event) [event] event)
|
||||
|
||||
Reference in New Issue
Block a user