not sure if this is a good idea.
This commit is contained in:
@@ -164,7 +164,21 @@
|
|||||||
visible-checks @(re-frame/subscribe [::visible-checks])
|
visible-checks @(re-frame/subscribe [::visible-checks])
|
||||||
visible-expense-accounts @(re-frame/subscribe [::visible-expense-accounts])
|
visible-expense-accounts @(re-frame/subscribe [::visible-expense-accounts])
|
||||||
selected-client @(re-frame/subscribe [::subs/client])
|
selected-client @(re-frame/subscribe [::subs/client])
|
||||||
percentage-size (if selected-client "%50%" "33%")]
|
percentage-size (if selected-client "%50%" "33%")
|
||||||
|
is-sorted-by-vendor? (seq (filter #(= "vendor" (:sort-key %)) sort))
|
||||||
|
_ (println is-sorted-by-vendor? sort)
|
||||||
|
[invoice-groups] (if is-sorted-by-vendor?
|
||||||
|
(reduce
|
||||||
|
(fn [[acc last-vendor] invoice]
|
||||||
|
(if (not= (:id (:vendor invoice))
|
||||||
|
last-vendor)
|
||||||
|
[(update-in acc [(clojure.core/count acc)] #(conj (or % []) invoice))
|
||||||
|
(:id (:vendor invoice))]
|
||||||
|
[(update-in acc [(dec (clojure.core/count acc))] #(conj (or % []) invoice))
|
||||||
|
(:id (:vendor invoice))]))
|
||||||
|
[[] nil]
|
||||||
|
(:invoices @invoice-page))
|
||||||
|
[[(:invoices @invoice-page)]])]
|
||||||
[:div
|
[:div
|
||||||
[:div.level
|
[:div.level
|
||||||
[:div.level-left
|
[:div.level-left
|
||||||
@@ -174,86 +188,89 @@
|
|||||||
[:div.level-item
|
[:div.level-item
|
||||||
[sort-by-list {:sort sort
|
[sort-by-list {:sort sort
|
||||||
:on-change opc}]]]]
|
:on-change opc}]]]]
|
||||||
[:table.table.is-fullwidth
|
(doall
|
||||||
[:thead
|
(for [invoices invoice-groups]
|
||||||
[:tr
|
^{:key (:id (first invoices))}
|
||||||
(when check-boxes
|
[:table.table.is-fullwidth
|
||||||
[:th {:style {"width" "20px"}}])
|
[:thead
|
||||||
(when-not selected-client
|
[:tr
|
||||||
[sorted-column {:on-sort opc
|
(when check-boxes
|
||||||
:style {:width percentage-size :cursor "pointer"}
|
[:th {:style {"width" "20px"}}])
|
||||||
:sort-name "Client"
|
(when-not selected-client
|
||||||
:sort-key "client"
|
[sorted-column {:on-sort opc
|
||||||
:sort sort}
|
:style {:width percentage-size :cursor "pointer"}
|
||||||
"Client"])
|
:sort-name "Client"
|
||||||
[sorted-column {:on-sort opc
|
:sort-key "client"
|
||||||
:style {:width percentage-size :cursor "pointer"}
|
:sort sort}
|
||||||
:sort-name "Vendor"
|
"Client"])
|
||||||
:sort-key "vendor"
|
[sorted-column {:on-sort opc
|
||||||
:sort sort}
|
:style {:width percentage-size :cursor "pointer"}
|
||||||
"Vendor"]
|
:sort-name "Vendor"
|
||||||
[sorted-column {:on-sort opc
|
:sort-key "vendor"
|
||||||
:style {:width percentage-size :cursor "pointer"}
|
:sort sort}
|
||||||
:sort-name "Invoice Number"
|
"Vendor"]
|
||||||
:sort-key "invoice-number"
|
[sorted-column {:on-sort opc
|
||||||
:sort sort}
|
:style {:width percentage-size :cursor "pointer"}
|
||||||
"Invoice #"]
|
:sort-name "Invoice Number"
|
||||||
[sorted-column {:on-sort opc
|
:sort-key "invoice-number"
|
||||||
:style {:width "8em" :cursor "pointer"}
|
:sort sort}
|
||||||
:sort-name "Date"
|
"Invoice #"]
|
||||||
:sort-key "date"
|
[sorted-column {:on-sort opc
|
||||||
:sort sort}
|
:style {:width "8em" :cursor "pointer"}
|
||||||
"Date"]
|
:sort-name "Date"
|
||||||
[sorted-column {:on-sort opc
|
:sort-key "date"
|
||||||
:style {:width "8em" :cursor "pointer"}
|
:sort sort}
|
||||||
:sort-name "Due"
|
"Date"]
|
||||||
:sort-key "due"
|
[sorted-column {:on-sort opc
|
||||||
:sort sort}
|
:style {:width "8em" :cursor "pointer"}
|
||||||
"Due"]
|
:sort-name "Due"
|
||||||
[sorted-column {:on-sort opc
|
:sort-key "due"
|
||||||
:style {:width "5em" :cursor "pointer"}
|
:sort sort}
|
||||||
:sort-name "Location"
|
"Due"]
|
||||||
:sort-key "location"
|
[sorted-column {:on-sort opc
|
||||||
:sort sort}
|
:style {:width "5em" :cursor "pointer"}
|
||||||
"Loc"]
|
:sort-name "Location"
|
||||||
[sorted-column {:on-sort opc
|
:sort-key "location"
|
||||||
:style {:width "8em" :cursor "pointer"}
|
:sort sort}
|
||||||
:sort-name "Total"
|
"Loc"]
|
||||||
:sort-key "total"
|
[sorted-column {:on-sort opc
|
||||||
:class "has-text-right"
|
:style {:width "8em" :cursor "pointer"}
|
||||||
:sort sort}
|
:sort-name "Total"
|
||||||
"Amount"]
|
:sort-key "total"
|
||||||
|
:class "has-text-right"
|
||||||
|
:sort sort}
|
||||||
|
"Amount"]
|
||||||
|
|
||||||
[sorted-column {:on-sort opc
|
[sorted-column {:on-sort opc
|
||||||
:style {:width "10em" :cursor "pointer"}
|
:style {:width "10em" :cursor "pointer"}
|
||||||
:sort-name "Outstanding"
|
:sort-name "Outstanding"
|
||||||
:sort-key "outstanding-balance"
|
:sort-key "outstanding-balance"
|
||||||
:class "has-text-right"
|
:class "has-text-right"
|
||||||
:sort sort}
|
:sort sort}
|
||||||
"Outstanding"]
|
"Outstanding"]
|
||||||
|
|
||||||
[:th {
|
[:th {
|
||||||
:style {:width "20rem" :cursor "pointer"}
|
:style {:width "20rem" :cursor "pointer"}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
""]]]
|
""]]]
|
||||||
[:tbody
|
[:tbody
|
||||||
|
|
||||||
(if (:loading @status)
|
(if (:loading @status)
|
||||||
[:tr
|
[:tr
|
||||||
[:td {:col-span 5}
|
[:td {:col-span 5}
|
||||||
[:i.fa.fa-spin.fa-spinner]]]
|
[:i.fa.fa-spin.fa-spinner]]]
|
||||||
|
|
||||||
(for [{:keys [client payments expense-accounts invoice-number date due total outstanding-balance id vendor] :as i} (:invoices @invoice-page)]
|
(for [{:keys [client payments expense-accounts invoice-number date due total outstanding-balance id vendor] :as i} invoices]
|
||||||
^{:key id}
|
^{:key id}
|
||||||
[row {:invoice i
|
[row {:invoice i
|
||||||
:check-boxes check-boxes
|
:check-boxes check-boxes
|
||||||
:checked checked
|
:checked checked
|
||||||
:on-check-changed on-check-changed
|
:on-check-changed on-check-changed
|
||||||
:selected-client selected-client
|
:selected-client selected-client
|
||||||
:overrides overrides
|
:overrides overrides
|
||||||
:expense-event expense-event
|
:expense-event expense-event
|
||||||
:on-edit-invoice on-edit-invoice
|
:on-edit-invoice on-edit-invoice
|
||||||
:on-void-invoice on-void-invoice
|
:on-void-invoice on-void-invoice
|
||||||
:on-unvoid-invoice on-unvoid-invoice}]))]]]))
|
:on-unvoid-invoice on-unvoid-invoice}]))]]))]))
|
||||||
|
|||||||
Reference in New Issue
Block a user