supports choosing transactions.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
(:require [auto-ap.events :as events]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.views.components.modal :refer [modal]]
|
||||
[auto-ap.views.utils :refer [date->str]]
|
||||
[auto-ap.views.utils :refer [date->str dispatch-event]]
|
||||
[re-frame.core :as re-frame]))
|
||||
|
||||
|
||||
@@ -17,23 +17,49 @@
|
||||
(fn [db]
|
||||
(::runnable? db)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::checked
|
||||
(fn [db]
|
||||
(::checked db ::checked)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::checked-count
|
||||
:<- [::checked]
|
||||
(fn [checked]
|
||||
(count checked)))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::opening
|
||||
(fn [{:keys [db]} [_ results runnable?]]
|
||||
{:db (-> db
|
||||
(assoc ::test-results results)
|
||||
(assoc ::checked #{})
|
||||
(assoc ::runnable? runnable?))
|
||||
:dispatch [::events/modal-status ::test-results {:visible? true}]}))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::toggle
|
||||
[(re-frame/path [::checked])]
|
||||
(fn [checked [_ which]]
|
||||
(let [checked (or checked #{})]
|
||||
(if (checked which)
|
||||
(disj checked which)
|
||||
(conj checked which)))))
|
||||
|
||||
|
||||
(defn test-results-modal []
|
||||
(let [runnable @(re-frame/subscribe [::runnable?])]
|
||||
(let [runnable? @(re-frame/subscribe [::runnable?])
|
||||
checked @(re-frame/subscribe [::checked])
|
||||
checked-count @(re-frame/subscribe [::checked-count])]
|
||||
(when (:visible? @(re-frame/subscribe [::subs/modal-state ::test-results]))
|
||||
[modal {:title "Rule results"
|
||||
:hide-event [::events/modal-status ::test-results {:visible? false}]}
|
||||
:hide-event [::events/modal-status ::test-results {:visible? false}]
|
||||
:foot (when runnable?
|
||||
[:button.button.is-primary {:disabled (boolean (= checked-count 0))}
|
||||
(str "Apply to " checked-count " transactions")])}
|
||||
[:table.table.is-fullwidth.compact
|
||||
[:tr
|
||||
(when runnable
|
||||
(when runnable?
|
||||
[:th {:style {:width "2em"}}])
|
||||
[:th "Client"]
|
||||
[:th "Bank Account"]
|
||||
@@ -44,9 +70,11 @@
|
||||
|
||||
^{:key id}
|
||||
[:tr
|
||||
(when runnable
|
||||
(when runnable?
|
||||
[:td
|
||||
[:input.checkbox {:type "checkbox"}]])
|
||||
[:input.checkbox {:type "checkbox"
|
||||
:checked (boolean (checked id))
|
||||
:on-change (dispatch-event [::toggle id])}]])
|
||||
[:td (:name client)]
|
||||
[:td (:name bank-account)]
|
||||
[:td description-original]
|
||||
|
||||
Reference in New Issue
Block a user