progress for sales
This commit is contained in:
@@ -44,17 +44,24 @@
|
||||
first
|
||||
:sort-icon))
|
||||
|
||||
(defn sort-by-list [sort]
|
||||
(defn sort-by-list [grid-spec sort]
|
||||
(if (seq sort)
|
||||
(into
|
||||
[:div.flex.gap-2.items-center
|
||||
|
||||
"sorted by"
|
||||
|
||||
]
|
||||
(for [{:keys [name sort-icon ]} sort]
|
||||
(for [{:keys [name sort-icon sort-key ]} sort]
|
||||
[:div.py-1.px-3.text-sm.rounded.bg-gray-100.dark:bg-gray-600.flex.items-center.gap-2.relative name [:div.h-4.w-4.mr-3 sort-icon]
|
||||
[:div {:class "absolute inline-flex items-center justify-center w-6 h-6 text-xs font-bold text-white hover:scale-110 transition-all duration-300 bg-gray-400 border-2 border-white rounded-full -top-2 -right-2 dark:border-gray-900"}
|
||||
[:div.h-4.w-4 svg/x]
|
||||
[:a {:href (str (bidi/path-for ssr-routes/only-routes
|
||||
(:route grid-spec)) "?remove-sort=" sort-key)
|
||||
:hx-boost "true"
|
||||
:hx-target (str "#" (:id grid-spec))
|
||||
|
||||
}
|
||||
[:div.h-4.w-4 svg/x]]
|
||||
]]
|
||||
))
|
||||
"default sort"))
|
||||
@@ -73,7 +80,7 @@
|
||||
:total total
|
||||
:subtitle [:div.flex.items-center.gap-2
|
||||
[:span (format "Total %s: %d, " (:entity-name grid-spec) total)]
|
||||
(sort-by-list sort)]
|
||||
(sort-by-list grid-spec sort)]
|
||||
:action-buttons ((:action-buttons grid-spec) user params)
|
||||
:rows (for [entity entities]
|
||||
(row* grid-spec user entity {:flash? (= flash-id ((:id-fn grid-spec) entity)) :params params}))
|
||||
@@ -169,7 +176,7 @@
|
||||
|
||||
(defn extract-params [grid-spec {:keys [query-params hx-query-params identity session] :as request}]
|
||||
(let [{hx-start "start" hx-per-page "per-page" hx-sort "sort" } hx-query-params
|
||||
{q-start "start" q-per-page "per-page" q-sort "sort" q-toggle-sort "toggle-sort"} query-params
|
||||
{q-start "start" q-per-page "per-page" q-sort "sort" q-toggle-sort "toggle-sort" q-remove-sort "remove-sort"} query-params
|
||||
raw-query-params (merge (or hx-query-params {}) query-params)
|
||||
|
||||
parsed-query-params (cond-> (into {} (map (fn [[k v]] [(keyword k) v]) raw-query-params))
|
||||
@@ -180,7 +187,8 @@
|
||||
hx-sort (assoc :sort (doto (parse-sort grid-spec hx-sort) println))
|
||||
q-sort (assoc :sort (doto (parse-sort grid-spec q-sort) println ))
|
||||
(not-empty q-toggle-sort) (update :sort #(toggle-sort grid-spec % q-toggle-sort) )
|
||||
true (dissoc :toggle-sort))]
|
||||
(not-empty q-remove-sort) (update :sort (fn [s] (filter (comp (complement #{q-remove-sort}) :sort-key) s)) )
|
||||
true (dissoc :toggle-sort :remove-sort))]
|
||||
{:raw-query-params raw-query-params
|
||||
:parsed-query-params parsed-query-params
|
||||
:client-selection (:client-selection (:session request))
|
||||
|
||||
Reference in New Issue
Block a user