all kinds of linkability.
This commit is contained in:
@@ -135,16 +135,19 @@
|
||||
(re-frame/reg-event-fx
|
||||
::set-active-page
|
||||
(fn [{:keys [db]} [_ handler params]]
|
||||
|
||||
|
||||
(if (and (not= :login handler) (not (:user db)))
|
||||
{:redirect "/login"
|
||||
:db (assoc db :active-page :login
|
||||
:page-failure nil
|
||||
:auto-ap.forms/forms nil)}
|
||||
{:db (assoc db :active-page handler
|
||||
:page-failure nil
|
||||
:query-params params
|
||||
:auto-ap.forms/forms nil)})))
|
||||
{:db (-> db
|
||||
(assoc :active-page handler
|
||||
:page-failure nil
|
||||
:query-params params
|
||||
:auto-ap.forms/forms nil)
|
||||
(auto-ap.views.pages.data-page/dispose-all))})))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::imported-invoices
|
||||
|
||||
@@ -170,6 +170,7 @@
|
||||
[:td (:post-date (:transaction (:payment invoice-payment)))]
|
||||
[:td
|
||||
[buttons/fa-icon {:icon "fa-external-link"
|
||||
:target "_blank"
|
||||
:href (str (bidi/path-for routes/routes :payments )
|
||||
"?"
|
||||
(url/map->query {:exact-match-id (:id (:payment invoice-payment))}))}]]])]]]]]
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.views.utils :refer [active-when active-when= login-url dispatch-event]]
|
||||
[auto-ap.views.components.layouts :refer [side-bar-layout loading-layout]]
|
||||
[auto-ap.views.pages.unpaid-invoices :refer [unpaid-invoices-page]]
|
||||
[auto-ap.views.pages.unpaid-invoices :refer [unpaid-invoices-page paid-invoices-page all-invoices-page voided-invoices-page]]
|
||||
[auto-ap.views.pages.import-invoices :refer [import-invoices-page]]
|
||||
[auto-ap.views.pages.needs-activation :refer [needs-activation-page]]
|
||||
[auto-ap.views.pages.transactions :refer [transactions-page]]
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
(defmulti page (fn [active-page] active-page))
|
||||
(defmethod page :unpaid-invoices [_]
|
||||
^{:key :voided}
|
||||
^{:key :unpaid}
|
||||
[unpaid-invoices-page {:status :unpaid}])
|
||||
|
||||
(defmethod page :import-invoices [_]
|
||||
@@ -42,17 +42,16 @@
|
||||
|
||||
|
||||
(defmethod page :paid-invoices [_]
|
||||
^{:key :voided}
|
||||
[unpaid-invoices-page {:status :paid}]
|
||||
)
|
||||
^{:key :paid}
|
||||
[paid-invoices-page {:status :paid}])
|
||||
|
||||
(defmethod page :voided-invoices [_]
|
||||
^{:key :voided}
|
||||
[unpaid-invoices-page {:status :voided}])
|
||||
[voided-invoices-page {:status :voided}])
|
||||
|
||||
(defmethod page :invoices [_]
|
||||
^{:key :all}
|
||||
[unpaid-invoices-page {}])
|
||||
[all-invoices-page {}])
|
||||
|
||||
(defmethod page :payments [_]
|
||||
[payments-page])
|
||||
|
||||
@@ -57,10 +57,13 @@
|
||||
(fn [db [_ which]]
|
||||
(get-in db [::additional-params which])))
|
||||
|
||||
|
||||
|
||||
(re-frame/reg-sub
|
||||
::params
|
||||
(fn [[_ id]]
|
||||
[(re-frame/subscribe [::subs/client])
|
||||
[ #_(re-frame/subscribe [::subs/active-page])
|
||||
(re-frame/subscribe [::subs/client])
|
||||
(re-frame/subscribe [::settled-filters id])
|
||||
(re-frame/subscribe [::table-params id])
|
||||
(re-frame/subscribe [::additional-params id])])
|
||||
@@ -76,9 +79,11 @@
|
||||
(re-frame/reg-event-fx
|
||||
::received
|
||||
(fn [{:keys [db]} [_ id data]]
|
||||
(println @(re-frame/subscribe [::params id]))
|
||||
{:db (assoc-in db [::data id] data)
|
||||
:set-uri-params (dissoc @(re-frame/subscribe [::params id]) :client-id)}))
|
||||
(let [uri-params (dissoc @(re-frame/subscribe [::params id]) :client-id)
|
||||
current-uri-params (auto-ap.views.utils/query-params)]
|
||||
(cond-> {:db (-> db (assoc-in [::data id] data)
|
||||
(assoc :query-params uri-params))}
|
||||
(not= uri-params current-uri-params) (assoc :set-uri-params uri-params)))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::dispose
|
||||
@@ -90,6 +95,11 @@
|
||||
(update ::filters dissoc id)
|
||||
(update ::settled-filters dissoc id))))
|
||||
|
||||
(defn dispose-all [db]
|
||||
(-> db
|
||||
(dissoc ::data ::checked ::table-params ::filters ::settled-filters)))
|
||||
|
||||
|
||||
(re-frame/reg-sub
|
||||
::data
|
||||
(fn [db [_ id]]
|
||||
|
||||
@@ -38,14 +38,17 @@
|
||||
::params-change
|
||||
[with-user]
|
||||
(fn [{:keys [user]} [_ params]]
|
||||
{:graphql {:token user
|
||||
:owns-state {:single [::data-page/page :invoices]}
|
||||
:query-obj (table/query params )
|
||||
:on-success (fn [result]
|
||||
(let [result (set/rename-keys (first (:invoice-page result))
|
||||
{:invoices :data})]
|
||||
(try
|
||||
{:graphql {:token user
|
||||
:owns-state {:single [::data-page/page :invoices]}
|
||||
:query-obj (table/query params )
|
||||
:on-success (fn [result]
|
||||
(let [result (set/rename-keys (first (:invoice-page result))
|
||||
{:invoices :data})]
|
||||
|
||||
[::data-page/received :invoices result]))}}))
|
||||
[::data-page/received :invoices result]))}}
|
||||
(catch js/Error e
|
||||
(println "Warning" e)))))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::unmounted
|
||||
@@ -196,14 +199,36 @@
|
||||
:checkable-fn (fn [i] (not (:scheduled-payment i)))
|
||||
:actions #{:edit :void :expense-accounts}}]]))
|
||||
|
||||
(defn layout [params]
|
||||
(let [{invoice-bar-active? :active?} @(re-frame/subscribe [::forms/form ::form/form])]
|
||||
[side-bar-layout {:side-bar [invoices-side-bar {:data-page :invoices}]
|
||||
:main [unpaid-invoices-content params]
|
||||
:right-side-bar [appearing-side-bar {:visible? invoice-bar-active?} [form/form {}]]}]))
|
||||
|
||||
(defn unpaid-invoices-page [params]
|
||||
(r/create-class
|
||||
{:display-name "invoices-page"
|
||||
{:display-name "unpaid-invoices-page"
|
||||
:component-will-unmount #(re-frame/dispatch-sync [::unmounted])
|
||||
:component-did-mount #(re-frame/dispatch [::mounted])
|
||||
:reagent-render
|
||||
(fn []
|
||||
(let [{invoice-bar-active? :active?} @(re-frame/subscribe [::forms/form ::form/form])]
|
||||
[side-bar-layout {:side-bar [invoices-side-bar {:data-page :invoices}]
|
||||
:main [unpaid-invoices-content params]
|
||||
:right-side-bar [appearing-side-bar {:visible? invoice-bar-active?} [form/form {}]]}]))}))
|
||||
:reagent-render layout}))
|
||||
|
||||
(defn paid-invoices-page [params]
|
||||
(r/create-class
|
||||
{:display-name "paid-invoices-page"
|
||||
:component-will-unmount #(re-frame/dispatch-sync [::unmounted])
|
||||
:component-did-mount #(re-frame/dispatch [::mounted])
|
||||
:reagent-render layout}))
|
||||
|
||||
(defn voided-invoices-page [params]
|
||||
(r/create-class
|
||||
{:display-name "voided-invoices-page"
|
||||
:component-will-unmount #(re-frame/dispatch-sync [::unmounted])
|
||||
:component-did-mount #(re-frame/dispatch [::mounted])
|
||||
:reagent-render layout}))
|
||||
|
||||
(defn all-invoices-page [params]
|
||||
(r/create-class
|
||||
{:display-name "all-invoices-page"
|
||||
:component-will-unmount #(re-frame/dispatch-sync [::unmounted])
|
||||
:component-did-mount #(re-frame/dispatch [::mounted])
|
||||
:reagent-render layout}))
|
||||
|
||||
Reference in New Issue
Block a user