Makes groups possible
This commit is contained in:
@@ -74,6 +74,7 @@
|
||||
:client/name
|
||||
:client/code
|
||||
:client/locations
|
||||
:client/groups
|
||||
:client/matches
|
||||
:client/week-a-credits
|
||||
:client/week-b-credits
|
||||
@@ -277,6 +278,9 @@
|
||||
[:client/locations [:vector {:decode/arbitrary (fn [m] (if (map? m)
|
||||
(vals m)
|
||||
m))} :string]]
|
||||
[:client/groups [:vector {:decode/arbitrary (fn [m] (if (map? m)
|
||||
(vals m)
|
||||
m))} :string]]
|
||||
[:client/emails {:optional true} [:maybe (many-entity {}
|
||||
[:db/id [:or entity-id temp-id]]
|
||||
[:email-contact/description :string]
|
||||
@@ -394,6 +398,19 @@
|
||||
(com/data-grid-cell {:class "align-top"}
|
||||
(com/a-icon-button {"@click.prevent.stop" "$refs.p.remove()"} svg/x))))
|
||||
|
||||
(defn group-row [_]
|
||||
(com/data-grid-row
|
||||
{:x-ref "p"
|
||||
:x-data (hx/json {})}
|
||||
(com/data-grid-cell
|
||||
{}
|
||||
(com/validated-field {}
|
||||
(com/text-input {:name (fc/field-name)
|
||||
:value (fc/field-value)
|
||||
:class "w-24"})))
|
||||
(com/data-grid-cell {:class "align-top"}
|
||||
(com/a-icon-button {"@click.prevent.stop" "$refs.p.remove()"} svg/x))))
|
||||
|
||||
(defn feature-flag-row [_]
|
||||
(com/data-grid-row
|
||||
{:x-ref "p"
|
||||
@@ -1318,7 +1335,7 @@
|
||||
(edit-path [_ _] [])
|
||||
|
||||
(step-schema [_]
|
||||
(mut/select-keys (mm/form-schema linear-wizard) #{:client/feature-flags}))
|
||||
(mut/select-keys (mm/form-schema linear-wizard) #{:client/feature-flags :client/groups}))
|
||||
|
||||
(render-step [this _]
|
||||
(mm/default-render-step
|
||||
@@ -1335,7 +1352,19 @@
|
||||
(com/data-grid-new-row {:colspan 2
|
||||
:hx-get (bidi/path-for ssr-routes/only-routes ::route/new-feature-flag)
|
||||
:index (count (fc/field-value))}
|
||||
"New flag")))))
|
||||
"New flag"))))
|
||||
(fc/with-field :client/groups
|
||||
(com/validated-field
|
||||
{:errors (fc/field-errors)
|
||||
:label "Groups"}
|
||||
(com/data-grid {:headers [(com/data-grid-header {} "Group")
|
||||
(com/data-grid-header {:class "w-16"})]}
|
||||
(fc/cursor-map #(group-row %))
|
||||
(com/data-grid-new-row {:colspan 2
|
||||
:hx-get (bidi/path-for ssr-routes/only-routes ::route/new-group)
|
||||
:index (count (fc/field-value))}
|
||||
|
||||
"New group")))))
|
||||
:footer
|
||||
(mm/default-step-footer linear-wizard this :validation-route ::route/navigate)
|
||||
:validation-route ::route/navigate)))
|
||||
@@ -1387,14 +1416,17 @@
|
||||
(first step-key)))))
|
||||
(form-schema [_] form-schema-2)
|
||||
(submit [_ {:keys [multi-form-state request-method identity] :as request}]
|
||||
(let [snapshot (mc/decode
|
||||
(let [
|
||||
snapshot (mc/decode
|
||||
form-schema-2
|
||||
(:snapshot multi-form-state)
|
||||
mt/strip-extra-keys-transformer)
|
||||
entity (cond-> snapshot
|
||||
(= :post request-method) (assoc :db/id "new")
|
||||
(= :put request-method) (dissoc :client/code)
|
||||
|
||||
(:client/locked-until snapshot) (update :client/locked-until clj-time.coerce/to-date)
|
||||
(seq (:client/groups snapshot)) (update :client/groups #(mapv str/upper-case %))
|
||||
(seq (:client/bank-accounts snapshot)) (update :client/bank-accounts
|
||||
(fn [bank-accounts]
|
||||
(mapv
|
||||
@@ -1418,6 +1450,7 @@
|
||||
"name" (conj (or (:client/matches updated-client) [])
|
||||
(:client/name updated-client))
|
||||
"code" (:client/code updated-client)
|
||||
|
||||
"exact" (map str/upper-case (conj (or (:client/matches updated-client) [])
|
||||
(:client/name updated-client)))}]))
|
||||
(html-response
|
||||
@@ -1669,6 +1702,9 @@
|
||||
::route/new-match (add-new-primitive-handler [:step-params :client/matches]
|
||||
""
|
||||
match-row)
|
||||
::route/new-group (add-new-primitive-handler [:step-params :client/groups]
|
||||
""
|
||||
group-row)
|
||||
::route/new-location-match (add-new-entity-handler [:step-params :client/location-matches]
|
||||
(fn [cursor _] (location-match-row cursor)))
|
||||
::route/new-email-contact (add-new-entity-handler [:step-params :client/emails]
|
||||
|
||||
Reference in New Issue
Block a user