payments use new grid. Still need to update void button
This commit is contained in:
@@ -11,7 +11,9 @@
|
||||
[auto-ap.views.components.dropdown :refer [drop-down drop-down-contents]]
|
||||
[auto-ap.events :as events]
|
||||
[goog.string :as gstring]
|
||||
[re-frame.core :as re-frame]))
|
||||
[re-frame.core :as re-frame]
|
||||
[auto-ap.views.components.grid :as grid]
|
||||
[auto-ap.views.components.buttons :as buttons]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::specific-table-params
|
||||
@@ -36,27 +38,27 @@
|
||||
void-event :void-event
|
||||
}]
|
||||
(let [{:keys [client s3-url bank-account payments type check-number date amount id vendor status invoices] :as check} check]
|
||||
[:tr {:class (:class check)}
|
||||
[grid/row {:class (:class check)}
|
||||
(when-not selected-client
|
||||
[:td (:name client)])
|
||||
[:td (:name vendor)]
|
||||
[:td (:name bank-account)]
|
||||
[:td (cond
|
||||
[grid/cell {} (:name client)])
|
||||
[grid/cell {} (:name vendor)]
|
||||
[grid/cell {} (:name bank-account)]
|
||||
[grid/cell {} (cond
|
||||
(= :cash type) "Cash"
|
||||
(= :debit type) "Debit"
|
||||
:else (if s3-url
|
||||
[:a {:href s3-url :target "_new"} [:a.button [:span.icon [:i.fa.fa-share-square-o]]
|
||||
[:span (str " " check-number )]]]
|
||||
check-number))]
|
||||
[:td (date->str date) ]
|
||||
[:td.has-text-right (nf amount )]
|
||||
[:td status]
|
||||
[:td.expandable
|
||||
[:div.buttons
|
||||
[grid/cell {} (date->str date) ]
|
||||
[grid/cell {:class "has-text-right"} (nf amount )]
|
||||
[grid/cell {} status]
|
||||
[grid/cell {:style {:overflow "visible"}}
|
||||
[:div.buttons
|
||||
(when (seq invoices)
|
||||
[drop-down {:id [::invoices id]
|
||||
:header [:button.button.badge {:data-badge (str (clojure.core/count invoices))
|
||||
:aria-haspopup true
|
||||
:aria-haspopup true?
|
||||
:tab-index "0"
|
||||
:on-click (dispatch-event [::events/toggle-menu [::invoices id]])
|
||||
} "Invoices"]}
|
||||
@@ -75,82 +77,32 @@
|
||||
(when (or (= :pending status)
|
||||
(and (#{":cash" :cash ":debit" :debit} type)
|
||||
(not= :voided status)))
|
||||
[:button.button.is-warning.is-outlined {:on-click (dispatch-event (conj void-event check))} [:span [:span.icon [:i.fa.fa-minus-circle]]]])]]]))
|
||||
[buttons/sl-icon {:event (conj void-event check) :icon :icon-bin-2}])]]]))
|
||||
|
||||
(defn table [{:keys [id payment-page status void-event]}]
|
||||
(let [{:keys [sort]} @(re-frame/subscribe [::table-params])
|
||||
{:keys [payments start end count total]} @payment-page
|
||||
selected-client @(re-frame/subscribe [::subs/client])
|
||||
percentage-size (if selected-client "50%" "33%")
|
||||
opc (fn [e]
|
||||
(re-frame/dispatch [::params-changed e]))]
|
||||
[:div
|
||||
[:div.level
|
||||
[:div.level-left
|
||||
[:div.level-item
|
||||
[paginator {:start start :end end :count count :total total
|
||||
:on-change opc}]]
|
||||
[:div.level-item
|
||||
[sort-by-list {:sort sort
|
||||
:on-change opc}]]]]
|
||||
|
||||
[:table.table.is-fullwidth
|
||||
[:thead
|
||||
[:tr
|
||||
(let [selected-client @(re-frame/subscribe [::subs/client])
|
||||
percentage-size (if selected-client "50%" "33%")]
|
||||
[grid/grid {:on-params-change (fn [e]
|
||||
(re-frame/dispatch [::params-changed e]))
|
||||
:params @(re-frame/subscribe [::table-params])
|
||||
:status status
|
||||
:column-count (if selected-client 7 8)}
|
||||
[grid/controls payment-page]
|
||||
[grid/table {:fullwidth true}
|
||||
[grid/header {}
|
||||
[grid/row {}
|
||||
(when-not selected-client
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width percentage-size :cursor "pointer"}
|
||||
:sort-key "client"
|
||||
:sort-name "Client"
|
||||
:sort sort}
|
||||
"Client"])
|
||||
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width percentage-size :cursor "pointer"}
|
||||
:sort-key "vendor"
|
||||
:sort-name "Vendor"
|
||||
:sort sort}
|
||||
"Vendor"]
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width percentage-size :cursor "pointer"}
|
||||
:sort-key "bank-account"
|
||||
:sort-name "Bank Account"
|
||||
:sort sort}
|
||||
"Bank Account"]
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width percentage-size :cursor "pointer"}
|
||||
:sort-key "check-number"
|
||||
:sort-name "Check #"
|
||||
:sort sort}
|
||||
"Check #"]
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width "8em" :cursor "pointer"}
|
||||
:sort-key "date"
|
||||
:sort-name "Date"
|
||||
:sort sort}
|
||||
"Date"]
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width "8em" :cursor "pointer"}
|
||||
:class "has-text-right"
|
||||
:sort-key "amount"
|
||||
:sort-name "Amount"
|
||||
:sort sort}
|
||||
"Amount"]
|
||||
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width "8em" :cursor "pointer"}
|
||||
:sort-key "status"
|
||||
:sort-name "Status"
|
||||
:sort sort}
|
||||
"Status"]
|
||||
[:th {:style {:width "15em"}} "" ]]]
|
||||
[:tbody
|
||||
(if (:loading @status)
|
||||
[:tr
|
||||
[:td {:col-span 5}
|
||||
[:i.fa.fa-spin.fa-spinner]]]
|
||||
(for [check (:payments @payment-page)]
|
||||
^{:key (:id check)}
|
||||
[row {:check check
|
||||
:selected-client selected-client
|
||||
:void-event void-event}]))]]]))
|
||||
[grid/sortable-header-cell {:sort-key "client" :sort-name "Client"} "Client"])
|
||||
[grid/sortable-header-cell {:sort-key "vendor" :sort-name "Vendor"} "Vendor"]
|
||||
[grid/sortable-header-cell {:sort-key "bank-account" :sort-name "Bank Account"} "Bank Account"]
|
||||
[grid/sortable-header-cell {:sort-key "check-number" :sort-name "Check Number"} "Check Number"]
|
||||
[grid/sortable-header-cell {:sort-key "date" :sort-name "Date" :style {:width "8em"}} "Date"]
|
||||
[grid/sortable-header-cell {:sort-key "amount" :sort-name "Amount" :class "has-text-right" :style {:width "8em"}} "Amount"]
|
||||
[grid/sortable-header-cell {:sort-key "status" :sort-name "Status" :style {:width "7em"}} "Status"]
|
||||
[grid/header-cell {:style {:width "12em"}}]]]
|
||||
[grid/body
|
||||
(for [check (:payments payment-page)]
|
||||
^{:key (:id check)}
|
||||
[row {:check check
|
||||
:selected-client selected-client
|
||||
:void-event void-event}])]]]))
|
||||
|
||||
Reference in New Issue
Block a user