first step of page abstraction.

This commit is contained in:
Bryce Covert
2020-08-16 17:40:45 -07:00
parent 0c87309c34
commit 001c66547c
10 changed files with 410 additions and 281 deletions

View File

@@ -175,16 +175,15 @@
[buttons/fa-icon {:icon "fa-undo"
:event [::unvoid-invoice i]}])]]]))
(defn invoice-table [{:keys [id invoice-page status vendors check-boxes on-check-changed expense-event overrides]}]
(defn invoice-table [{:keys [id data checked status vendors check-boxes on-check-changed expense-event overrides]}]
(let [selected-client @(re-frame/subscribe [::subs/client])
{:keys [sort]} @(re-frame/subscribe [::table-params])
{:keys [invoices outstanding]} invoice-page
selected-client @(re-frame/subscribe [::subs/client])
is-loading? (= :loading (:state status))
is-sorted-by-vendor? (and (= "vendor" (:sort-key (first sort)))
(not is-loading?)
(or (apply <= (map (comp :name :vendor) (:invoices invoice-page)))
(apply >= (map (comp :name :vendor) (:invoices invoice-page)))))
(or (apply <= (map (comp :name :vendor) (:data data)))
(apply >= (map (comp :name :vendor) (:data data)))))
[invoice-groups] (if is-sorted-by-vendor?
(reduce
@@ -196,19 +195,19 @@
[(update-in acc [(dec (clojure.core/count acc))] #(conj (or % []) invoice))
(:id (:vendor invoice))]))
[[] nil]
(:invoices invoice-page))
[[(:invoices invoice-page)]])]
(: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 invoice-page)
:checked checked
:status status
:check-boxes? check-boxes
:column-count (if selected-client 7 8)}
[grid/controls invoice-page
[grid/controls data
[:div.level-item
"Outstanding " (nf outstanding)]]
"Outstanding " (nf (:outstanding data))]]
(for [invoices invoice-groups]
^{:key (or (:id (first invoices)) "init")}
[grid/table {:fullwidth true}