-
-
Save jlongster/757ab6be90d0643bf4a3 to your computer and use it in GitHub Desktop.
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
(defui TransactionRow | |
static om/Ident | |
(ident [this {:keys [id]}] [:transactions/by-id id]) | |
static om/IQuery | |
(query [this] '[:id :amount :description :date :from_acct :to_acct]) | |
Object | |
(render [this] | |
(println "rendering" (:id (om/props this))) | |
(let [{:keys [columns widths formatters on-edit]} (om/get-computed this) | |
id (:id (om/props this)) | |
data (into {} (map (fn [c] [c (get (om/props this) c)]) columns))] | |
(dom/div | |
#js {:key id} | |
(map-indexed | |
(fn [idx [col value]] | |
(let [formatter (get formatters col) | |
text (if (and formatter value) | |
(formatter value) | |
(or value ""))] | |
(dom/input | |
#js {:key (name col) | |
:defaultValue text | |
:onBlur | |
#(let [value (.-value (.-target %))] | |
(om/transact! | |
this | |
`[(transaction/update ~(assoc {:id id} col value))]))}))) | |
data))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment