                     :keywords? true}))))))
     (recur)))
 
-;; TODO histkey is really id key. resolve name confusion.
-(defn table [cursor owner {:keys [histkey path]}]
-  (reify
-    om/IRender
-    (render [_]
-      ;; Select the first row
-      ;;(put! out {:type :row-selected :row (first (om/get-state owner :data))})
-      (let [cols (get-in cursor [:header :cols])
-            table-id (str (name histkey) "-table")
-            history (om/get-shared owner :history)]
-        (dom/div #js {:id (str table-id "-container")}
-         (dom/table
-          #js {;; :id table-id
-               :className "table table-hover hecuba-table"} ;; table-hover table-stripedso,
-          (dom/thead
-           nil
-           (dom/tr
-            nil
-            (into-array
-             (for [[_ {:keys [label]}] cols]
-               (dom/th nil label)))))
-          (dom/tbody
-           nil
-           (into-array
-            (for [{:keys [id href ] :as row} (-> cursor :data
-                                                (cond-> path path))]
-              (dom/tr
-               #js {:onClick (fn [_ _ ]
-                               (om/update! cursor :selected id)
-                               (history/update-token-ids! history histkey id))
-                    :className (if (= id (:selected cursor)) "success")
-                    ;; TODO use this to scroll the row into view.
-                    ;; Possible solution here: http://stackoverflow.com/questions/1805808/how-do-i-scroll-a-row-of-a-table-into-view-element-scrollintoview-using-jquery
-                    :id (str table-id "-selected")}
-               (into-array
-                (for [[k {:keys [href]}] cols]
-                  (let [k (if (vector? k) k (vector k))]
-                    (dom/td nil (if href
-                                  (dom/a #js {:href (get row href)} (get-in row k))
-                                  (get-in row k))))))))))))))))
-
 (defn device-detail [{:keys [selected data] :as cursor} owner]
   (om/component
    (let [row      (first (filter #(= (:id %) selected) data))]

           [:li [:a
                 {:onClick (fn [_ _]
                             (history/update-token-ids! history :properties nil)
                             (fixed-scroll-to-element "projects-div"))}
                 (title-for properties :title-key :addressStreetTwo)]]]
          (om/build table devices {:opts {:histkey :devices}})])))))

(defn programmes-tab [data owner]
  (let [{tables :tables} data]
    (reify

                             (history/update-token-ids! history :programmes nil)
                             (fixed-scroll-to-element "programmes-div"))}
                 (title-for programmes)]]]
          (om/build projects-table projects {:opts {:histkey :projects}})])))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; properties
(defn properties-table [properties owner]
  (reify
    om/IRender
    (render [_]
      (let [table-id   "properties-table"
            history    (om/get-shared owner :history)]
        (html
         [:table {:className "table table-hover"}
          [:thead
           [:tr [:th "Address"] [:th "Country"]]]
          [:tbody
           (for [row (sort-by :name (:data properties))]
             (let [{:keys [id addressStreetTwo country]} row]
               [:tr {:onClick (fn [_ _]
                                (om/update! properties :selected id)
                                (history/update-token-ids! history :properties id)
                                (fixed-scroll-to-element "devices-div"))
                     :className (if (= id (:selected properties)) "success")
                     :id (str table-id "-selected")}
                [:td addressStreetTwo]
                [:td country]]))]])))))

(defn properties-div [tables owner]
  (reify
