A better way to allow bulk select.
This commit is contained in:
@@ -54,29 +54,53 @@
|
||||
:query/alias :result}]}
|
||||
:on-success (fn [result]
|
||||
|
||||
|
||||
[::data-page/received ::page (:result result)])}}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::unapprove-all
|
||||
::unapprove-selected
|
||||
(fn [cofx [_ params]]
|
||||
|
||||
{:db (-> (:db cofx)
|
||||
(assoc-in [:status :loading] true))
|
||||
:graphql {:token (-> cofx :db :user)
|
||||
:owns-state {:single ::unapprove-all}
|
||||
:query-obj
|
||||
{:venia/operation {:operation/type :mutation
|
||||
:operation/name "UnapproveTransactions"}
|
||||
:venia/queries [{:query/data
|
||||
[:unapprove-transactions
|
||||
(data-params->query-params params)
|
||||
[[:transactions transaction-read]
|
||||
:total
|
||||
:start
|
||||
:end]]}]}
|
||||
:on-success (fn [result]
|
||||
[::data-page/received ::page (set/rename-keys (first (:unapprove-transactions result))
|
||||
{:transactions :data})])}}))
|
||||
(let [checked @(re-frame/subscribe [::data-page/checked ::page])
|
||||
checked-params (get checked "header")
|
||||
specific-transactions (map :id (vals (dissoc checked "header")))]
|
||||
(println checked-params)
|
||||
{:db (-> (:db cofx)
|
||||
(assoc-in [:status :loading] true))
|
||||
:graphql {:token (-> cofx :db :user)
|
||||
:owns-state {:single ::unapprove-selected}
|
||||
:query-obj
|
||||
{:venia/operation {:operation/type :mutation
|
||||
:operation/name "UnapproveTransactions"}
|
||||
:venia/queries [{:query/data
|
||||
[:unapprove-transactions
|
||||
{:filters (some-> checked-params data-params->query-params)
|
||||
:ids specific-transactions}
|
||||
[:message]]}]}
|
||||
:on-success (fn [result]
|
||||
[::params-change params]
|
||||
#_[::data-page/received ::page (:result result)])}})))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::delete-selected
|
||||
(fn [cofx [_ params]]
|
||||
(let [checked @(re-frame/subscribe [::data-page/checked ::page])
|
||||
checked-params (get checked "header")
|
||||
specific-transactions (map :id (vals (dissoc checked "header")))]
|
||||
(println checked-params)
|
||||
{:db (-> (:db cofx)
|
||||
(assoc-in [:status :loading] true))
|
||||
:graphql {:token (-> cofx :db :user)
|
||||
:owns-state {:single ::delete-selected}
|
||||
:query-obj
|
||||
{:venia/operation {:operation/type :mutation
|
||||
:operation/name "UnapproveTransactions"}
|
||||
:venia/queries [{:query/data
|
||||
[:delete-transactions
|
||||
{:filters (some-> checked-params data-params->query-params)
|
||||
:ids specific-transactions}
|
||||
[:message]]}]}
|
||||
:on-success (fn [result]
|
||||
[::params-change params])}})))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::unmounted
|
||||
@@ -105,22 +129,41 @@
|
||||
|
||||
|
||||
(defn content []
|
||||
(let [user @(re-frame/subscribe [::subs/user])
|
||||
params @(re-frame/subscribe [::data-page/params ::page])]
|
||||
(let [is-admin? @(re-frame/subscribe [::subs/is-admin?])
|
||||
params @(re-frame/subscribe [::data-page/params ::page])
|
||||
checked @(re-frame/subscribe [::data-page/checked ::page])]
|
||||
[:div
|
||||
[:h1.title "Transactions"]
|
||||
[status/status-notification {:statuses [[::status/single ::unapprove-all]
|
||||
[status/status-notification {:statuses [[::status/single ::unapprove-selected]
|
||||
[::status/single ::delete-selected]
|
||||
[::status/single ::manual-import]]}]
|
||||
(when (= "admin" (:user/role user))
|
||||
(when is-admin?
|
||||
[:div.is-pulled-right
|
||||
[:div.buttons
|
||||
|
||||
(into [:div.tags ] (map (fn [[z {:keys [id]}]]
|
||||
(if (= "header" z)
|
||||
[:span.tag.is-medium {:on-click
|
||||
(dispatch-event [::data-page/remove-check ::page "header"])}
|
||||
"All visible transactions"]
|
||||
[:span.tag.is-medium id
|
||||
[:button.delete.is-small {:on-click
|
||||
(dispatch-event [::data-page/remove-check ::page id])}]]))
|
||||
checked))
|
||||
[:button.button.is-outlined.is-primary {:on-click (dispatch-event [::manual/opening])}
|
||||
"Manual Yodlee Import"]
|
||||
[:button.button.is-warning {:on-click (dispatch-event [::unapprove-all params])
|
||||
:class (status/class-for @(re-frame/subscribe [::status/single ::unapprove-all]))
|
||||
:disabled (status/disabled-for @(re-frame/subscribe [::status/single ::unapprove-all]))}
|
||||
"Unapprove all"]]])
|
||||
[:button.button.is-warning {:on-click (dispatch-event [::unapprove-selected params])
|
||||
:class (status/class-for @(re-frame/subscribe [::status/single ::unapprove-selected]))
|
||||
:disabled (or (status/disabled-for @(re-frame/subscribe [::status/single ::unapprove-selected]))
|
||||
(not (seq checked)))}
|
||||
"Unapprove selected"]
|
||||
[:button.button.is-danger {:on-click (dispatch-event [::delete-selected params])
|
||||
:class (status/class-for @(re-frame/subscribe [::status/single ::delete-selected]))
|
||||
:disabled (or (status/disabled-for @(re-frame/subscribe [::status/single ::delete-selected]))
|
||||
(not (seq checked)))}
|
||||
"Delete selected"]]])
|
||||
[table/table {:id :transactions
|
||||
:check-boxes? is-admin?
|
||||
:data-page ::page}]]))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user