partway through transaction rules
This commit is contained in:
@@ -54,8 +54,8 @@
|
||||
:else
|
||||
y))
|
||||
|
||||
(defn paginator [{:keys [start end count total on-change]}]
|
||||
(let [per-page default-pagination-size
|
||||
(defn paginator [{:keys [start per-page end count total on-change] :as g}]
|
||||
(let [per-page (or per-page default-pagination-size)
|
||||
max-buttons 5
|
||||
buttons-before (Math/floor (/ max-buttons 2))
|
||||
total-pages (Math/max 1 (Math/ceil (/ total per-page)))
|
||||
@@ -66,7 +66,8 @@
|
||||
[:li
|
||||
[:a.pagination-link {:class (when (= current-page x)
|
||||
"is-current")
|
||||
:on-click (fn [e] (on-change {:start (* x per-page)}))}
|
||||
:on-click (fn [e] (on-change {:start (* x per-page)
|
||||
:per-page per-page}))}
|
||||
(inc x)]]))
|
||||
|
||||
|
||||
@@ -88,7 +89,14 @@
|
||||
extended-first-page-button
|
||||
(apply list (subvec all-buttons first-page-button last-page-button))
|
||||
extended-last-page-button
|
||||
"Showing " (Math/min (inc start) total) "-" end "/" total]]))
|
||||
[:span.mx-4 (Math/min (inc start) total) "-" end "/" total]
|
||||
[:div.select
|
||||
[:select {:value per-page :on-change (fn [e] (on-change {:start 0
|
||||
:per-page (js/parseInt (.. e -target -value ))}))}
|
||||
[:option {:value 20 } "20 per page" ]
|
||||
[:option {:value 50} "50 per page" ]
|
||||
[:option {:value 100} "100 per page" ]
|
||||
[:option {:value 200} "200 per page" ]]]]]))
|
||||
|
||||
(defn sort-by-list [{:keys [sort on-change]}]
|
||||
[:div.field.is-grouped.is-grouped-multiline
|
||||
@@ -103,7 +111,7 @@
|
||||
[:a.tag.is-medium.is-delete {:on-click (fn []
|
||||
(on-change {:sort (filter #(not= sort-key (:sort-key %)) sort)}))}]]])])
|
||||
|
||||
(defn controls [{:keys [start end count total] :as para}]
|
||||
(defn controls [{:keys [start end count total per-page] :as para}]
|
||||
(let [children (r/children (r/current-component))]
|
||||
[:> Consumer {}
|
||||
(fn [consume]
|
||||
@@ -115,6 +123,7 @@
|
||||
[:div.level-left
|
||||
[:div.level-item
|
||||
[paginator {:start start :end end :count count :total total
|
||||
:per-page (:per-page params)
|
||||
:on-change on-params-change}]]
|
||||
[:div.level-item
|
||||
[sort-by-list {:sort (:sort params)
|
||||
@@ -156,16 +165,17 @@
|
||||
"checked"
|
||||
"")
|
||||
:on-change (fn [x e]
|
||||
(let [checked (or checked #{})]
|
||||
;; TODO only map once everything is moved over to data-page
|
||||
(if (map? checked)
|
||||
(if (get checked id)
|
||||
(on-check-changed (dissoc checked id))
|
||||
(on-check-changed (assoc checked id entity)))
|
||||
(if id
|
||||
(let [checked (or checked #{})]
|
||||
;; TODO only map once everything is moved over to data-page
|
||||
(if (map? checked)
|
||||
(if (get checked id)
|
||||
(on-check-changed (dissoc checked id))
|
||||
(on-check-changed (assoc checked id entity)))
|
||||
|
||||
(if (get checked id)
|
||||
(on-check-changed (disj checked id))
|
||||
(on-check-changed (conj checked id))))))}
|
||||
(if (get checked id)
|
||||
(on-check-changed (disj checked id))
|
||||
(on-check-changed (conj checked id)))))))}
|
||||
(boolean? checkable?) (assoc :disabled (not checkable?))) ]]))
|
||||
|
||||
(map r/as-element children))))]))
|
||||
@@ -258,10 +268,10 @@
|
||||
[:<> ]
|
||||
(r/children (r/current-component)))))))
|
||||
|
||||
(defn virtual-paginate [start xs ]
|
||||
(take default-pagination-size (drop (or start 0) xs)))
|
||||
(defn virtual-paginate [start per-page xs ]
|
||||
(take (or per-page default-pagination-size) (drop (or start 0) xs)))
|
||||
|
||||
(defn virtual-paginate-controls [start xs]
|
||||
{:start (or start 0) :end (min (+ (or start 0) default-pagination-size)
|
||||
(defn virtual-paginate-controls [start per-page xs ]
|
||||
{:start (or start 0) :end (min (+ (or start 0) (or per-page default-pagination-size))
|
||||
(count xs))
|
||||
:total (count xs)})
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
{
|
||||
:start (:start params 0)
|
||||
:sort (:sort params)
|
||||
:per-page (:per-page params)
|
||||
|
||||
:vendor-id (:id (:vendor params))
|
||||
:date-range (:date-range params)
|
||||
|
||||
Reference in New Issue
Block a user