Hi,

https://gist.github.com/geraldodev/383684825c9bb9f32920

bound-input, function to be used when you want the data update key by key, and 
have no validation on it. You pass an identifier for a react ref, and the 
current value of the data (that comes from om/props). It needs a component that 
knows hows to identify itself.

(defui Operador
  static om/Ident
  (ident [this {:keys [id]}]
         [:operador/por-id id])
  static om/IQuery
  (query [this]
         '[:id :nome :email])
  Object
  (render [this]
          (let [{:keys [nome email]} (om/props this)]
            (dom/form
              nil
              (dom/div
                #js {:className "form-group"}
                (dom/label nil "Nome")
                (bound-input this {:ref :nome :value nome}))
              (dom/div
                #js {:className "form-group"}
                (dom/label nil "Email")
                (bound-input this {:ref :email :value email}))
              (dom/button
                #js
                {:className "btn"
                 :type "button"
                 :onClick (fn [e]
                            (let [reg (om/props this)]
                              (println reg)))}
                "Gravar")))))


That will issue a message like this for every change :
[(app/assoc-in {:ref :nome, :new-value "nezia ", :ident [:operador/por-id 11]})]

That can be executed by a function like:

(defmethod mutate 'app/assoc-in
  [{:keys [state] :as env} key {:keys [ref new-value ident]}]
  {:value ident
   :action #(swap! state assoc-in (conj ident ref) new-value)}

You can customize the message key by passing :mutate-key parameter to 
bound-input.

If you paste the gist into your app, there is a message that you can try on the 
shell that adds another "inactive operator" like this:

(om/transact!  reconciler `[(app/adiciona-desativado ~{:id 10 :nome "fesson" 
:email "[email protected]"}) :operadores-desativados]).

There are no remote on this. If you click Gravar (Save) it prints to console 
the current value of the Operador instance.

Please criticize if you can bear a non english speaker practitioner.

Regards,
Geraldo

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to