                 (if (:edit state)
                   [:span
                    [:button.big {:on-click #(end-edit owner)} "Cancel"]
-                   [:button.big {:on-click #(save-deck owner)} "Save"]]
+                   [:button.big {:on-click #(save-deck cursor owner)} "Save"]]
                   [:span
                    [:button.big {:on-click #(handle-delete cursor owner)} "Delete"]
                    [:button.big {:on-click #(edit-deck owner)} "Edit"]])

  (om/set-state! owner :edit false)
  (-> owner (om/get-node "viewport") js/$ (.removeClass "edit")))

(defn save-deck [owner]
  (end-edit owner)
  (let [deck (om/get-state owner :deck)
        decks (:decks @app-state)
        cards (for [card (:cards deck)]
                {:qty (:qty card) :card (get-in card [:card :title])})
        data (assoc deck :cards cards)]
    (if-let [id (:_id deck)]
      (swap! app-state assoc :decks (map #(if (= id (:_id %)) deck %) decks))
      (swap! app-state assoc :decks (conj decks deck)))
    (go (let [response (<! (POST "/data/decks/" data :json))]))))

(defn match [{:keys [side faction]} query]

           [:div.deck-collection
            (if (empty? decks)
              [:h4 "You have no deck"]
              (for [deck (sort-by :date > decks)]
                [:div.deckline {:class (when (= (get-in state [:deck :_id]) (:_id deck)) "active")
                                :on-click #(om/set-state! owner :deck deck)}
                 [:img {:src (image-url (:identity deck))}]
                 [:h4 (:name deck)]
                 [:div.float-right (-> (:date deck) js/Date. js/moment (.format "MMM Do YYYY - HH:mm"))]
                 [:p (get-in deck [:identity :title])]]))]]

          [:div.decklist
