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