first step of page abstraction.
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -102,7 +102,10 @@
|
||||
[:button.delete {:on-click (dispatch-event [::modal-closed])}]]
|
||||
[:section.modal-card-body
|
||||
body]
|
||||
(let [status (some-> confirm :status-from re-frame/subscribe deref )]
|
||||
(let [status (some-> confirm :status-from re-frame/subscribe deref )
|
||||
can-submit (if-let [can-submit (-> confirm :can-submit)]
|
||||
@(re-frame/subscribe can-submit)
|
||||
true)]
|
||||
(if foot
|
||||
[:footer.modal-card-foot
|
||||
[appearing {:visible? (= :error (:state status))
|
||||
@@ -122,7 +125,11 @@
|
||||
[:div.buttons
|
||||
(when confirm
|
||||
[:button.button {:class (conj (status/class-for status) (:class confirm) )
|
||||
:disabled (if can-submit
|
||||
false
|
||||
true)
|
||||
:on-click (:on-click confirm)}
|
||||
(:value confirm)])
|
||||
(when cancel?
|
||||
[:button.button {:on-click (dispatch-event [::modal-closed] )} "Cancel"])]]]))]])))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user