feat(ssr): migrate location-select to a Selmer template (Phase 2 — Selmer validated)
First interactive Transaction Edit component rendered from a Selmer template instead of
Hiccup/com/select, proving the render-file path + the Hiccup<->Selmer interop bridge on
real, e2e-covered markup.
- resources/templates/components/location-select.html: plain-HTML <select> with a
{% for %} over option maps + {% if opt.selected %}.
- location-select*: build options/selected/classes in Clojure (reusing
inputs/default-input-classes so styling can't drift), render via
sel/render->hiccup, and embed the fragment back into the still-Hiccup account row.
- skill: finalize selmer-conventions.md from this validated example (was a stub); add the
cookbook entry; scorecard marks the first Selmer component.
Verified on a fresh server: full suite 38 pass / 1 unrelated fail, swap 6/6,
transaction-edit 8/8 -- the Shared Location test selects through the Selmer <select>,
saves, and spreads Shared -> DT. Verified by string-match + e2e (not byte-parity:
hh/add-class is set-based so class order differs, CSS is order-independent).
Scope note: the modal's remaining attribute-heavy components delegate to the shared
com/typeahead / com/select / com/button-group-button; converting those is the
cross-cutting Phase 11 Selmer sweep, not a single-modal change (Open decision 2).
This commit is contained in:
@@ -21,11 +21,13 @@
|
||||
[auto-ap.ssr-routes :as ssr-routes]
|
||||
[auto-ap.ssr.common-handlers :refer [add-new-entity-handler]]
|
||||
[auto-ap.ssr.components :as com]
|
||||
[auto-ap.ssr.components.inputs :as inputs]
|
||||
[auto-ap.ssr.grid-page-helper :as helper]
|
||||
[auto-ap.ssr.transaction.common :refer [grid-page]]
|
||||
[auto-ap.ssr.components.multi-modal :as mm]
|
||||
[auto-ap.ssr.form-cursor :as fc]
|
||||
[auto-ap.ssr.hx :as hx]
|
||||
[auto-ap.ssr.selmer :as sel]
|
||||
[auto-ap.ssr.svg :as svg]
|
||||
[auto-ap.ssr.utils
|
||||
:refer [->db-id apply-middleware-to-all-handlers check-allowance
|
||||
@@ -36,6 +38,7 @@
|
||||
[bidi.bidi :as bidi]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clojure.edn :as edn]
|
||||
[clojure.string :as str]
|
||||
[datomic.api :as dc]
|
||||
[hiccup.util :as hu]
|
||||
[iol-ion.query :refer [dollars=]]
|
||||
@@ -153,20 +156,29 @@
|
||||
(:vendor/default-account clientized))))
|
||||
|
||||
(defn location-select*
|
||||
"The location <select> for an account row, rendered from a Selmer template
|
||||
(templates/components/location-select.html) -- the first interactive modal component
|
||||
migrated off Hiccup. Same options/selection/styling as the old com/select, emitted as
|
||||
plain HTML and embedded back into the Hiccup row via the interop bridge."
|
||||
[{:keys [name account-location client-locations value]}]
|
||||
(let [options (into (cond account-location
|
||||
[[account-location account-location]]
|
||||
(let [options (cond account-location
|
||||
[[account-location account-location]]
|
||||
|
||||
(seq client-locations)
|
||||
(into [["Shared" "Shared"]]
|
||||
(for [cl client-locations]
|
||||
[cl cl]))
|
||||
:else
|
||||
[["Shared" "Shared"]]))]
|
||||
(com/select {:options options
|
||||
:name name
|
||||
:value (or value (ffirst options))
|
||||
:class "w-full"})))
|
||||
(seq client-locations)
|
||||
(into [["Shared" "Shared"]]
|
||||
(for [cl client-locations]
|
||||
[cl cl]))
|
||||
|
||||
:else
|
||||
[["Shared" "Shared"]])
|
||||
selected (or value (ffirst options))
|
||||
classes (str/join " " (conj (vec inputs/default-input-classes) "w-full"))]
|
||||
(sel/render->hiccup
|
||||
"templates/components/location-select.html"
|
||||
{:name name
|
||||
:classes classes
|
||||
:options (for [[v label] options]
|
||||
{:value v :label label :selected (= v selected)})})))
|
||||
|
||||
(defn account-typeahead*
|
||||
[{:keys [name value client-id x-model]}]
|
||||
|
||||
Reference in New Issue
Block a user