Makes transaction rule form much better; state visible
This commit is contained in:
@@ -6,7 +6,9 @@
|
||||
[auto-ap.views.components.sort-by-list :refer [sort-by-list]]
|
||||
[auto-ap.views.pages.admin.rules.results-modal :as results-modal]
|
||||
[auto-ap.views.components.sorter :refer [sorted-column toggle-sort-by sort-icon]]
|
||||
[auto-ap.views.components.buttons :as buttons]
|
||||
[auto-ap.views.components.grid :as grid]
|
||||
[auto-ap.status :as status]
|
||||
[re-frame.core :as re-frame]
|
||||
[reagent.core :as reagent]
|
||||
[reagent.core :as r]))
|
||||
@@ -17,6 +19,8 @@
|
||||
(fn [{:keys [user db]} [_ which]]
|
||||
{:graphql
|
||||
{:token user
|
||||
:owns-state {:multi ::run
|
||||
:which (:id which)}
|
||||
:query-obj {:venia/operation {:operation/type :query
|
||||
:operation/name "RunTransactionRule"}
|
||||
:venia/queries [{:query/data [:run-transaction-rule
|
||||
@@ -27,8 +31,7 @@
|
||||
[:client [:name]]
|
||||
[:bank-account [:name]]
|
||||
:description-original]]}]}
|
||||
:on-success [::succeeded-run (:id which)]
|
||||
#_#_:on-error [:forms/save-error ::form]}}))
|
||||
:on-success [::succeeded-run (:id which)]}}))
|
||||
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
@@ -41,6 +44,11 @@
|
||||
(fn [db]
|
||||
(::table-params db)))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::unmounted
|
||||
(fn [db]
|
||||
(status/reset-multi db ::run)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::table-params
|
||||
:<- [::specific-table-params]
|
||||
@@ -55,13 +63,13 @@
|
||||
{:db (merge table-params params)}))
|
||||
|
||||
|
||||
|
||||
(defn table [{:keys [id rule-page on-params-change params status]}]
|
||||
(defn table* [{:keys [id rule-page on-params-change params status]}]
|
||||
(let [{:keys [sort asc]} @params
|
||||
{:keys [transaction-rules start end count total]} @rule-page
|
||||
selected-client @(re-frame/subscribe [::subs/client])
|
||||
opc (fn [p]
|
||||
(re-frame/dispatch [::params-changed p]))]
|
||||
(re-frame/dispatch [::params-changed p]))
|
||||
states @(re-frame/subscribe [::status/multi ::run])]
|
||||
[grid/grid {:on-params-change opc
|
||||
:params @(re-frame/subscribe [::table-params])
|
||||
:status @status
|
||||
@@ -88,7 +96,7 @@
|
||||
:sort-name "Note"}
|
||||
"Note"]
|
||||
|
||||
[grid/header-cell {}]]]
|
||||
[grid/header-cell {:style {:width (str (inc (* 2 44)) "px")}}]]]
|
||||
[grid/body
|
||||
(for [{:keys [client bank-account description amount-lte amount-gte note id] :as r} transaction-rules]
|
||||
^{:key id}
|
||||
@@ -109,6 +117,12 @@
|
||||
:else
|
||||
"")]
|
||||
[grid/cell {} note]
|
||||
[grid/cell {} [:div.buttons
|
||||
[:a.button {:on-click (dispatch-event [::run-clicked r])} [:span.icon [:i.fa.fa-play]]]
|
||||
[:a.button {:on-click (dispatch-event [::form/editing r])} [:span.icon [:i.fa.fa-pencil]]]]]])]]]))
|
||||
[grid/cell {}
|
||||
[:div.buttons
|
||||
[buttons/fa-icon {:event [::run-clicked r] :icon :fa-play :class (status/class-for (get states (:id r)))}]
|
||||
[buttons/fa-icon {:event [::form/editing r] :icon :fa-pencil}]]]])]]]))
|
||||
|
||||
(defn table [params]
|
||||
(r/create-class {:component-will-unmount (dispatch-event [::unmounted])
|
||||
:reagent-render (fn []
|
||||
[table* params])}))
|
||||
|
||||
Reference in New Issue
Block a user