 (defonce next-task-id (atom 0))
 (defonce next-card-id (atom 0))
 
-(defn create-task
+(defn create-task!
   "Create a task to display in a card"
   [name done]
   (swap! next-task-id inc)

        title-style #(if % :div.card__title--is-open :div.card__title)
        add-task (fn [card-id e]
                   (when (= "Enter" (.-key e))
                     (js/alert "Find the task and add one task to it")                 
                     (set! (.. e -target -value) "")
                   ))
        ]


(def card-list (r/atom []))

(defn add-task-to!
  [card-id task]
  (defn add-if! [card]
    (if (= card-id (:card-id card))
      (update-in card [:tasks] conj (create-task! task false))
      card))
  (swap! card-list #(mapv add-if! %)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(def init-card-list
  "Fake card list returned by the server"
  [(create-card!
     "1st card"
     "This is my first description"
     :bug-fix
     :backlog
     (create-task! "Done some stuff" true))
   (create-card!
     "2nd card"
     "This is my second description"
     :enhancement
     :under-dev
     (create-task! "Done some stuff" true)
     (create-task! "Done some more stuff" false))
   (create-card!
     "3rd card"
     "This is my third description"
     :bug-fix
     :under-dev)
   (create-card!
     "4th card"
     "This is my fourth description"
     :enhancement
