Makes tasks card
This commit is contained in:
@@ -1,25 +1,28 @@
|
||||
(ns auto-ap.views.pages.transactions
|
||||
(:require [auto-ap.effects.forward :as forward]
|
||||
[auto-ap.forms :as forms]
|
||||
[auto-ap.status :as status]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.views.components.modal :as modal]
|
||||
[auto-ap.views.components.layouts
|
||||
:refer
|
||||
[appearing-side-bar side-bar-layout]]
|
||||
[auto-ap.views.components.modal :as modal]
|
||||
[auto-ap.views.pages.data-page :as data-page]
|
||||
[auto-ap.views.pages.transactions.common :refer [transaction-read data-params->query-params]]
|
||||
[auto-ap.views.pages.transactions.bulk-updates :as bulk]
|
||||
[auto-ap.views.pages.transactions.common :refer [data-params->query-params
|
||||
transaction-read]]
|
||||
[auto-ap.views.pages.transactions.form :as edit]
|
||||
[auto-ap.views.pages.transactions.manual :as manual]
|
||||
[auto-ap.views.pages.transactions.bulk-updates :as bulk]
|
||||
[auto-ap.views.pages.transactions.side-bar :as side-bar]
|
||||
[auto-ap.views.pages.transactions.table :as table]
|
||||
[auto-ap.views.utils :refer [dispatch-event with-user date->str standard]]
|
||||
[auto-ap.views.utils :refer [date->str dispatch-event standard
|
||||
with-user]]
|
||||
[auto-ap.views.utils :as u]
|
||||
[cljs-time.core :as time]
|
||||
[clojure.string :as str]
|
||||
[re-frame.core :as re-frame]
|
||||
[reagent.core :as reagent]
|
||||
[vimsical.re-frame.fx.track :as track]
|
||||
[auto-ap.status :as status]
|
||||
[clojure.string :as str]))
|
||||
[vimsical.re-frame.fx.track :as track]))
|
||||
|
||||
|
||||
|
||||
@@ -122,35 +125,38 @@
|
||||
(re-frame/reg-event-fx
|
||||
::mounted
|
||||
(fn [{:keys [db]} _]
|
||||
{:db (assoc-in db [::data-page/settled-filters ::page :date-range] {:start (date->str (time/plus (time/now) (time/months -1))
|
||||
standard)})
|
||||
::track/register {:id ::params
|
||||
:subscription [::data-page/params ::page]
|
||||
:event-fn (fn [params]
|
||||
[::params-change params])}
|
||||
::forward/register [{:id ::updated
|
||||
:events #{::edit/edited}
|
||||
:event-fn (fn [[_ edited-transaction]]
|
||||
[::data-page/updated-entity ::page edited-transaction])}
|
||||
{:id ::manual-import
|
||||
:events #{::manual/import-completed}
|
||||
:event-fn (fn [[_ result]]
|
||||
[::status/info ::manual-import
|
||||
(str "Successfully "
|
||||
(str/join ", "
|
||||
[(when-let [imported (:import-batch/imported result)]
|
||||
(str "imported " imported))
|
||||
(when-let [extant (:import-batch/extant result)]
|
||||
(str "extant " extant))
|
||||
(when-let [suppressed (:import-batch/suppressed result)]
|
||||
(str "suppressed " suppressed))
|
||||
(when-let [not-ready (:import-batch/not-ready result)]
|
||||
(str "too early " not-ready))
|
||||
(when-let [error (:validation-error result)]
|
||||
(str "errored " error))])
|
||||
" transactions."
|
||||
(when (:sample-error result)
|
||||
(str " Sample error: " (:info (:sample-error result)))))])}]}))
|
||||
(let [db (if (:date-range (u/query-params))
|
||||
db
|
||||
(assoc-in db [::data-page/settled-filters ::page :date-range] {:start (date->str (time/plus (time/now) (time/months -1))
|
||||
standard)}))]
|
||||
{:db db
|
||||
::track/register {:id ::params
|
||||
:subscription [::data-page/params ::page]
|
||||
:event-fn (fn [params]
|
||||
[::params-change params])}
|
||||
::forward/register [{:id ::updated
|
||||
:events #{::edit/edited}
|
||||
:event-fn (fn [[_ edited-transaction]]
|
||||
[::data-page/updated-entity ::page edited-transaction])}
|
||||
{:id ::manual-import
|
||||
:events #{::manual/import-completed}
|
||||
:event-fn (fn [[_ result]]
|
||||
[::status/info ::manual-import
|
||||
(str "Successfully "
|
||||
(str/join ", "
|
||||
[(when-let [imported (:import-batch/imported result)]
|
||||
(str "imported " imported))
|
||||
(when-let [extant (:import-batch/extant result)]
|
||||
(str "extant " extant))
|
||||
(when-let [suppressed (:import-batch/suppressed result)]
|
||||
(str "suppressed " suppressed))
|
||||
(when-let [not-ready (:import-batch/not-ready result)]
|
||||
(str "too early " not-ready))
|
||||
(when-let [error (:validation-error result)]
|
||||
(str "errored " error))])
|
||||
" transactions."
|
||||
(when (:sample-error result)
|
||||
(str " Sample error: " (:info (:sample-error result)))))])}]})))
|
||||
|
||||
(defn action-buttons []
|
||||
(let [is-admin? @(re-frame/subscribe [::subs/is-admin?])
|
||||
|
||||
Reference in New Issue
Block a user