 
 (declare add-column! current-columns)
 
-(defn- document-accept-drop!
-  ([document-id state new-pages target-idx]
-   (go
-     (println "dropping" (pr-str (map :id new-pages)) "on document" document-id
-              (str "(at index " target-idx ")"))
-     (let [document (om/value (get-in state [:documents document-id]))]
-       (<! (api/update-document! (update document :pages
-                                         (fn [pages]
-                                           (data/insert-pages pages
-                                                              new-pages
-                                                              target-idx)))))
-       (println "Saved!")
-       ;; indicate successful drop
-       true)))
-  ([state new-pages target-idx]
-   (go
-     (println "Dropping pages on unsaved document...")
-     (let [document (<! (api/save-new-document! {:title "New Document"
-                                                 :pages new-pages}
-                                                "inbox"))]
-       ;; TODO: We need to be able to change our own ID
-       (when document
-         (add-column! (current-columns state) [:document (:id document)])
-         true)))))
-
 (defrecord DocumentColumnSource [id document-id]
   ColumnSource
   (column-title [_ state]
-    (if document-id
-      (get-in state [:documents document-id :title]
-              "Untitled Document")
-      "Unsaved Document"))
+    (get-in state [:documents document-id :title]
+            "Untitled Document"))
   (column-header-url [_]
-    (when document-id
-      (nav/document-route {:id document-id})))
+    (nav/document-route {:id document-id}))
   (column-pages [_ state]
     (get-in state
             [:documents document-id :pages]
             []))
   (remove-pages! [_ state page-ids]
     (go
-      (when document-id
-        (if-let [document (om/value (get-in state [:documents document-id]))]
-          (<! (api/update-document! (update document
-                                            :pages
-                                            #(remove (comp (set page-ids) :id) %))))
-          (js/console.error (str "[DocumentColumnSource] Failed to get document " document-id)
-                            {:document-id document-id})))))
+      (if-let [document (om/value (get-in state [:documents document-id]))]
+        (<! (api/update-document! (update document
+                                          :pages
+                                          #(remove (comp (set page-ids) :id) %))))
+        (js/console.error (str "[DocumentColumnSource] Failed to get document " document-id)
+                          {:document-id document-id}))))
   ColumnDropTarget
   (accept-drop! [_ state new-pages target-idx]
-    (if-not document-id
-      (document-accept-drop! state new-pages target-idx)
-      (document-accept-drop! document-id state new-pages target-idx)))
+    (go
+      (println "dropping" (pr-str (map :id new-pages)) "on document" document-id
+               (str "(at index " target-idx ")"))
+      (let [document (om/value (get-in state [:documents document-id]))]
+        (<! (api/update-document! (update document :pages
+                                          (fn [pages]
+                                            (data/insert-pages pages
+                                                               new-pages
+                                                               target-idx)))))
+        (println "Saved!")
+        ;; indicate successful drop
+        true)))
   om/IWillMount
   (will-mount [_]
-    (assert (or (nil? document-id)
-                (number? document-id)))
-    (when document-id
-      (api/fetch-documents! [document-id]))))
+    (assert (number? document-id))
+    (api/fetch-documents! [document-id])))
+
+(defrecord NewDocumentColumnSource [id]
+  ColumnSource
+  (column-title [_ _]
+    "Create New Document")
+  (column-header-url [_] nil)
+  (column-pages [_ _] [])
+  (remove-pages! [_ state page-ids]
+    (assert false "Can't remove pages from NewDocumentColumnSource"))
+  ColumnDropTarget
+  (accept-drop! [_ state new-pages _]
+    (go
+      (println "Dropping pages on unsaved document...")
+      (let [document (<! (api/save-new-document! {:title "New Document"
+                                                  :pages new-pages}
+                                                 "inbox"))]
+        (when document
+          (add-column! (current-columns state) [:document (:id document)])
+          true)))))
 
 (defn- inbox-page-drag-over [page owner store-idx! e]
   ;; Calculcate the center position for this image and set idx to the

      (let [key (case k
                  "d" :document
                  "f" :file
                  "i" :inbox)
            value (try (let [n (js/parseInt v 10)] (when (integer? n) n)) (catch js/Error e nil))]
        [key value]))))


  (s/join "," (for [column columns]
                (match [column]
                  [[:document id]] (str "d:" id)
                  [[:inbox _]] "i"
                  [[:new-document _]] "n"))))

(defn- current-columns [props]
  (-> (or (get-in props [:navigation :query-params :columns])
          "i,n")
      (parse-column-param)))

(defn- add-column! [columns column]
