This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defsc Price [this {:keys [value type] :as props} {:keys [edit-mode?]}] | |
{:query [:_id | |
:value | |
:type | |
:currency | |
fs/form-config-join] | |
:form-fields #{:value} | |
:ident [:prices/by-id :_id]} | |
(dom/div | |
(condp = type | |
"HOURLY_RATE" | |
(dom/div | |
:.form-group.mb-0 | |
(dom/label | |
:.col-sm-4.control-label "Hourly price") | |
(dom/div | |
:.col-sm-8 | |
(if-not edit-mode? | |
(dom/p | |
:.form-control-static value) | |
(dom/input | |
:.form-control | |
{:type "text" | |
:value value | |
:onChange #(m/set-string! this :value :event %) | |
:onBlur #(js/console.log (fs/dirty-fields props true))}))))))) | |
(def ui-price (prim/factory Price {:keyfn :_id})) | |
(defsc ListingForm | |
[this {:keys [ui/edit-mode? prices _id] :as props} {:keys []}] | |
{:query [:_id | |
{:prices (prim/get-query Price)} | |
:ui/edit-mode? | |
fs/form-config-join] | |
:form-fields #{:prices} | |
:ident [:listing/by-id :_id] | |
:initial-state {:ui/edit-mode? "listing-details"}} | |
(let [listing-edit? (= edit-mode? "listing-details") | |
entity-ident (prim/get-ident this (prim/props this))] | |
(dom/div | |
(dom/p :.title "Listing Details") | |
(dom/form | |
:.form-horizontal | |
(dom/div | |
:.row | |
(dom/div | |
:.col-md-6 | |
(mapv (fn [p] (ui-price (prim/computed p {:edit-mode? listing-edit?}))) prices))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment