uses context, better loading experience
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
[auto-ap.views.components.sort-by-list :refer [sort-by-list]]
|
||||
[auto-ap.views.pages.admin.rules.results-modal :as results-modal]
|
||||
[auto-ap.views.components.sorter :refer [sorted-column toggle-sort-by sort-icon]]
|
||||
[auto-ap.views.components.grid :refer [grid]]
|
||||
[auto-ap.views.components.grid :as grid]
|
||||
[re-frame.core :as re-frame]
|
||||
[reagent.core :as reagent]
|
||||
[reagent.core :as r]))
|
||||
@@ -57,67 +57,58 @@
|
||||
|
||||
|
||||
(defn table [{:keys [id rule-page on-params-change params status]}]
|
||||
(let [opc (fn [p]
|
||||
(re-frame/dispatch [::params-changed p]))
|
||||
{:keys [table-sortable-header-cell
|
||||
table
|
||||
table-header
|
||||
table-row
|
||||
table-header-cell
|
||||
table-body
|
||||
table-cell
|
||||
grid-container]}
|
||||
(grid {:on-params-change opc
|
||||
:params (re-frame/subscribe [::table-params])
|
||||
:status status
|
||||
:column-count 5})]
|
||||
(fn [{:keys [id rule-page on-params-change params status]}]
|
||||
(let [{:keys [sort asc]} @params
|
||||
{:keys [transaction-rules start end count total]} @rule-page
|
||||
selected-client @(re-frame/subscribe [::subs/client])]
|
||||
[grid-container {:start start :end end :count count :total total}
|
||||
[table {:fullwidth true }
|
||||
[table-header
|
||||
[table-row {}
|
||||
[table-sortable-header-cell {:sort-key "client"
|
||||
:sort-name "Client"}
|
||||
"Client"]
|
||||
(let [{:keys [sort asc]} @params
|
||||
{:keys [transaction-rules start end count total]} @rule-page
|
||||
selected-client @(re-frame/subscribe [::subs/client])
|
||||
opc (fn [p]
|
||||
(re-frame/dispatch [::params-changed p]))]
|
||||
[grid/grid {:on-params-change opc
|
||||
:params @(re-frame/subscribe [::table-params])
|
||||
:status @status
|
||||
:column-count 6}
|
||||
[grid/controls {:start start :end end :count count :total total}]
|
||||
[grid/table {:fullwidth true }
|
||||
[grid/header
|
||||
[grid/row {}
|
||||
[grid/sortable-header-cell {:sort-key "client"
|
||||
:sort-name "Client"}
|
||||
"Client"]
|
||||
|
||||
[table-sortable-header-cell {:sort-key "bank-account"
|
||||
:sort-name "Bank Account"}
|
||||
"Bank Account"]
|
||||
[grid/sortable-header-cell {:sort-key "bank-account"
|
||||
:sort-name "Bank Account"}
|
||||
"Bank Account"]
|
||||
|
||||
[table-sortable-header-cell {:sort-key "description"
|
||||
:sort-name "Description"}
|
||||
"Description"]
|
||||
[grid/sortable-header-cell {:sort-key "description"
|
||||
:sort-name "Description"}
|
||||
"Description"]
|
||||
|
||||
[table-header-cell {:style {:width "12em"}} "Amount"]
|
||||
[grid/header-cell {:style {:width "12em"}} "Amount"]
|
||||
|
||||
[table-sortable-header-cell {:sort-key "note"
|
||||
:sort-name "Note"}
|
||||
"Note"]
|
||||
[grid/sortable-header-cell {:sort-key "note"
|
||||
:sort-name "Note"}
|
||||
"Note"]
|
||||
|
||||
[table-header-cell {:style {:width "9em"}}]]]
|
||||
[table-body
|
||||
(for [{:keys [client bank-account description amount-lte amount-gte note id] :as r} transaction-rules]
|
||||
^{:key id}
|
||||
[table-row {:class (:class r)}
|
||||
[table-cell {} (:name client)]
|
||||
[table-cell {} (:name bank-account)]
|
||||
[table-cell {} description]
|
||||
[table-cell {:class "has-text-right"}
|
||||
(cond (and amount-gte amount-lte)
|
||||
(str (->$ amount-gte) " - " (->$ amount-lte))
|
||||
[grid/header-cell {}]]]
|
||||
[grid/body
|
||||
(for [{:keys [client bank-account description amount-lte amount-gte note id] :as r} transaction-rules]
|
||||
^{:key id}
|
||||
[grid/row {:class (:class r)}
|
||||
[grid/cell {} (:name client)]
|
||||
[grid/cell {} (:name bank-account)]
|
||||
[grid/cell {} description]
|
||||
[grid/cell {:class "has-text-right"}
|
||||
(cond (and amount-gte amount-lte)
|
||||
(str (->$ amount-gte) " - " (->$ amount-lte))
|
||||
|
||||
amount-gte
|
||||
(str ">=" (->$ amount-gte))
|
||||
amount-gte
|
||||
(str ">=" (->$ amount-gte))
|
||||
|
||||
amount-lte
|
||||
(str "<=" (->$ amount-lte))
|
||||
amount-lte
|
||||
(str "<=" (->$ amount-lte))
|
||||
|
||||
:else
|
||||
"")]
|
||||
[table-cell {} note]
|
||||
[table-cell {} [:div.buttons
|
||||
[:a.button {:on-click (dispatch-event [::run-clicked r])} [:span.icon [:i.fa.fa-play]]]
|
||||
[:a.button {:on-click (dispatch-event [::form/editing r])} [:span.icon [:i.fa.fa-pencil]]]]]])]]]))))
|
||||
:else
|
||||
"")]
|
||||
[grid/cell {} note]
|
||||
[grid/cell {} [:div.buttons
|
||||
[:a.button {:on-click (dispatch-event [::run-clicked r])} [:span.icon [:i.fa.fa-play]]]
|
||||
[:a.button {:on-click (dispatch-event [::form/editing r])} [:span.icon [:i.fa.fa-pencil]]]]]])]]]))
|
||||
|
||||
Reference in New Issue
Block a user