 (defui UI
   static om/IQuery
   (query [this]
-         (vec (concat (om/get-query TodoListUI)
-                      (om/get-query NewTodoItemUI))))
+         [:tudu.item/editing
+          {:tudu/items (om/get-query TodoItemUI)}])
   Object
   (render [this]
-          (let [props (om/props this)]
+          (let [props (om/props this)
+                nti-cprops {:on-title-change (on-change-cb this task-title-change)
+                            :create-task #(create-task this %)}]
             (dom/div nil
-                     (new-todo-item-ui props)
+                     (new-todo-item-ui (om/computed props nti-cprops))
                      (todo-list-ui props)))))
 
 (defmulti read om/dispatch)

  Object
  (render [this]
          (let [{:keys [id status title]} (om/props this)
                {:keys [close-item]} (om/get-computed this)
                closed? (= status :close)
                class-name (str "todo-list-item-title status-" (name status))]
            (dom/div #js {:className "todo-list-item" :key (str "todo-item-" id)}
                     (dom/input #js {:type "checkbox" :disabled closed?
                                     :checked closed?
                                     :onClick #(close-item id)})

                     (dom/span #js {:className class-name} title)))))


                            :tudu.item/editing :tudu/items]))

(defui NewTodoItemUI
  Object
  (render [this]
          (let [{:keys [tudu.item/editing]} (om/props this)
                {:keys [title]} editing
                {:keys [create-task on-title-change]} (om/get-computed this)]
            (dom/div #js {:className "new-todo-item-form"}
                      (dom/div #js {:className "form-group"}
                               (dom/label nil "Task")
                               (dom/input #js {:value title
                                               :onChange on-title-change}))
                      (dom/button #js {:className "new-todo-item-create"
                                       :onClick #(create-task editing)}
                                  "Create")))))

(def new-todo-item-ui (om/factory NewTodoItemUI))
