so many small tweaks due to the fact that the grid was slow.

This commit is contained in:
Bryce Covert
2020-08-12 09:18:59 -07:00
parent 5bc0e957ef
commit 255a73dc30
10 changed files with 192 additions and 161 deletions

View File

@@ -119,13 +119,12 @@
(mapv (fn [c]
[:div.level-item c]) children))]]))))]))
(defn table []
(r/create-class {:reagent-render
(fn [{:keys [fullwidth]}]
(into
[:table.table.compact.grid {:class (if fullwidth
["is-fullwidth"])}]
(r/children (r/current-component))))}))
(defn table [{:keys [fullwidth]}]
(into
[:table.table.compact.grid {:class (if fullwidth
["is-fullwidth"])}]
(r/children (r/current-component))))
(defn header []
(into
@@ -138,13 +137,17 @@
(r/children (r/current-component))))
(defn row [{:keys [class]}]
(into [:tr {:class class}]
(r/children (r/current-component))))
(apply r/create-element "tr" #js {:className class}
(map r/as-element (r/children (r/current-component)))))
(defn button-cell [params]
(apply r/create-element "td" #js {"style" #js {"overflow" "visible"}}
(map r/as-element (r/children (r/current-component)))))
(defn cell [params]
[:td params
(into [:span.test ]
(r/children (r/current-component)))])
(apply r/create-element "td" #js {}
(map r/as-element (r/children (r/current-component))))
)
(defn body []
(let [children (r/children (r/current-component))]
@@ -153,29 +156,28 @@
(let [{:strs [column-count status]} (js->clj consume)]
(r/as-element
(cond (= :loading (:state status))
[:tbody
(for [i (range 40)]
^{:key "loading-body"}
[:tbody.test
(for [i (range 20)]
^{:key i}
[:tr
(for [x (range column-count)]
^{:key x}
[:td #_{:col-span column-count}
[appearing {:visible? true
:timeout 1000
:enter-class "appear"
:exit-class "disappear"}
[:div.test
[:div.ph-item
[:div.ph-row
[:div.ph-col-12.big]]]]]])
])]
[:div
[:div.ph-item
[:div.ph-row
[:div.ph-col-12.big]]]]])])]
(= :error (:state status))
^{:key "error-body"}
[:tbody [:tr [:td.has-text-centered {:col-span column-count}
"An unexpected error has occured. "
(-> status :error first :message)
" Please try refreshing the page."]]]
:else
(into [:tbody]
(into ^{:key "main-body"}
[:tbody]
children)))))]))

View File

@@ -44,7 +44,8 @@
:<- [::specific-table-params]
:<- [::subs/query-params]
(fn [[specific-table-params query-params]]
(merge (select-keys query-params #{:start :sort}) specific-table-params )))
(update (merge (select-keys query-params #{:start :sort}) specific-table-params )
:sort seq)))
(re-frame/reg-event-fx
::params-changed
@@ -128,7 +129,7 @@
[grid/cell {:class "has-text-right"} (nf total )]
[grid/cell {:class "has-text-right"} (nf outstanding-balance )]
[grid/cell {:style {:overflow "visible"}}
[grid/button-cell {}
[:div.buttons
(when (seq expense-accounts)
[drop-down {:id [::expense-accounts id ]
@@ -188,9 +189,12 @@
{:keys [sort]} @(re-frame/subscribe [::table-params])
{:keys [invoices outstanding]} invoice-page
selected-client @(re-frame/subscribe [::subs/client])
is-loading? (= :loading status)
is-loading? (= :loading (:state status))
is-sorted-by-vendor? (and (= "vendor" (:sort-key (first sort)))
(not is-loading?))
(not is-loading?)
(or (apply <= (map (comp :name :vendor) (:invoices invoice-page)))
(apply >= (map (comp :name :vendor) (:invoices invoice-page)))))
[invoice-groups] (if is-sorted-by-vendor?
(reduce
(fn [[acc last-vendor] invoice]
@@ -203,7 +207,9 @@
[[] nil]
(:invoices invoice-page))
[[(:invoices invoice-page)]])]
^{:key (str @(re-frame/subscribe [::table-params]))}
[grid/grid {:on-params-change (fn [p]
(re-frame/dispatch [::params-changed p]))
:params @(re-frame/subscribe [::table-params])
:status status
@@ -242,7 +248,6 @@
[row {:invoice i
:check-boxes check-boxes
:checked checked
:on-check-changed on-check-changed
:selected-client selected-client
:overrides overrides
:expense-event expense-event}])]])]))