Made all interactions much better
This commit is contained in:
@@ -16,13 +16,29 @@
|
||||
[clojure.string :as str]
|
||||
[goog.string :as gstring]
|
||||
[re-frame.core :as re-frame]
|
||||
[auto-ap.views.components.expense-accounts-dialog :as expense-accounts-dialog]))
|
||||
[auto-ap.views.components.expense-accounts-dialog :as expense-accounts-dialog]
|
||||
[auto-ap.views.pages.data-page :as data-page]))
|
||||
|
||||
(defn query [params]
|
||||
{:venia/queries [[:invoice_page
|
||||
(-> params
|
||||
(assoc
|
||||
:client-id (:id @(re-frame/subscribe [::subs/client]))))
|
||||
{
|
||||
:start (:start params 0)
|
||||
:sort (:sort params)
|
||||
|
||||
:vendor-id (:id (:vendor params))
|
||||
:date-range (:date-range params)
|
||||
:due-range (:due-range params)
|
||||
:amount-gte (:amount-gte (:amount-range params))
|
||||
:amount-lte (:amount-lte (:amount-range params))
|
||||
:invoice-number-like (:invoice-number-like params)
|
||||
:client-id (:id @(re-frame/subscribe [::subs/client]))
|
||||
:import-status (:import-status params)
|
||||
:status (condp = @(re-frame/subscribe [::subs/active-page])
|
||||
:invoices nil
|
||||
:import-invoices nil
|
||||
:unpaid-invoices :unpaid
|
||||
:paid-invoices :paid
|
||||
:voided-invoices :voided)}
|
||||
[[:invoices [:id :total :outstanding-balance :invoice-number :date :due :status :client-identifier :automatically-paid-when-due
|
||||
[:vendor [:name :id]]
|
||||
[:expense_accounts [:amount :id :location
|
||||
@@ -35,24 +51,7 @@
|
||||
:start
|
||||
:end]]]})
|
||||
|
||||
(re-frame/reg-sub
|
||||
::specific-table-params
|
||||
(fn [db]
|
||||
(::table-params db)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::table-params
|
||||
:<- [::specific-table-params]
|
||||
:<- [::subs/query-params]
|
||||
(fn [[specific-table-params query-params]]
|
||||
(update (merge (select-keys query-params #{:start :sort}) specific-table-params )
|
||||
:sort seq)))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::params-changed
|
||||
[(re-frame/path [::table-params])]
|
||||
(fn [{table-params :db} [_ params :as z]]
|
||||
{:db (merge table-params params)}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::void-invoice
|
||||
@@ -92,7 +91,7 @@
|
||||
(fn [{:keys [db]} [_ invoice]]
|
||||
{:db db}))
|
||||
|
||||
(defn row [{:keys [invoice check-boxes checked selected-client overrides expense-event actions]}]
|
||||
(defn row [{:keys [invoice check-boxes selected-client overrides expense-event actions]}]
|
||||
(let [{:keys [client payments expense-accounts invoice-number date due total outstanding-balance id vendor checkable?] :as i} invoice
|
||||
accounts-by-id @(re-frame/subscribe [::subs/accounts-by-id client])
|
||||
account->name #(:name (accounts-by-id (:id %)))]
|
||||
@@ -180,12 +179,13 @@
|
||||
[buttons/fa-icon {:icon "fa-undo"
|
||||
:event [::unvoid-invoice i]}])]]]))
|
||||
|
||||
(defn invoice-table [{:keys [id data checked status check-boxes on-check-changed overrides actions]}]
|
||||
(defn invoice-table [{:keys [id check-boxes overrides actions data-page]}]
|
||||
(let [selected-client @(re-frame/subscribe [::subs/client])
|
||||
{:keys [sort]} @(re-frame/subscribe [::table-params])
|
||||
{:keys [data status table-params]} @(re-frame/subscribe [::data-page/page data-page])
|
||||
|
||||
selected-client @(re-frame/subscribe [::subs/client])
|
||||
is-loading? (= :loading (:state status))
|
||||
is-sorted-by-vendor? (and (= "vendor" (:sort-key (first sort)))
|
||||
is-sorted-by-vendor? (and (= "vendor" (:sort-key (first (:sort table-params))))
|
||||
(not is-loading?)
|
||||
(or (apply <= (map (comp :name :vendor) (:data data)))
|
||||
(apply >= (map (comp :name :vendor) (:data data)))))
|
||||
@@ -202,12 +202,7 @@
|
||||
[[] nil]
|
||||
(:data data))
|
||||
[[(:data data)]])]
|
||||
[grid/grid {:on-params-change (fn [p]
|
||||
(re-frame/dispatch [::params-changed p]))
|
||||
:on-check-changed on-check-changed
|
||||
:params @(re-frame/subscribe [::table-params])
|
||||
:checked checked
|
||||
:status status
|
||||
[grid/grid {:data-page data-page
|
||||
:check-boxes? check-boxes
|
||||
:column-count (if selected-client 8 9)}
|
||||
[grid/controls data
|
||||
|
||||
Reference in New Issue
Block a user