Makes navigation a little bit better.

This commit is contained in:
Bryce
2024-03-20 14:48:44 -07:00
parent f6f6dcc865
commit 8af5713ba2
29 changed files with 280 additions and 227 deletions

File diff suppressed because one or more lines are too long

View File

@@ -192,10 +192,11 @@
(upload-xls request)
(base-page
request
(com/page {:nav (com/admin-aside-nav)
(com/page {:nav com/admin-aside-nav
:client-selection (:client-selection (:session request))
:client (:client request)
:identity (:identity request)
:request request
:app-params {:hx-get (bidi/path-for ssr-routes/only-routes
:admin-ezcater-xls)
:hx-trigger "clientSelected from:body"

View File

@@ -44,7 +44,7 @@
(defn page [request]
(base-page
request
(com/page {:nav (com/admin-aside-nav)
(com/page {:nav com/admin-aside-nav
:client-selection (:client-selection (:session request))
:clients (:clients request)
:client (:client request)

View File

@@ -132,12 +132,12 @@
(def grid-page
(helper/build {:id "entity-table"
:nav (com/admin-aside-nav)
:nav com/admin-aside-nav
:page-specific-nav filters
:fetch-page fetch-page
:parse-query-params (comp
(query-params/parse-key :code query-params/parse-long)
(helper/default-parse-query-params grid-page))
(query-params/parse-key :code query-params/parse-long)
(helper/default-parse-query-params grid-page))
:action-buttons (fn [_]
[(com/button {:hx-get (str (bidi/path-for ssr-routes/only-routes
:admin-account-new-dialog))
@@ -145,8 +145,8 @@
"New Account")])
:row-buttons (fn [_ entity]
[(com/icon-button {:hx-get (str (bidi/path-for ssr-routes/only-routes
:admin-account-edit-dialog
:db/id (:db/id entity)))}
:admin-account-edit-dialog
:db/id (:db/id entity)))}
svg/pencil)])
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
:admin)}

View File

@@ -89,7 +89,7 @@
(def grid-page
(helper/build {:id "job-table"
:id-fn :arn
:nav (com/admin-aside-nav)
:nav com/admin-aside-nav
:fetch-page fetch-page
:action-buttons (fn [request]
[(com/button {:hx-get (str (bidi/path-for ssr-routes/only-routes :admin-job-start-dialog))
@@ -118,8 +118,8 @@
(when (and (:start-date e)
(:end-date e))
(str (time/in-minutes (time/interval
(:start-date e)
(:end-date e))) " minutes")))}
(:start-date e)
(:end-date e))) " minutes")))}
{:key "name"
:name "Name"
:render :name}

View File

@@ -168,7 +168,7 @@
(def grid-page
(helper/build {:id "entity-table"
:nav (com/admin-aside-nav)
:nav com/admin-aside-nav
:page-specific-nav filters
:fetch-page fetch-page
:parse-query-params (helper/default-parse-query-params grid-page)

View File

@@ -242,11 +242,12 @@
(defn page [{:keys [form-params form-errors] :as request}]
(base-page
request
(com/page {:nav (com/admin-aside-nav)
(com/page {:nav com/admin-aside-nav
:client-selection (:client-selection (:session request))
:clients (:clients request)
:client (:client request)
:identity (:identity request)}
:identity (:identity request)
:request request}
(com/breadcrumbs {} [:a {:href (bidi/path-for ssr-routes/only-routes ::route/page)}
"Admin"])
[:div.flex.space-x-4

View File

@@ -165,10 +165,11 @@
(let [entity-id (or (some-> query-params (get "entity-id") Long/parseLong)
(some-> route-params (get :entity-id) Long/parseLong))]
(base-page request
(com/page {:nav (com/admin-aside-nav)
(com/page {:nav com/admin-aside-nav
:client-selection (:client-selection (:session request))
:client (:client request)
:identity (:identity request)
:request request
:app-params {:hx-get (bidi/path-for ssr-routes/only-routes
:admin-history)
:hx-trigger "clientSelected from:body"

View File

@@ -124,7 +124,7 @@
(def grid-page
(helper/build {:id "entity-table"
:id-fn :db/id
:nav (com/admin-aside-nav)
:nav com/admin-aside-nav
:fetch-page fetch-page
:page-specific-nav filters
:row-buttons (fn [_ entity]
@@ -138,7 +138,7 @@
:end (:end-date (:parsed-query-params request))}
:id "date-range"}) [1 :hx-swap-oob] true)])
:parse-query-params (comp
(helper/default-parse-query-params grid-page))
(helper/default-parse-query-params grid-page))
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
:admin)}
"Admin"]

View File

@@ -176,7 +176,7 @@
(def grid-page
(helper/build {:id "entity-table"
:nav (com/admin-aside-nav)
:nav com/admin-aside-nav
:page-specific-nav filters
:fetch-page fetch-page
:parse-query-params (comp

View File

@@ -136,7 +136,7 @@
(def grid-page
(helper/build {:id "entity-table"
:nav (com/admin-aside-nav)
:nav com/admin-aside-nav
:page-specific-nav filters
:fetch-page fetch-page
:parse-query-params (comp

View File

@@ -130,7 +130,7 @@
(defn page [{:keys [identity matched-route] :as request}]
(base-page
request
(com/page {:nav (com/company-aside-nav)
(com/page {:nav com/company-aside-nav
:client-selection (:client-selection (:session request))
:client (:client request)
:identity (:identity request)

View File

@@ -90,7 +90,7 @@
(def grid-page
(helper/build
{:id "entity-table"
:nav (com/company-aside-nav)
:nav com/company-aside-nav
:id-fn (comp :db/id second)
:fetch-page fetch-page
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
@@ -126,46 +126,46 @@
(-> vendor :vendor/legal-entity-last-name)))]]
(when-let [t99-type (some-> vendor :vendor/legal-entity-1099-type :db/ident name)]
(com/pill
{:class "text-xs font-medium"
:color :primary}
(str/capitalize t99-type))
{:class "text-xs font-medium"
:color :primary}
(str/capitalize t99-type))
)])}
{:key "tin"
:name "TIN"
:sort-key "tin"
:show-starting "md"
:render (fn [[_ vendor]]
[:div.flex.gap-4
(when-let [tin (-> vendor :vendor/legal-entity-tin)]
[:span {:class "text-xs font-medium py-0.5 "}
tin])
(when-let [tin-type (some-> vendor :vendor/legal-entity-tin-type :db/ident name)]
(com/pill {:class "text-xs font-medium"
:color :yellow}
(name tin-type)))]
)}
[:div.flex.gap-4
(when-let [tin (-> vendor :vendor/legal-entity-tin)]
[:span {:class "text-xs font-medium py-0.5 "}
tin])
(when-let [tin-type (some-> vendor :vendor/legal-entity-tin-type :db/ident name)]
(com/pill {:class "text-xs font-medium"
:color :yellow}
(name tin-type)))]
)}
{:key "address"
:name "Address"
:sort-key "address"
:show-starting "lg"
:render (fn [[_ vendor]]
(if (-> vendor :vendor/address :address/street1)
[:div
[:div (-> vendor :vendor/address :address/street1)] " "
[:div
(-> vendor :vendor/address :address/street2)] " "
[:div
(-> vendor :vendor/address :address/city) " "
(-> vendor :vendor/address :address/state) ","
(-> vendor :vendor/address :address/zip)]]
[:p.text-sm.italic.text-gray-400 "No address"]))}
(if (-> vendor :vendor/address :address/street1)
[:div
[:div (-> vendor :vendor/address :address/street1)] " "
[:div
(-> vendor :vendor/address :address/street2)] " "
[:div
(-> vendor :vendor/address :address/city) " "
(-> vendor :vendor/address :address/state) ","
(-> vendor :vendor/address :address/zip)]]
[:p.text-sm.italic.text-gray-400 "No address"]))}
{:key "paid"
:name "Paid"
:sort-key "paid"
:render (fn [[_ _ paid]]
(com/pill {:class "text-xs font-medium"
:color :primary}
"Paid $" (Math/round paid)))}]}))
"Paid $" (Math/round paid)))}]}))

View File

@@ -133,7 +133,7 @@
(def grid-page
(helper/build
{:id "plaid-table"
:nav (com/company-aside-nav)
:nav com/company-aside-nav
:fetch-page fetch-page
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
:company)}
@@ -181,9 +181,9 @@
:name "Accounts"
:show-starting "md"
:render (fn [e]
[:ul
(for [a (:plaid-item/accounts e)]
[:li (:plaid-account/name a) " - " (:plaid-account/number a)])])}]}))
[:ul
(for [a (:plaid-item/accounts e)]
[:li (:plaid-account/name a) " - " (:plaid-account/number a)])])}]}))
(def page (helper/page-route grid-page))

View File

@@ -70,7 +70,7 @@
(def grid-page
(helper/build {:id "report-table"
:nav (com/company-aside-nav)
:nav com/company-aside-nav
:fetch-page fetch-page
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
:company)}

View File

@@ -122,7 +122,7 @@ fastlink.open({fastLinkURL: '%s',
(def grid-page
(helper/build
{:id "yodlee-table"
:nav (com/company-aside-nav)
:nav com/company-aside-nav
:id-fn :db/id
:fetch-page fetch-page
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
@@ -136,19 +136,19 @@ fastlink.open({fastLinkURL: '%s',
:route :company-yodlee-table
:action-buttons (fn [request]
[[:div.flex.flex-col.flex-shrink
[:div.flex-shrink
(com/button {:color :primary
:on-click "openFastlink()"
:disabled (if (:client request)
false
true)
:hx-get (bidi/path-for ssr-routes/only-routes
:company-yodlee-fastlink-dialog)
:hx-target "#modal-holder"}
(com/button-icon {} svg/refresh)
"Link new account")]
(when-not (:client request)
[:div.text-xs "Note: please select a specific customer to link a new account."])]])
[:div.flex-shrink
(com/button {:color :primary
:on-click "openFastlink()"
:disabled (if (:client request)
false
true)
:hx-get (bidi/path-for ssr-routes/only-routes
:company-yodlee-fastlink-dialog)
:hx-target "#modal-holder"}
(com/button-icon {} svg/refresh)
"Link new account")]
(when-not (:client request)
[:div.text-xs "Note: please select a specific customer to link a new account."])]])
:row-buttons (fn [request _]
[
(com/button {:hx-put (bidi/path-for ssr-routes/only-routes
@@ -194,9 +194,9 @@ fastlink.open({fastLinkURL: '%s',
:name "Accounts"
:show-starting "md"
:render (fn [e]
[:ul
(for [a (:yodlee-provider-account/accounts e)]
[:li (:yodlee-account/name a) " - " (:yodlee-account/number a)])])}]}))
[:ul
(for [a (:yodlee-provider-account/accounts e)]
[:li (:yodlee-account/name a) " - " (:yodlee-account/number a)])])}]}))
(def page (helper/page-route grid-page))
(def table (helper/table-route grid-page))

View File

@@ -1,12 +1,13 @@
(ns auto-ap.ssr.components.aside
(:require [auto-ap.client-routes :as client-routes]
[auto-ap.logging :as alog]
[auto-ap.routes.admin.clients :as ac-routes]
[auto-ap.routes.admin.excel-invoices :as ei-routes]
[auto-ap.routes.admin.import-batch :as ib-routes]
[auto-ap.routes.admin.transaction-rules :as transaction-rules]
[auto-ap.routes.admin.vendors :as v-routes]
[auto-ap.routes.payments :as payment-routes]
[auto-ap.routes.invoice :as invoice-route]
[auto-ap.routes.payments :as payment-routes]
[auto-ap.ssr-routes :as ssr-routes]
[auto-ap.ssr.hiccup-helper :as hh]
[auto-ap.ssr.hx :as hx]
@@ -19,30 +20,36 @@
[:a (-> params
(dissoc :icon)
(assoc :type "button")
(update :class str " cursor-pointer flex items-center p-2 w-full text-xs text-gray-600 rounded-lg transition duration-75 group hover:bg-gray-100 dark:text-white dark:hover:bg-gray-700")
(update :class (fn [c]
(cond-> (or c "cursor-pointer flex items-center p-2 w-full text-sm rounded-lg transition duration-75 group hover:bg-gray-100 dark:hover:bg-gray-700 select-none")
(:active? params) (hh/add-class "text-blue-600 font-extrabold dark:text-blue-100 bg-gray-100")
(not (:active? params)) (hh/add-class "text-gray-600 dark:text-white"))))
(assoc :hx-indicator "find .htmx-indicator")
(assoc :hx-boost "true")
(assoc :hx-select "#app")
(assoc :hx-target "#app")
(assoc :hx-swap "innerHTML"))
(when (:icon params)
[:span {:class "flex-shrink-0 w-6 h-6 text-gray-400 transition duration-75 group-hover:text-blue-500 dark:text-gray-400 group-hover:scale-110 dark:group-hover:text-white mr-3"}
(:icon params)])
(into [:span {:class "flex-1 text-left whitespace-nowrap text-gray-600 dark:text-white"}] children)
(when (get params "@click")
(into [:span {:class "flex-1 text-left whitespace-nowrap"}] children)
(when (get params "@click.prevent")
[:svg {:aria-hidden "true", :class "w-6 h-6", :fill "currentColor", :viewbox "0 0 20 20", :xmlns "http://www.w3.org/2000/svg"}
[:path {:fill-rule "evenodd", :d "M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z", :clip-rule "evenodd"}]])
[:div.htmx-indicator.flex.items-center
(svg/spinner-primary {:class "inline w-4 h-4 text-white"})]]])
(defn sub-menu- [params & children]
[:ul (update params
:class (fnil hh/add-class "")"py-2 space-y-1.5")
[:ul (cond-> (update params
:class (fnil hh/add-class "") "space-y-1.5 max-h-0 transition transition-all overflow-hidden")
true (assoc ":class" (format "selected == '%s' ? 'py-0.5' : 'py-0'" (:selector params))
:x-ref "submenu"
":style" (format "selected == '%s' ? 'max-height: ' + $refs.submenu.scrollHeight + 'px' : ''" (:selector params))))
(for [c children]
[:li
(update-in c [1 1 :class ] str " flex items-center p-2 pl-11 w-full text-base font-normal text-gray-900 rounded-lg transition duration-75 group hover:bg-gray-100 dark:text-white dark:hover:bg-gray-700")])])
(update-in c [1 1 :class ] (fn [c]
(hh/add-class (or c "") " flex items-center p-2 pl-11 w-full text-base font-normal rounded-lg transition duration-75 group hover:bg-gray-100 dark:text-white dark:hover:bg-gray-700")))])])
(defn left-aside- [{:keys [nav page-specific]} & children]
[:aside {:id "left-nav",
@@ -67,84 +74,113 @@
page-specific]
)]])
(defn main-aside-nav- []
[:ul {:class "space-y-1"}
(defn main-aside-nav- [request]
[:ul {:class "space-y-1"
:x-data (hx/json {:selected
(cond
(#{::invoice-route/page} (:matched-route request))
"invoices"
(#{:pos-sales :pos-expected-deposits :pos-tenders :pos-refunds :pos-cash-drawer-shifts} (:matched-route request))
"sales"
(#{::payment-routes/page} (:matched-route request))
"payments"
:else
nil)})}
[:li
(menu-button- {:icon svg/pie
:href "/"}
"Dashboard")]
[:li {:x-data (hx/json {:open false})}
(menu-button- {"@click" "open = !open"
:icon svg/accounting-invoice-mail}
"Invoices")
(sub-menu- (hx/alpine-appear {:x-show "open"})
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
::invoice-route/page)
{:date-range "month"})}
"All")
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
::invoice-route/page)
{:date-range "month"})}
"Paid")
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
::invoice-route/unpaid-page)
{:date-range "month"})}
"Unpaid")
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
::invoice-route/voided-page)
{:date-range "month"})}
"Voided"))]
[:li {:x-data (hx/json {:open false})}
(menu-button- {:icon svg/receipt-register-1
"@click" "open = !open"}
"Sales")
(sub-menu- (hx/alpine-appear {:x-show "open"})
(menu-button- {:href (str (bidi/path-for ssr-routes/only-routes
:pos-sales)
"?date-range=week")} "Sales")
(menu-button- {:href (str (bidi/path-for ssr-routes/only-routes
:pos-expected-deposits)
"?date-range=week")} "Expected Deposits")
(menu-button- {:href (str (bidi/path-for ssr-routes/only-routes
:pos-tenders)
"?date-range=week")} "Tenders")
(menu-button- {:href (str (bidi/path-for ssr-routes/only-routes
:pos-refunds)
"?date-range=week")} "Refunds")
(menu-button- {:href (str (bidi/path-for ssr-routes/only-routes
:pos-cash-drawer-shifts)
"?date-range=week")} "Cash drawer shifts")
#_(menu-button- {:href "Sales"} "Cash Shifts")
#_(menu-button- {:href "Sales"} "Tenders"))]
[:li {:x-data (hx/json {:open false})}
(menu-button- {"@click" "open = !open"
:icon svg/payments}
"Payments")
(sub-menu- (hx/alpine-appear {:x-show "open"})
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
::payment-routes/page)
{ :date-range "month"})} "All")
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
::payment-routes/page)
{:status "pending"
:date-range "month"})} "Pending")
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
::payment-routes/page)
{:status "cleared"
:date-range "month"})} "Cleared")
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
::payment-routes/page)
{:status "voided"
:date-range "month"})} "Voided"))]
(menu-button- {"@click.prevent" "if (selected == 'invoices') {selected = null } else { selected = 'invoices'} "
:icon svg/accounting-invoice-mail}
"Invoices")
(sub-menu-
{:selector "invoices"}
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
::invoice-route/page)
{:date-range "month"})
:active? (= ::invoice-route/page (:matched-route request))}
"All")
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
::invoice-route/page)
{:date-range "month"})
:active? (= ::invoice-route/page (:matched-route request))}
"Paid")
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
::invoice-route/unpaid-page)
{:date-range "month"})
:active? (= ::invoice-route/page (:matched-route request))}
"Unpaid")
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
::invoice-route/voided-page)
{:date-range "month"})
:active? (= ::invoice-route/page (:matched-route request))}
"Voided"))
(menu-button- {:icon svg/receipt-register-1
"@click.prevent" "if (selected == 'sales') {selected = null } else { selected = 'sales'} "}
"Sales")
(sub-menu- {:selector "sales"}
(menu-button- {:href (str (bidi/path-for ssr-routes/only-routes
:pos-sales)
"?date-range=week")
:active? (= :pos-sales (:matched-route request))} "Sales")
(menu-button- {:href (str (bidi/path-for ssr-routes/only-routes
:pos-expected-deposits)
"?date-range=week")
:active? (= :pos-expected-deposits (:matched-route request))}
"Expected Deposits")
(menu-button- {:href (str (bidi/path-for ssr-routes/only-routes
:pos-tenders)
"?date-range=week")
:active? (= :pos-tenders (:matched-route request))} "Tenders")
(menu-button- {:href (str (bidi/path-for ssr-routes/only-routes
:pos-refunds)
"?date-range=week")
:active? (= :pos-refunds (:matched-route request))} "Refunds")
(menu-button- {:href (str (bidi/path-for ssr-routes/only-routes
:pos-cash-drawer-shifts)
"?date-range=week")
:active? (= :cash-drawer-shifts (:matched-route request))} "Cash drawer shifts"))
;; TODO make specific routes for categories
;; TODO auto-apen sub menus
(menu-button- {"@click.prevent" "if (selected == 'payments') {selected = null } else { selected = 'payments'} "
:icon svg/payments}
"Payments")
(sub-menu- {:selector "payments"}
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
::payment-routes/page)
{:date-range "month"})
:active? (= ::payment-routes/page (:matched-route request))} "All")
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
::payment-routes/page)
{:status "pending"
:date-range "month"})
:active? (= ::payment-routes/page (:matched-route request))} "Pending")
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
::payment-routes/page)
{:status "cleared"
:date-range "month"})
:active? (= ::payment-routes/page (:matched-route request))} "Cleared")
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
::payment-routes/page)
{:status "voided"
:date-range "month"})
:active? (= ::payment-routes/page (:matched-route request))} "Voided"))
[:li {:x-data (hx/json {:open false})}
(menu-button- {"@click" "open = !open"
(menu-button- {"@click.prevent" "if (selected == 'transactions') {selected = null } else { selected = 'transactions'} "
:icon svg/bank}
"Transactions")
(sub-menu- (hx/alpine-appear {:x-show "open"})
(sub-menu- {:selector "transactions"}
(menu-button- {:href (bidi/path-for client-routes/routes
:transactions)} "All")
(menu-button- {:href (bidi/path-for client-routes/routes
@@ -155,26 +191,26 @@
:approved-transactions)} "Approved")
(menu-button- {:href (bidi/path-for ssr-routes/only-routes
:transaction-insights)} "Insights"))]
[:li {:x-data (hx/json {:open false})}
(menu-button- {"@click" "open = !open"
:icon svg/receipt}
"Ledger")
(sub-menu- (hx/alpine-appear {:x-show "open"})
(menu-button- {:href (bidi/path-for client-routes/routes
:ledger)} "Register")
(menu-button- {:href (bidi/path-for client-routes/routes
:profit-and-loss)} "Profit & Loss")
(menu-button- {:href (bidi/path-for client-routes/routes
:profit-and-loss-detail)} "Profit & Loss Detail")
(menu-button- {:href (bidi/path-for client-routes/routes
:cash-flows)} "Cash Flows")
(menu-button- {:href (bidi/path-for client-routes/routes
:balance-sheet)} "Balance Sheet")
(menu-button- {:href (bidi/path-for client-routes/routes
:external-import-ledger)} "External Ledger Import"))]])
(menu-button- {"@click.prevent" "if (selected == 'ledger') {selected = null } else { selected = 'ledger'} "
:icon svg/receipt}
"Ledger")
(sub-menu- {:selector "ledger"}
(menu-button- {:href (bidi/path-for client-routes/routes
:ledger)} "Register")
(menu-button- {:href (bidi/path-for client-routes/routes
:profit-and-loss)} "Profit & Loss")
(menu-button- {:href (bidi/path-for client-routes/routes
:profit-and-loss-detail)} "Profit & Loss Detail")
(menu-button- {:href (bidi/path-for client-routes/routes
:cash-flows)} "Cash Flows")
(menu-button- {:href (bidi/path-for client-routes/routes
:balance-sheet)} "Balance Sheet")
(menu-button- {:href (bidi/path-for client-routes/routes
:external-import-ledger)} "External Ledger Import"))])
(defn company-aside-nav- []
(defn company-aside-nav- [_]
[:ul {:class "space-y-2" :hx-boost "true"}
[:li
(menu-button- {:icon svg/vendors
@@ -204,40 +240,47 @@
"1099 Vendor Info"
)]])
(defn admin-aside-nav- []
[:ul {:class "space-y-2"}
(defn admin-aside-nav- [{:keys [matched-route] :as request}]
[:ul {:class "space-y-2" :x-data (hx/json {:selected "nil"})}
[:li
(menu-button- {:icon svg/dashboard
:active? (= :auto-ap.routes.admin/page matched-route)
:href (bidi/path-for ssr-routes/only-routes :auto-ap.routes.admin/page)}
"Dashboard")]
[:li
(menu-button- {:icon svg/restaurant
:href (bidi/path-for ssr-routes/only-routes ::ac-routes/page) }
:active? (= ::ac-routes/page matched-route)
:href (bidi/path-for ssr-routes/only-routes ::ac-routes/page)}
"Clients")]
[:li
(menu-button- {:icon svg/vendors
:active? (= ::v-routes/page matched-route)
:href (bidi/path-for ssr-routes/only-routes
::v-routes/page)}
"Vendors")]
[:li
(menu-button- {:icon svg/user
:active? (= :users matched-route)
:href (bidi/path-for ssr-routes/only-routes
:users)}
"Users")]
[:li
(menu-button- {:icon svg/accounts
:active? (= :admin-accounts matched-route)
:href (bidi/path-for ssr-routes/only-routes
:admin-accounts)}
"Accounts")]
[:li
(menu-button- {:icon svg/cog
:active? (= ::transaction-rules/page matched-route)
:href (bidi/path-for ssr-routes/only-routes ::transaction-rules/page)}
"Rules")]
[:li
(menu-button- {:icon svg/question
:active? (= :admin-rules matched-route)
:href (bidi/path-for ssr-routes/only-routes
:admin-history)
:hx-boost "true"}
@@ -245,20 +288,24 @@
[:li
(menu-button- {:icon svg/rabbit
:active? (= :admin-jobs matched-route)
:href (bidi/path-for ssr-routes/only-routes
:admin-jobs)}
"Background Jobs")]
[:li {:x-data (hx/json {:open false})}
(menu-button- {:icon svg/arrow-in
"@click" "open = !open"}
"Import")
(sub-menu- (hx/alpine-appear
{:x-show "open"})
(menu-button- {:href (bidi/path-for ssr-routes/only-routes
::ei-routes/page)} "Excel Invoices")
(menu-button- {:href (bidi/path-for ssr-routes/only-routes
::ib-routes/page)} "Import Batches")
(menu-button- {:href (bidi/path-for ssr-routes/only-routes
:admin-ezcater-xls)
:hx-boost "true"} "EZCater XLS Import"))]])
(menu-button- {:icon svg/arrow-in
"@click.prevent" "if (selected == 'import') {selected = null } else { selected = 'import'} "}
"Import")
(sub-menu- {:selector "import"}
(menu-button- {:href (bidi/path-for ssr-routes/only-routes
::ei-routes/page)
:active? (= ::ei-routes/page matched-route)} "Excel Invoices")
(menu-button- {:href (bidi/path-for ssr-routes/only-routes
::ib-routes/page)
:active? (= ::ib-routes/page matched-route)} "Import Batches")
(menu-button- {:href (bidi/path-for ssr-routes/only-routes
:admin-ezcater-xls)
:active? (= :admin-ezcater-xls matched-route)
:hx-boost "true"} "EZCater XLS Import"))])

View File

@@ -6,7 +6,7 @@
[auto-ap.ssr.svg :as svg]
[auto-ap.ssr.hx :as hx]))
(defn page- [{:keys [nav page-specific client clients client-selection identity app-params] :or {app-params {}}} & children]
(defn page- [{:keys [nav page-specific client clients client-selection identity app-params request] :or {app-params {}} } & children]
[:div#app {"_" (hiccup/raw "
on notification from body put event.detail.value into #notification-details then add .htmx-added to #notification-holder then remove .hidden from #notification-holder then wait 30ms then remove .htmx-added from #notification-holder
on htmx:responseError put event.detail.xhr.response into #error-details then add .htmx-added to #error-holder then remove .hidden from #error-holder then wait 30ms then remove .htmx-added from #error-holder"
@@ -19,7 +19,8 @@
[:div#app-contents.flex.pt-16.overflow-hidden (assoc app-params
:hx-disinherit "*"
:x-init "leftNavShow = true")
(left-aside- {:nav nav
(left-aside- {:nav (when nav
(nav request))
:page-specific page-specific})
[:div#main-content {:class "relative w-full h-full overflow-y-auto px-4 bg-gray-100 dark:bg-gray-900 min-h-content lg:pl-64"
":class" "leftNavShow ? 'lg:pl-64' : ''"

View File

@@ -208,7 +208,6 @@
(defn table-route [grid-spec]
(-> (fn table [{:keys [identity] :as request}]
(alog/peek ::qp (pr-str (:query-params request)))
(let [unparse-query-params (or (:unparse-query grid-spec)
default-unparse-query-params)]
(html-response (table*
@@ -249,7 +248,8 @@
:client-selection (:client-selection (:session request))
:clients (:clients request)
:client (:client request)
:identity (:identity request)}
:identity (:identity request)
:request request}
(apply com/breadcrumbs {} (:breadcrumbs grid-spec))
[:div {:x-data (hx/json {:selected [] :all_selected false})
"x-bind:hx-vals" "JSON.stringify({selected: $data.selected, 'all-selected': $data.all_selected})"
@@ -277,7 +277,9 @@
[:hide? {:optional true} [:=> [:cat entity-spec] :boolean]]]))
(def grid-spec (m/schema [:map
[:id :string]
[:nav vector?]
[:nav [:=>
[:cat request-spec]
vector?]]
[:page-specific-nav
{:optional true
:default (fn [request])}

View File

@@ -420,7 +420,7 @@ invoice_dropzone = new Dropzone(\"#invoice\", {
:method request-method)
(base-page
request
(com/page {:nav (com/admin-aside-nav)
(com/page {:nav com/admin-aside-nav
:client-selection (:client-selection (:session request))
:client (:client request)
:identity (:identity request)

View File

@@ -375,7 +375,7 @@
;; TODO fix parsing of query params
(def grid-page
(helper/build {:id "entity-table"
:nav (com/main-aside-nav)
:nav com/main-aside-nav
:check-boxes? true
:page-specific-nav filters
:fetch-page fetch-page

View File

@@ -278,7 +278,7 @@
;; TODO fix parsing of query params
(def grid-page
(helper/build {:id "entity-table"
:nav (com/main-aside-nav)
:nav com/main-aside-nav
:check-boxes? true
:page-specific-nav filters
:fetch-page fetch-page
@@ -364,16 +364,16 @@
:class "w-8"
:render (fn [p]
(link-dropdown (concat (->> p :payment/invoices (map (fn [invoice]
{:link (hu/url (bidi/path-for ssr-routes/only-routes
::invoice-route/page)
{:exact-match-id (:db/id invoice)})
:content (str "Inv. " (:invoice/invoice-number invoice))})))
(some-> p :transaction/_payment ((fn [t]
[{:link (hu/url (bidi/path-for client-routes/routes
:transactions)
{:exact-match-id (:db/id (first t))})
:color :secondary
:content "Transaction"}]))))))}]}))
{:link (hu/url (bidi/path-for ssr-routes/only-routes
::invoice-route/page)
{:exact-match-id (:db/id invoice)})
:content (str "Inv. " (:invoice/invoice-number invoice))})))
(some-> p :transaction/_payment ((fn [t]
[{:link (hu/url (bidi/path-for client-routes/routes
:transactions)
{:exact-match-id (:db/id (first t))})
:color :secondary
:content "Transaction"}]))))))}]}))
(def row* (partial helper/row* grid-page))

View File

@@ -136,23 +136,23 @@
(def grid-page
(helper/build
{:id "expected-deposit-table"
:nav (com/main-aside-nav)
:nav com/main-aside-nav
:page-specific-nav filters
:fetch-page fetch-page
:parse-query-params (comp
(query-params/parse-key :total-gte query-params/parse-double)
(query-params/parse-key :total-lte query-params/parse-double)
(helper/default-parse-query-params grid-page))
(query-params/parse-key :total-gte query-params/parse-double)
(query-params/parse-key :total-lte query-params/parse-double)
(helper/default-parse-query-params grid-page))
:oob-render
(fn [request]
[(assoc-in (date-range-field* request) [1 :hx-swap-oob] true)])
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
:company)}
"POS"]
"POS"]
[:a {:href (bidi/path-for ssr-routes/only-routes
:pos-expected-deposits)}
"Expected deposits"]]
"Expected deposits"]]
:title "Expected deposits"
:entity-name "Expected deposit"
:route :pos-expected-deposit-table
@@ -170,7 +170,7 @@
:name "Client"
:sort-key "client"
:hide? (fn [args]
(= (count (:clients args)) 1))
(= (count (:clients args)) 1))
:render #(-> % :expected-deposit/client :client/code)}
{:key "date"
:name "Date"

View File

@@ -95,23 +95,23 @@
(def grid-page
(helper/build {:id "refund-table"
:nav (com/main-aside-nav)
:nav com/main-aside-nav
:page-specific-nav filters
:fetch-page fetch-page
:parse-query-params (comp
(query-params/parse-key :total-gte query-params/parse-double)
(query-params/parse-key :total-lte query-params/parse-double)
(helper/default-parse-query-params grid-page))
(query-params/parse-key :total-gte query-params/parse-double)
(query-params/parse-key :total-lte query-params/parse-double)
(helper/default-parse-query-params grid-page))
:oob-render
(fn [request]
[(assoc-in (date-range-field* request) [1 :hx-swap-oob] true)])
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
:company)}
"POS"]
"POS"]
[:a {:href (bidi/path-for ssr-routes/only-routes
:pos-refunds)}
"Refunds"]]
"Refunds"]]
:title "Refunds"
:entity-name "Refund"
:route :pos-refund-table
@@ -119,7 +119,7 @@
:name "Client"
:sort-key "client"
:hide? (fn [args]
(= (count (:clients args)) 1))
(= (count (:clients args)) 1))
:render #(-> % :sales-refund/client :client/code)}
{:key "date"
:name "Date"

View File

@@ -169,14 +169,14 @@
(def grid-page
(helper/build
{:id "sales-table"
:nav (com/main-aside-nav)
:nav com/main-aside-nav
:page-specific-nav filters
:fetch-page fetch-page
:parse-query-params (comp
(query-params/parse-key :processor #(query-params/parse-keyword "ccp-processor" %))
(query-params/parse-key :total-gte query-params/parse-double)
(query-params/parse-key :total-lte query-params/parse-double)
(helper/default-parse-query-params grid-page))
(query-params/parse-key :processor #(query-params/parse-keyword "ccp-processor" %))
(query-params/parse-key :total-gte query-params/parse-double)
(query-params/parse-key :total-lte query-params/parse-double)
(helper/default-parse-query-params grid-page))
:oob-render
(fn [request]
[(assoc-in (date-range-field* request) [1 :hx-swap-oob] true)])

View File

@@ -112,14 +112,14 @@
(def grid-page
(helper/build
{:id "tender-table"
:nav (com/main-aside-nav)
:nav com/main-aside-nav
:page-specific-nav filters
:fetch-page fetch-page
:parse-query-params (comp
(query-params/parse-key :processor #(query-params/parse-keyword "ccp-processor" %))
(query-params/parse-key :total-gte query-params/parse-double)
(query-params/parse-key :total-lte query-params/parse-double)
(helper/default-parse-query-params grid-page))
(query-params/parse-key :processor #(query-params/parse-keyword "ccp-processor" %))
(query-params/parse-key :total-gte query-params/parse-double)
(query-params/parse-key :total-lte query-params/parse-double)
(helper/default-parse-query-params grid-page))
:oob-render
(fn [request]
[(assoc-in (date-range-field* request) [1 :hx-swap-oob] true)])

View File

@@ -317,7 +317,7 @@
(defn page [{:keys [identity matched-route session clients] :as request}]
(base-page
request
(com/page {:nav (com/main-aside-nav)
(com/page {:nav com/main-aside-nav
:client-selection (:client-selection (:session request))
:client (:client request)
:identity (:identity request)
@@ -325,7 +325,8 @@
:transaction-insights)
:hx-trigger "clientSelected from:body"
:hx-select "#app-contents"
:hx-swap "outerHTML swap:300ms"}}
:hx-swap "outerHTML swap:300ms"}
:request request}
(com/breadcrumbs {}
[:a {:href (bidi/path-for client-routes/routes
:transactions)}

View File

@@ -45,7 +45,6 @@
[:script {:src "/js/htmx-disable.js"}]
[:script {:type "text/javascript", :src "https://cdn.yodlee.com/fastlink/v4/initialize.js", :async "async"}]]
[:link {:rel "stylesheet" :href "https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.1.4/dist/css/datepicker.min.css"}]
[:script {:type "text/javascript" :src "https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.1.4/dist/js/datepicker-full.min.js"}]
[:link {:rel "stylesheet" :href "https://cdn.jsdelivr.net/npm/choices.js@9.0.1/public/assets/styles/choices.min.css"}]

View File

@@ -205,20 +205,20 @@
(def grid-page
(helper/build {:id "user-table"
:nav (com/admin-aside-nav)
:nav com/admin-aside-nav
:page-specific-nav filters
:fetch-page fetch-page
:parse-query-params (comp
(query-params/parse-key :role #(query-params/parse-keyword "user-role" %))
(query-params/parse-key :client parse-client)
(helper/default-parse-query-params grid-page))
(query-params/parse-key :role #(query-params/parse-keyword "user-role" %))
(query-params/parse-key :client parse-client)
(helper/default-parse-query-params grid-page))
:row-buttons (fn [request entity]
[(com/button {:hx-post (str (bidi/path-for ssr-routes/only-routes
:user-impersonate))
:hx-vals (format "{\"db/id\": \"%s\"}" (:db/id entity))} "Impersonate")
(com/icon-button {:hx-get (str (bidi/path-for ssr-routes/only-routes
:user-edit-dialog
:db/id (:db/id entity)))}
:user-edit-dialog
:db/id (:db/id entity)))}
svg/pencil)])
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
:admin)}
@@ -238,7 +238,7 @@
(when-let [profile-image (:user/profile-image-url user) ]
[:div.rounded-full.overflow-hidden.w-8.h-8.display-inline
[:img {:src profile-image }]])
[:span.inline-block ](:user/name user)])}
[:span.inline-block ] (:user/name user)])}
{:key "email"
:name "Email"