Simplifying filters
This commit is contained in:
@@ -36,102 +36,110 @@
|
||||
:on-success [::editing-matches-found which]
|
||||
:on-error [::editing-matches-failed which]}} ))
|
||||
|
||||
(defn table [{:keys [id transaction-page status on-params-change vendors params check-boxes checked on-check-changed expense-event]}]
|
||||
(let [opc (fn [p]
|
||||
(on-params-change (merge @params p )))]
|
||||
(fn [{:keys [id transaction-page status on-params-change vendors checked]}]
|
||||
(let [{:keys [sort]} @params
|
||||
{:keys [transactions start end count total]} @transaction-page
|
||||
selected-client @(re-frame/subscribe [::subs/client])
|
||||
percentage-size (if selected-client "25%" "33%")]
|
||||
[:div
|
||||
[:div.level
|
||||
[:div.level-left
|
||||
[:div.level-item
|
||||
[paginator {:start start :end end :count count :total total
|
||||
:on-change (fn [p ]
|
||||
(on-params-change (merge @params p)))}]]
|
||||
[:div.level-item
|
||||
[sort-by-list {:sort sort
|
||||
:on-change opc}]]]]
|
||||
|
||||
|
||||
[:table.table.is-fullwidth
|
||||
[:thead
|
||||
[:tr
|
||||
(re-frame/reg-sub
|
||||
::table-params
|
||||
(fn [db]
|
||||
(::table-params db)))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::params-changed
|
||||
[(re-frame/path [::table-params])]
|
||||
(fn [{table-params :db} [_ params :as z]]
|
||||
{:db (merge table-params params)
|
||||
:dispatch [:auto-ap.views.pages.transactions/params-change]}))
|
||||
|
||||
(defn table [{:keys [id transaction-page status]}]
|
||||
(let [{:keys [sort]} @(re-frame/subscribe [::table-params])
|
||||
{:keys [transactions start end count total]} @transaction-page
|
||||
opc (fn [e] (re-frame/dispatch [::params-changed e]))
|
||||
selected-client @(re-frame/subscribe [::subs/client])
|
||||
percentage-size (if selected-client "25%" "33%")]
|
||||
[: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
|
||||
(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 "8em" :cursor "pointer"}
|
||||
:sort-key "date"
|
||||
:sort-name "Date"
|
||||
:sort sort}
|
||||
"Date"]
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width "8em" :cursor "pointer"}
|
||||
:sort-key "amount"
|
||||
:sort-name "Amount"
|
||||
:class "has-text-right"
|
||||
:sort sort}
|
||||
"Amount"]
|
||||
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width "8em" :cursor "pointer"}
|
||||
:sort-key "status"
|
||||
:sort-name "Status"
|
||||
:sort sort}
|
||||
"Status"]
|
||||
[:th {:width percentage-size} "Bank account"]
|
||||
[:th {:style {:width "14em"}} "" ]]]
|
||||
[:tbody
|
||||
(if (:loading @status)
|
||||
[:tr
|
||||
[:td {:col-span 5}
|
||||
[:i.fa.fa-spin.fa-spinner]]]
|
||||
(for [{:keys [client account vendor approval-status payment status bank-account description-original date amount id yodlee-merchant ] :as i} (:transactions @transaction-page)]
|
||||
^{:key id}
|
||||
[:tr {:class (:class i)}
|
||||
(when-not selected-client
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width percentage-size :cursor "pointer"}
|
||||
:sort-key "client"
|
||||
:sort-name "Client"
|
||||
:sort sort}
|
||||
"Client"])
|
||||
[:td (:name client)])
|
||||
[:td (cond vendor
|
||||
(:name vendor)
|
||||
yodlee-merchant
|
||||
[:i.has-text-grey (str "Merchant '" (:name yodlee-merchant) "'")]
|
||||
|
||||
[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 "8em" :cursor "pointer"}
|
||||
:sort-key "date"
|
||||
:sort-name "Date"
|
||||
:sort sort}
|
||||
"Date"]
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width "8em" :cursor "pointer"}
|
||||
:sort-key "amount"
|
||||
:sort-name "Amount"
|
||||
:class "has-text-right"
|
||||
:sort sort}
|
||||
"Amount"]
|
||||
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width "8em" :cursor "pointer"}
|
||||
:sort-key "status"
|
||||
:sort-name "Status"
|
||||
:sort sort}
|
||||
"Status"]
|
||||
[:th {:width percentage-size} "Bank account"]
|
||||
[:th {:style {:width "14em"}} "" ]]]
|
||||
[:tbody
|
||||
(if (:loading @status)
|
||||
[:tr
|
||||
[:td {:col-span 5}
|
||||
[:i.fa.fa-spin.fa-spinner]]]
|
||||
(for [{:keys [client account vendor approval-status payment status bank-account description-original date amount id yodlee-merchant ] :as i} (:transactions @transaction-page)]
|
||||
^{:key id}
|
||||
[:tr {:class (:class i)}
|
||||
(when-not selected-client
|
||||
[:td (:name client)])
|
||||
[:td (cond vendor
|
||||
(:name vendor)
|
||||
yodlee-merchant
|
||||
[:i.has-text-grey (str "Merchant '" (:name yodlee-merchant) "'")]
|
||||
|
||||
:else
|
||||
[:i.has-text-grey (str description-original)])]
|
||||
#_[:td description-original]
|
||||
[:td (date->str date) ]
|
||||
[:td.has-text-right (nf amount )]
|
||||
[:td status]
|
||||
[:td (:name bank-account )]
|
||||
[:td.expandable
|
||||
[:div.buttons
|
||||
[drop-down {:id [::expense-accounts id ]
|
||||
:header [:a.button {:aria-haspopup true
|
||||
:on-click (dispatch-event [::events/toggle-menu [::expense-accounts id]])
|
||||
:tab-index "0"}
|
||||
[:span.icon-saving-bank-1]]}
|
||||
[drop-down-contents
|
||||
[:div
|
||||
[:span.dropdown-item description-original ]]]]
|
||||
[:a.button {:on-click (dispatch-event [::intend-to-edit i])} [:span [:span.icon [:i.fa.fa-pencil]]]]
|
||||
(when payment
|
||||
[:a.tag {:href (:s3-url payment) :target "_new"}
|
||||
#_[:i.fa.fa-money-check]
|
||||
[:span.icon [:i.fa.fa-money]]
|
||||
(str " " (:check-number payment) " (" (gstring/format "$%.2f" amount ) ")")])]]
|
||||
]))]]]))))
|
||||
:else
|
||||
[:i.has-text-grey (str description-original)])]
|
||||
#_[:td description-original]
|
||||
[:td (date->str date) ]
|
||||
[:td.has-text-right (nf amount )]
|
||||
[:td status]
|
||||
[:td (:name bank-account )]
|
||||
[:td.expandable
|
||||
[:div.buttons
|
||||
[drop-down {:id [::expense-accounts id ]
|
||||
:header [:a.button {:aria-haspopup true
|
||||
:on-click (dispatch-event [::events/toggle-menu [::expense-accounts id]])
|
||||
:tab-index "0"}
|
||||
[:span.icon-saving-bank-1]]}
|
||||
[drop-down-contents
|
||||
[:div
|
||||
[:span.dropdown-item description-original ]]]]
|
||||
[:a.button {:on-click (dispatch-event [::intend-to-edit i])} [:span [:span.icon [:i.fa.fa-pencil]]]]
|
||||
(when payment
|
||||
[:a.tag {:href (:s3-url payment) :target "_new"}
|
||||
#_[:i.fa.fa-money-check]
|
||||
[:span.icon [:i.fa.fa-money]]
|
||||
(str " " (:check-number payment) " (" (gstring/format "$%.2f" amount ) ")")])]]
|
||||
]))]]]))
|
||||
|
||||
Reference in New Issue
Block a user