Updates page as needed.

This commit is contained in:
Bryce
2024-03-29 10:43:15 -07:00
parent 6496eea485
commit d34e125b6f
4 changed files with 19 additions and 24 deletions

View File

@@ -228,7 +228,7 @@
:else :else
"forward"))) "forward")))
(defn render-navigate [{ {:keys [wizard] :as request} :request to-step :to-step}] (defn render-navigate [{ {:keys [wizard] :as request } :request to-step :to-step oob :oob}]
(let [current-step (get-current-step wizard) (let [current-step (get-current-step wizard)
wizard (navigate wizard to-step) wizard (navigate wizard to-step)
new-step (get-current-step wizard) new-step (get-current-step wizard)
@@ -244,7 +244,8 @@
(assoc :step-params (assoc :step-params
(init-step-params new-step % request)))))))) (init-step-params new-step % request))))))))
:headers {"HX-reswap" (when transition-type "outerHTML swap:0.16s") :headers {"HX-reswap" (when transition-type "outerHTML swap:0.16s")
"x-transition-type" (or transition-type "none")}))) "x-transition-type" (or transition-type "none")}
:oob (or oob []))))
(def next-handler (def next-handler
(-> (fn [{:keys [wizard] :as request}] (-> (fn [{:keys [wizard] :as request}]

View File

@@ -22,6 +22,7 @@
[auto-ap.ssr.utils [auto-ap.ssr.utils
:refer [->db-id apply-middleware-to-all-handlers clj-date-schema :refer [->db-id apply-middleware-to-all-handlers clj-date-schema
entity-id form-validation-error html-response money strip entity-id form-validation-error html-response money strip
->OOBElements
wrap-schema-enforce]] wrap-schema-enforce]]
[auto-ap.time :as atime] [auto-ap.time :as atime]
[bidi.bidi :as bidi] [bidi.bidi :as bidi]
@@ -127,8 +128,6 @@
vendor)) vendor))
;; TODO account / vendor search should use allowances
(defrecord BasicDetailsStep [linear-wizard] (defrecord BasicDetailsStep [linear-wizard]
mm/ModalWizardStep mm/ModalWizardStep
(step-name [_] (step-name [_]
@@ -482,7 +481,8 @@
hx/trigger-click-or-enter) "Add another") hx/trigger-click-or-enter) "Add another")
(com/navigation-button {:class "w-48" :next-arrow? false (com/navigation-button {:class "w-48" :next-arrow? false
"@click" "$dispatch('modalclose') " "@click" "$dispatch('modalclose') "
"@keyup.enter.stop" "$dispatch('modalclose')"} "Close"))) "@keyup.enter.stop" "$dispatch('modalclose')"}
"Close")))
:footer :footer
nil nil
:validation-route ::route/new-wizard-navigate))) :validation-route ::route/new-wizard-navigate)))
@@ -494,7 +494,6 @@
:invoice/client (->db-id client)})) :invoice/client (->db-id client)}))
(form-validation-error (str "Invoice '" invoice-number "' already exists.")))) (form-validation-error (str "Invoice '" invoice-number "' already exists."))))
;; TODO warn on account usage based on allowance
(defn assert-invoice-amounts-add-up [{:keys [:invoice/expense-accounts :invoice/total]}] (defn assert-invoice-amounts-add-up [{:keys [:invoice/expense-accounts :invoice/total]}]
(let [expense-account-total (reduce + 0 (map (fn [x] (:invoice-expense-account/amount x)) expense-accounts))] (let [expense-account-total (reduce + 0 (map (fn [x] (:invoice-expense-account/amount x)) expense-accounts))]
@@ -592,24 +591,10 @@
(exception->4xx #(assert-not-locked client-id (:invoice/date invoice))) (exception->4xx #(assert-not-locked client-id (:invoice/date invoice)))
(let [transaction-result (audit-transact [transaction] (:identity request))] (let [transaction-result (audit-transact [transaction] (:identity request))]
(solr/touch-with-ledger (get-in transaction-result [:tempids "invoice"])) (solr/touch-with-ledger (get-in transaction-result [:tempids "invoice"]))
(mm/render-navigate {:request (assoc-in request [:multi-form-state :snapshot :db/id] (get-in transaction-result [:tempids "invoice"])) (assoc-in (mm/render-navigate {:request (assoc-in request [:multi-form-state :snapshot :db/id] (get-in transaction-result [:tempids "invoice"]))
:to-step :next-steps}) :to-step :next-steps
#_(html-response })
(@(resolve 'auto-ap.ssr.invoices/row*) [:headers "hx-trigger"] "invalidated")))))
identity
(dc/pull (dc/db conn) default-read (get-in transaction-result [:tempids "invoice"]))
{:flash? true
:request request})
:headers {"hx-trigger" "modalclose"
"hx-retarget" "#entity-table tbody"
"hx-reswap" "afterbegin"
#_(format "#entity-table tr[data-id=\"%d\"]" (get-in transaction-result [:tempids "invoice"]))})))
#_(html-response [:div]
:headers {"hx-trigger" "modalclose,invalidated"})))
@@ -676,6 +661,7 @@
[:label {:class "block mb-2 text-sm font-medium text-gray-900 dark:text-white"} "Default expense account"] [:label {:class "block mb-2 text-sm font-medium text-gray-900 dark:text-white"} "Default expense account"]
[:div.flex.gap-2.items-center (com/pill {:color :primary} account-name) [:div.flex.gap-2.items-center (com/pill {:color :primary} account-name)
(com/validated-save-button (cond-> {:errors form-errors (com/validated-save-button (cond-> {:errors form-errors
:color :secondary
;;:x-data (hx/json {}) ;;:x-data (hx/json {})
:class "w-24" :class "w-24"
:hx-put (hu/url (bidi/path-for ssr-routes/only-routes ::route/new-wizard-navigate) :hx-put (hu/url (bidi/path-for ssr-routes/only-routes ::route/new-wizard-navigate)

View File

@@ -1035,6 +1035,8 @@
(= "" (:check-number snapshot))) (= "" (:check-number snapshot)))
(throw (Exception. "Check number is required"))) (throw (Exception. "Check number is required")))
true)) true))
;; TODO just confirm that the outstanding balances haven't been surpassed
;; and that the invoices are still pending
result (exception->4xx result (exception->4xx
#(if (= :handwrite-check (:method snapshot)) #(if (= :handwrite-check (:method snapshot))
(add-handwritten-check request this snapshot) (add-handwritten-check request this snapshot)

View File

@@ -7,6 +7,7 @@
[clojure.string :as str] [clojure.string :as str]
[datomic.api :as dc] [datomic.api :as dc]
[hiccup2.core :as hiccup] [hiccup2.core :as hiccup]
[hiccup.compiler :refer [HtmlRenderer render-html]]
[malli.core :as mc] [malli.core :as mc]
[malli.core :as m] [malli.core :as m]
[malli.error :as me] [malli.error :as me]
@@ -15,6 +16,11 @@
[slingshot.slingshot :refer [throw+ try+]] [slingshot.slingshot :refer [throw+ try+]]
[taoensso.encore :refer [filter-vals]])) [taoensso.encore :refer [filter-vals]]))
(defrecord OOBElements [elements]
HtmlRenderer
(render-html [this]
(str/join "\n" (map render-html elements))))
(defn html-response [hiccup & {:keys [status headers oob] :or {status 200 headers {} oob []}}] (defn html-response [hiccup & {:keys [status headers oob] :or {status 200 headers {} oob []}}]
{:status status {:status status
:headers (into {"Content-Type" "text/html"} :headers (into {"Content-Type" "text/html"}