other pages

This commit is contained in:
Bryce
2023-05-18 22:14:23 -07:00
parent 33fc70295b
commit 33cae26cc1
9 changed files with 349 additions and 222 deletions

View File

@@ -3,11 +3,20 @@
[auto-ap.ssr-routes :as ssr-routes]
[auto-ap.ssr.components.card :refer [content-card-]]
[auto-ap.ssr.components.paginator :refer [paginator-]]
[bidi.bidi :as bidi]))
[bidi.bidi :as bidi]
[hiccup2.core :as hiccup]))
(defn header- [params & rest]
(into [:th.px-4.py-3 {:scope "col" :class (:class params)} ] rest))
(into [:th.px-4.py-3 {:scope "col" :class (:class params)
"_" (hiccup/raw (when (:sort-key params ) (format "on click trigger sorted(key:\"%s\")", (:sort-key params))))}]
(if (:sort-key params)
[(into [:a {:href "#"} ] rest)]
rest)))
(defn sort-header- [params & rest]
[:th.px-4.py-3 {:scope "col" :class (:class params)
"_" (hiccup/raw (format "on click trigger sorted(key:\"%s\")", (:sort-key params)))}
(into [:a {:href "#"} ] rest)])
(defn row- [params & rest]
(into [:tr (update params
@@ -27,9 +36,9 @@
[:input {:id "checkbox-all", :type "checkbox", :class "w-4 h-4 bg-gray-100 border-gray-300 rounded text-primary-600 focus:ring-primary-500 dark:focus:ring-primary-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"}]
[:label {:for "checkbox-all", :class "sr-only"} "checkbox"]]])
(defn data-grid- [{:keys [headers]} & rest]
(defn data-grid- [{:keys [headers thead-params]} & rest]
[:table {:class "w-full text-sm text-left text-gray-500 dark:text-gray-400"}
[:thead {:class "text-xs text-gray-800 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400"}
[:thead (assoc thead-params :class "text-xs text-gray-800 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400")
(into
[:tr]
headers)]
@@ -40,9 +49,10 @@
(defn data-grid-card- [{:keys [id
route
title
entity-name
action-buttons
total
subtitle
thead-params
start
per-page
flash-id
@@ -61,13 +71,14 @@
[:h1.text-2xl.mb-3.font-bold title]
[:div {:class "flex items-center flex-1 space-x-4"}
[:h5
[:span (format "Total %s:" entity-name)]
[:span {:class "dark:text-white pl-4"} total]]]]
(when subtitle
[:span subtitle])]]]
(into [:div {:class "flex flex-col flex-shrink-0 space-y-3 md:flex-row md:items-center lg:justify-end md:space-y-0 md:space-x-3"}
]
action-buttons)]
[:div {:class "overflow-x-auto"}
(data-grid- {:headers headers
:thead-params thead-params
}
rows