progress on combinining everything

This commit is contained in:
2025-03-07 11:51:36 -08:00
parent 17993a0dee
commit 0a797fea3a
4 changed files with 91 additions and 98 deletions

File diff suppressed because one or more lines are too long

View File

@@ -113,6 +113,10 @@
(= :secondary (:color params)) (str " text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700")
(= :primary (:color params)) (str " text-white bg-green-500 hover:bg-green-600 focus:ring-green-300 dark:bg-green-600 dark:hover:bg-green-700 ")
(= :secondary-light (:color params)) (str " text-blue-800 bg-white-200 border-gray-100 border hover:bg-blue-100 focus:ring-blue-100 dark:bg-blue-400 dark:hover:bg-blue-800 ")
(not (nil? (:color params)))
(str " text-white " (bg-colors (:color params) (:disabled params)))
(nil? (:color params))
(str " bg-white dark:bg-gray-600 border-gray-300 dark:border-gray-700 text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-100 font-medium border border-gray-300 dark:border-gray-700")))
(assoc :tabindex 0)

View File

@@ -21,7 +21,7 @@
children))
(defn badge- [params & children]
[:div (merge params {:class (-> (hh/add-class "absolute inline-flex items-center justify-center w-6 h-6 text-xs font-black text-white
[:div (merge params {:class (-> (hh/add-class "absolute inline-flex items-center z-10 justify-center w-6 h-6 text-xs font-black text-white
border-3 border-white rounded-full -top-2 -right-2 dark:border-gray-900"
(:class params)
)

View File

@@ -794,7 +794,7 @@
[])
(step-schema [_]
[:map])
(mut/select-keys (mm/form-schema linear-wizard) #{:transaction/accounts}))
(render-step [this {{:keys [snapshot] :as multi-form-state} :multi-form-state :as request}]
(mm/default-render-step
@@ -804,105 +804,94 @@
{}
[:div
(payment-info-view request)
[:div.mt-4
[:h2.text-xl.font-bold.mb-6 "Select an Action"]
[:div {:x-data "{ activeForm: null }"}
[:div {:class "flex space-x-2 mb-4"}
(com/button-group {:name "method"}
(com/button-group-button {"@click" "activeForm = 'payment'" :value "payment" ":class" "{ '!bg-primary-200 text-primary-800': activeForm === 'payment'}" :class "relative"}
(let [count (count-payment-matches request)]
(when (> count 0)
(com/badge {:color "green"} (str count))))
"Link to payment")
(com/button-group-button {"@click" "activeForm = 'unpaid'" :value "unpaid" ":class" "{ '!bg-primary-200 text-primary-800': activeForm === 'unpaid'}" :class "relative"}
(let [count (count-unpaid-invoice-matches request)]
(when (> count 0)
(com/badge {:color "green"} (str count))))
"Link to unpaid invoices")
(com/button-group-button {"@click" "activeForm = 'autopay'" :value "autopay" ":class" "{ '!bg-primary-200 text-primary-800': activeForm === 'autopay'}" :class "relative"}
(let [count (count-autopay-invoice-matches request)]
(when (> count 0)
(com/badge {:color "green"} (str count))))
"Link to autopay invoices")
(com/button-group-button {"@click" "activeForm = 'rule'" :value "rule" ":class" "{ '!bg-primary-200 text-primary-800': activeForm === 'rule'}" :class "relative"}
(let [count (count-rule-matches request)]
(when (> count 0)
(com/badge {:color "green"} (str count))))
"Apply rule")
(com/button-group-button {"@click" "activeForm = 'manual'" :value "manual" ":class" "{ '!bg-primary-200 text-primary-800': activeForm === 'manual'}"}
"Manual"))]
[:div {:x-show "activeForm === 'payment'", :x-transition:enter "transition ease-out duration-500", :x-transition:enter-start "opacity-0 transform scale-95", :x-transition:enter-end "opacity-100 transform scale-100"}
(payment-matches-view request)]
[:div {:x-show "activeForm === 'unpaid'", :x-transition:enter "transition ease-out duration-500", :x-transition:enter-start "opacity-0 transform scale-95", :x-transition:enter-end "opacity-100 transform scale-100"}
(unpaid-invoices-view request)]
[:div {:x-show "activeForm === 'autopay'", :x-transition:enter "transition ease-out duration-500", :x-transition:enter-start "opacity-0 transform scale-95", :x-transition:enter-end "opacity-100 transform scale-100"}
(autopay-invoices-view request)]
[:div {:x-show "activeForm === 'rule'", :x-transition:enter "transition ease-out duration-500", :x-transition:enter-start "opacity-0 transform scale-95", :x-transition:enter-end "opacity-100 transform scale-100"}
(transaction-rules-view request)]
[:div {:x-show "activeForm === 'manual'", :x-transition:enter "transition ease-out duration-500", :x-transition:enter-start "opacity-0 transform scale-95", :x-transition:enter-end "opacity-100 transform scale-100"}
[:div {}
(fc/with-field :transaction/accounts
(com/validated-field
{:errors (fc/field-errors)}
(com/data-grid {:headers [(com/data-grid-header {} "Account")
(com/data-grid-header {:class "w-32"} "Location")
(com/data-grid-header {:class "w-16"} "$")
(com/data-grid-header {:class "w-16"})]}
(fc/cursor-map #(transaction-account-row* {:value %
:client-id (:transaction/client snapshot)}))
;; Radio selection for the different options
[:div {:x-data (hx/json {:selectedAction nil})}
;; Option cards with counts as badges
[:div.space-y-4
;; Link to Payment Option
[:div.border.rounded-lg.p-4.transition-colors.duration-150
{#_#_:class "hover:border-blue-500 cursor-pointer"
:class {:bg-blue-50 "selectedAction === 'payment'"}
"@click" "selectedAction = 'payment'"}
[:div.flex.justify-between.items-center
[:div.font-semibold "Link to Payment"]
(let [count (count-payment-matches request)]
[:div.bg-blue-100.text-blue-800.rounded-full.px-2.py-1.text-xs.font-medium
(str count " " (if (= count 1) "match" "matches"))])]]
;; Link to Autopay Invoices Option
[:div.border.rounded-lg.p-4.transition-colors.duration-150
{#_#_:class "hover:border-blue-500 cursor-pointer"
:class {:bg-blue-50 "selectedAction === 'autopay'"}
"@click" "selectedAction = 'autopay'"}
[:div.flex.justify-between.items-center
[:div.font-semibold "Link to Autopay Invoices"]
(let [count (count-autopay-invoice-matches request)]
[:div.bg-blue-100.text-blue-800.rounded-full.px-2.py-1.text-xs.font-medium
(str count " " (if (= count 1) "match" "matches"))])]]
;; Link to Unpaid Invoices Option
[:div.border.rounded-lg.p-4.transition-colors.duration-150
{#_#_:class "hover:border-blue-500 cursor-pointer"
:class {:bg-blue-50 "selectedAction === 'unpaid'"}
"@click" "selectedAction = 'unpaid'"}
[:div.flex.justify-between.items-center
[:div.font-semibold "Link to Unpaid Invoices"]
(let [count (count-unpaid-invoice-matches request)]
[:div.bg-blue-100.text-blue-800.rounded-full.px-2.py-1.text-xs.font-medium
(str count " " (if (= count 1) "match" "matches"))])]]
;; Apply Transaction Rule Option
[:div.border.rounded-lg.p-4.transition-colors.duration-150
{#_#_:class "hover:border-blue-500 cursor-pointer"
:class {:bg-blue-50 "selectedAction === 'rule'"}
"@click" "selectedAction = 'rule'"}
[:div.flex.justify-between.items-center
[:div.font-semibold "Apply Transaction Rule"]
(let [count (count-rule-matches request)]
[:div.bg-blue-100.text-blue-800.rounded-full.px-2.py-1.text-xs.font-medium
(str count " " (if (= count 1) "match" "matches"))])]]
;; Manually Code Option
[:div.border.rounded-lg.p-4.transition-colors.duration-150
{#_#_:class "hover:border-blue-500 cursor-pointer"
:class {:bg-blue-50 "selectedAction === 'manual'"}
"@click" "selectedAction = 'manual'"}
[:div.flex.justify-between.items-center
[:div.font-semibold "Manually Code Transaction"]
[:div.bg-gray-100.text-gray-800.rounded-full.px-2.py-1.text-xs.font-medium "Always available"]]]]
;; Display selected content based on choice
[:div.mt-6 {:x-show "selectedAction !== null"}
;; Link to Payment
[:div {:x-show "selectedAction === 'payment'"}
[:h3.text-lg.font-bold.mb-4 "Available Payments"]
(payment-matches-view request)]
;; Link to Autopay Invoices
[:div {:x-show "selectedAction === 'autopay'"}
[:h3.text-lg.font-bold.mb-4 "Available Autopay Invoices"]
(autopay-invoices-view request)]
;; Link to Unpaid Invoices
[:div {:x-show "selectedAction === 'unpaid'"}
[:h3.text-lg.font-bold.mb-4 "Available Unpaid Invoices"]
(unpaid-invoices-view request)]
;; Apply Transaction Rules
[:div {:x-show "selectedAction === 'rule'"}
[:h3.text-lg.font-bold.mb-4 "Available Transaction Rules"]
(transaction-rules-view request)]
;; Manually Code
[:div {:x-show "selectedAction === 'manual'"}
[:div.p-4.bg-blue-50.rounded-lg
[:h3.text-lg.font-bold.mb-2 "Manual Coding Instructions"]
[:p "To manually code this transaction:"]
[:ol.list-decimal.pl-6.mt-2
[:li "Click \"Done\" below to proceed"]
[:li "Go to the \"Accounting Codes\" tab"]
[:li "Add accounts and amounts as needed"]
[:li "Save your changes"]]]]]]]])
(com/data-grid-new-row {:colspan 4
:hx-get (bidi/path-for ssr-routes/only-routes
::route/edit-wizard-new-account)
:row-offset 0
:index (count (fc/field-value))
:tr-params {:hx-vals (hx/json {:client-id (:transaction/client snapshot)})}}
"New account")
(com/data-grid-row {}
(com/data-grid-cell {})
(com/data-grid-cell {:class "text-right"} [:span.font-bold.text-right "TOTAL"])
(com/data-grid-cell {:id "total"
:class "text-right"
:hx-trigger "change from:closest form target:.amount-field"
:hx-put (bidi.bidi/path-for ssr-routes/only-routes ::route/account-total)
:hx-target "this"
:hx-swap "innerHTML"}
(account-total* request))
(com/data-grid-cell {}))
(com/data-grid-row {}
(com/data-grid-cell {})
(com/data-grid-cell {:class "text-right"} [:span.font-bold.text-right "BALANCE"])
(com/data-grid-cell {:id "total"
:class "text-right"
:hx-trigger "change from:closest form target:.amount-field"
:hx-put (bidi.bidi/path-for ssr-routes/only-routes ::route/account-balance)
:hx-target "this"
:hx-swap "innerHTML"}
(account-balance* request))
(com/data-grid-cell {}))
(com/data-grid-row {}
(com/data-grid-cell {})
(com/data-grid-cell {:class "text-right"} [:span.font-bold.text-right "TRANSACTION TOTAL"])
(com/data-grid-cell {:class "text-right"}
(format "$%,.2f" (Math/abs (:transaction/amount snapshot))))
(com/data-grid-cell {})))))]]] ])
:footer
(mm/default-step-footer linear-wizard this :validation-route ::route/edit-wizard-navigate
:next-button (com/button {:color :primary :x-ref "next" :class "w-32"} "Done"))
:validation-route ::route/edit-wizard-navigate)))
(defrecord EditWizard [_ current-step]
mm/LinearModalWizard
(hydrate-from-request
@@ -921,7 +910,7 @@
(-> mm/default-form-props
(assoc :hx-post
(str (bidi/path-for ssr-routes/only-routes ::route/edit-submit))))
:render-timeline? true))
:render-timeline? false))
(steps [_]
[:basic-details
:links