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