Updates page as needed.
This commit is contained in:
@@ -228,7 +228,7 @@
|
||||
:else
|
||||
"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)
|
||||
wizard (navigate wizard to-step)
|
||||
new-step (get-current-step wizard)
|
||||
@@ -244,7 +244,8 @@
|
||||
(assoc :step-params
|
||||
(init-step-params new-step % request))))))))
|
||||
: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
|
||||
(-> (fn [{:keys [wizard] :as request}]
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
[auto-ap.ssr.utils
|
||||
:refer [->db-id apply-middleware-to-all-handlers clj-date-schema
|
||||
entity-id form-validation-error html-response money strip
|
||||
->OOBElements
|
||||
wrap-schema-enforce]]
|
||||
[auto-ap.time :as atime]
|
||||
[bidi.bidi :as bidi]
|
||||
@@ -127,8 +128,6 @@
|
||||
vendor))
|
||||
|
||||
|
||||
;; TODO account / vendor search should use allowances
|
||||
|
||||
(defrecord BasicDetailsStep [linear-wizard]
|
||||
mm/ModalWizardStep
|
||||
(step-name [_]
|
||||
@@ -482,7 +481,8 @@
|
||||
hx/trigger-click-or-enter) "Add another")
|
||||
(com/navigation-button {:class "w-48" :next-arrow? false
|
||||
"@click" "$dispatch('modalclose') "
|
||||
"@keyup.enter.stop" "$dispatch('modalclose')"} "Close")))
|
||||
"@keyup.enter.stop" "$dispatch('modalclose')"}
|
||||
"Close")))
|
||||
:footer
|
||||
nil
|
||||
:validation-route ::route/new-wizard-navigate)))
|
||||
@@ -494,7 +494,6 @@
|
||||
:invoice/client (->db-id client)}))
|
||||
(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]}]
|
||||
(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)))
|
||||
(let [transaction-result (audit-transact [transaction] (:identity request))]
|
||||
(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"]))
|
||||
:to-step :next-steps})
|
||||
#_(html-response
|
||||
(@(resolve 'auto-ap.ssr.invoices/row*)
|
||||
|
||||
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"})))
|
||||
(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
|
||||
})
|
||||
[:headers "hx-trigger"] "invalidated")))))
|
||||
|
||||
|
||||
|
||||
@@ -676,6 +661,7 @@
|
||||
[: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)
|
||||
(com/validated-save-button (cond-> {:errors form-errors
|
||||
:color :secondary
|
||||
;;:x-data (hx/json {})
|
||||
:class "w-24"
|
||||
:hx-put (hu/url (bidi/path-for ssr-routes/only-routes ::route/new-wizard-navigate)
|
||||
|
||||
@@ -1035,6 +1035,8 @@
|
||||
(= "" (:check-number snapshot)))
|
||||
(throw (Exception. "Check number is required")))
|
||||
true))
|
||||
;; TODO just confirm that the outstanding balances haven't been surpassed
|
||||
;; and that the invoices are still pending
|
||||
result (exception->4xx
|
||||
#(if (= :handwrite-check (:method snapshot))
|
||||
(add-handwritten-check request this snapshot)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
[clojure.string :as str]
|
||||
[datomic.api :as dc]
|
||||
[hiccup2.core :as hiccup]
|
||||
[hiccup.compiler :refer [HtmlRenderer render-html]]
|
||||
[malli.core :as mc]
|
||||
[malli.core :as m]
|
||||
[malli.error :as me]
|
||||
@@ -15,6 +16,11 @@
|
||||
[slingshot.slingshot :refer [throw+ try+]]
|
||||
[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 []}}]
|
||||
{:status status
|
||||
:headers (into {"Content-Type" "text/html"}
|
||||
|
||||
Reference in New Issue
Block a user