This commit is contained in:
2024-05-26 20:22:13 -07:00
111 changed files with 10708 additions and 5015 deletions

View File

@@ -10,6 +10,7 @@
[auto-ap.routes.outgoing-invoice :as oi-routes]
[auto-ap.routes.payments :as payment-routes]
[auto-ap.ssr-routes :as ssr-routes]
[auto-ap.ssr.components.tags :as tags]
[auto-ap.ssr.hiccup-helper :as hh]
[auto-ap.ssr.hx :as hx]
[auto-ap.ssr.svg :as svg]
@@ -45,14 +46,14 @@
: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 (cond-> {} (:active? params) (assoc "max-height" "400px"))
":style" (format "selected == '%s' ? 'max-height: ' + $refs.submenu.scrollHeight + 'px' : ''" (:selector params))))
:style (cond-> {} (:active? params) (assoc "max-height" "900px"))
":style" (format "selected == '%s' ? 'max-height: ' + $el.scrollHeight + 'px' : ''" (:selector params))))
(for [c children]
[:li
(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]
(defn left-aside- [{:keys [nav page-specific]} & _]
[:aside {:id "left-nav",
:class "fixed top-0 left-0 pt-16 z-20 w-64 h-screen transition-transform",
"x-transition:enter" "transition duration-500"
@@ -66,12 +67,13 @@
:x-show "leftNavShow"
":aria-hidden" "leftNavShow ? 'false' : 'true'"}
;; TODO this causes a leftNavShow error when hitting back button. maybe amke a container
[:template {:x-teleport "body"}
[:div.fixed.inset-0.lg:hidden {:x-show "leftNavShow" :x-transition:enter "transition duration-500" :x-transition:enter-start "opacity-0" :x-transition:enter-end "opacity-100"
:x-transition:leave "transition duration-500" :x-transition:leave-start "opacity-100" :x-transition:leave-end "opacity-0"
"@click.capture.prevent" "leftNavShow=false"}
[:div.fixed.inset-0.bg-gray-800.z-10.opacity-70]]]
[:div.fixed.inset-0.bg-gray-800.z-100.opacity-70]]]
[:div {:class "overflow-y-auto py-5 px-3 h-full bg-gray-50 border-r border-gray-200 dark:bg-gray-800 dark:border-gray-700"}
nav
@@ -83,12 +85,12 @@
(defn main-aside-nav- [request]
(let [selected (cond
(#{::invoice-route/all-page ::invoice-route/unpaid-page ::invoice-route/voided-page ::invoice-route/paid-page ::oi-routes/new ::invoice-route/import-page} (:matched-route request))
(#{::invoice-route/all-page ::invoice-route/unpaid-page ::invoice-route/voided-page ::invoice-route/paid-page ::oi-routes/new ::invoice-route/import-page :invoice-glimpse :invoice-glimpse-textract-invoice} (:matched-route request))
"invoices"
(#{:pos-sales :pos-expected-deposits :pos-tenders :pos-refunds :pos-cash-drawer-shifts} (:matched-route request))
"sales"
(#{::payment-routes/all-page ::payment-routes/pending-page ::payment-routes/cleared-page ::payment-routes/voided-page } (:matched-route request))
(#{::payment-routes/all-page ::payment-routes/pending-page ::payment-routes/cleared-page ::payment-routes/voided-page} (:matched-route request))
"payments"
:else
nil)]
@@ -102,7 +104,7 @@
(when (can? (:identity request)
{:subject :invoice-page})
(list
(list
(menu-button- {"@click.prevent" "if (selected == 'invoices') {selected = null } else { selected = 'invoices'} "
:icon svg/accounting-invoice-mail}
"Invoices")
@@ -135,13 +137,26 @@
:hx-boost "true"}
"Voided")
(when (can? (:identity request)
{:subject :invoice
:activity :import})
(menu-button- {:href (bidi/path-for ssr-routes/only-routes
::invoice-route/import-page)
:active? (= ::invoice-route/import-page (:matched-route request))
:hx-boost "true"} "Import"))
:hx-boost "true"} "Import"))
(when (can? (:identity request)
{:subject :invoice
:activity :import})
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
:invoice-glimpse))
:active? (= :invoice-glimpse (:matched-route request))
:hx-boost "true"}
[:div.flex.gap-2
"Glimpse"
(tags/pill- {:color :secondary} "Beta")]))
(when (can? (:identity request)
@@ -272,42 +287,62 @@
:external-import-ledger)} "External Ledger Import")))))]))
(defn company-aside-nav- [_]
(defn company-aside-nav- [request]
[:ul {:class "space-y-2" :hx-boost "true"}
[:li
(menu-button- {:icon svg/vendors
:active? (= :company (:matched-route request))
:href (bidi/path-for ssr-routes/only-routes
:company)
:hx-boost true}
"My Company")]
[:li
(menu-button- {:icon svg/report
:active? (= :company-reports (:matched-route request))
:href (bidi/path-for ssr-routes/only-routes
:company-reports)
:hx-boost true}
"Reports")]
[:li
(menu-button- {:icon svg/report
:active? (= :company-expense-report (:matched-route request))
:href (bidi/path-for ssr-routes/only-routes
:company-expense-report)
:hx-boost true}
"Expense Report")]
(when (can? (:identity request)
{:subject :reconciliation-report})
[:li
(menu-button- {:icon svg/report
:active? (= :company-reconciliation-report (:matched-route request))
:href (bidi/path-for ssr-routes/only-routes
:company-reports)
:company-reconciliation-report)
:hx-boost true}
"Reports")]
"Bank Sync Report")])
[:li
(menu-button- {:icon svg/bank
:active? (= :company-plaid (:matched-route request))
:href (bidi/path-for ssr-routes/only-routes
:company-plaid)
:hx-boost true}
"Plaid Link")]
[:li
(menu-button- {:icon svg/bank
:active? (= :company-yodlee (:matched-route request))
:href (bidi/path-for ssr-routes/only-routes
:company-yodlee)
:hx-boost true}
"Yodlee Link")]
[:li
(menu-button- {:icon svg/government-building
:active? (= :company-1099 (:matched-route request))
:href (bidi/path-for ssr-routes/only-routes
:company-1099)
:hx-boost true}
"1099 Vendor Info"
)]])
"1099 Vendor Info")]])
(defn admin-aside-nav- [{:keys [matched-route] :as request}]
(defn admin-aside-nav- [{:keys [matched-route]}]
[:ul {:class "space-y-2" :x-data (hx/json {:selected "nil"})}
[:li
(menu-button- {:icon svg/dashboard

View File

@@ -44,7 +44,8 @@
(defn data-grid- [{:keys [headers thead-params id] :as params} & rest]
[:table (merge {:class "w-full text-sm text-left text-gray-500 dark:text-gray-400"}
(dissoc params :headers :thead-params))
[:thead (assoc thead-params :class "text-xs text-gray-800 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400")
[:thead (update thead-params :class #(-> "text-xs text-gray-800 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400"
(hh/add-class (or % ""))))
(into
[:tr]
headers)]
@@ -137,7 +138,7 @@
(a-button- (merge
(dissoc params :index :colspan)
{
"@click" "$dispatch('newRow', {index: (newRowIndex++)})"
"@click.prevent" "$dispatch('newRow', {index: (newRowIndex++)})"
:color :secondary
:hx-trigger "newRow"
:hx-vals (hiccup/raw "js:{index: event.detail.index }")

View File

@@ -175,10 +175,12 @@
(update :class (fnil hh/add-class "") default-input-classes)
(assoc :x-modelable "value")
(assoc :type "text")
(assoc "_" (hiccup/raw "init initDatepicker(me)"))
(assoc "@change" "value = $event.target.value; console.log(value)")
(assoc "hx-on" (hiccup/raw "changeDate: htmx.trigger(this, \"change\")
htmx:beforeCleanupElement: this.dp.destroy()"))
(assoc :x-data (hx/json {:dp nil}) )
(assoc :x-init " dp = initDatepicker($el);")
(assoc "@htmx:before-history-save" "destroyDatepicker(dp)" )
(assoc "@htmx:before-cleanup-element" "destroyDatepicker(dp)" )
(assoc "@change" "value = $event.target.value;")
(assoc "hx-on" (hiccup/raw "changeDate: htmx.trigger(this, \"change\") "))
(update :class #(str % (use-size size) " w-full"))
(dissoc :size))]])

View File

@@ -165,12 +165,13 @@
:else
[:div "No action possible."])]])
(defn default-render-step [linear-wizard step & {:keys [head body footer validation-route discard-route]}]
(defn default-render-step [linear-wizard step & {:keys [head body footer validation-route discard-route width-height-class]}]
(let [is-last? (= (step-key step) (last (steps linear-wizard)))]
(com/modal-card-advanced
{"@keydown.enter.prevent.stop" "if ($refs.next ) {$refs.next.click()}"
:class (str
"w-full h-full md:w-[750px] md:h-[600px]
(or width-height-class " md:w-[750px] md:h-[600px] ")
" w-full h-full
group-[.forward]/transition:htmx-swapping:opacity-0
group-[.forward]/transition:htmx-swapping:-translate-x-1/4
group-[.forward]/transition:htmx-swapping:scale-75

View File

@@ -1,12 +1,11 @@
(ns auto-ap.ssr.components.navbar
(:require
[auto-ap.graphql.utils :refer [is-admin?]]
[auto-ap.ssr-routes :as ssr-routes]
[auto-ap.ssr.company-dropdown :as cd]
[auto-ap.ssr.components.buttons :refer [icon-button-]]
[auto-ap.ssr.components.user-dropdown :as user-dropdown]
[auto-ap.ssr.svg :as svg]
[bidi.bidi :as bidi]))
(:require [auto-ap.graphql.utils :refer [is-admin? limited-clients]]
[auto-ap.ssr-routes :as ssr-routes]
[auto-ap.ssr.company-dropdown :as cd]
[auto-ap.ssr.components.buttons :refer [icon-button-]]
[auto-ap.ssr.components.user-dropdown :as user-dropdown]
[auto-ap.ssr.svg :as svg]
[bidi.bidi :as bidi]))
(defn navbar- [{:keys [client-selection client identity clients dd-env]}]
[:nav {:class "fixed z-30 w-full bg-white border-b border-gray-200 dark:bg-gray-800 dark:border-gray-700"}
@@ -39,7 +38,10 @@
:hx-target "#modal-holder"
:hx-swap "outerHTML"}
svg/search)
(cd/dropdown {:client-selection client-selection :client client :identity identity
:clients clients})
(let [limited-clients (limited-clients identity)]
(when (or (nil? limited-clients)
(> (count limited-clients) 1))
(cd/dropdown {:client-selection client-selection :client client :identity identity
:clients clients})))
(user-dropdown/dropdown {:identity identity})]]]])

View File

@@ -11,7 +11,8 @@
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"
)
:x-data (hx/json {:leftNavShow true})}
:x-data (hx/json {:leftNavShow true})
}
(navbar- {:client-selection client-selection
:clients clients
:client client