   (let [[type _] (str/split selected #"-")]
     type))
 
+(defn programmes-div [programmes owner]
+  (reify
+    om/IRender
+    (render [_]
+      (html
+       ;; hide div if we've already chosen something
+       [:div {:id "programmes" :class (if (:active programmes) "hidden" "")}
+        [:h1 "Programmes"]
+        (om/build programmes-table programmes)]))))
+
 (defn programmes-table [cursor owner]
   (reify
     om/IRender

        ;; TODO sort out duplication here, wrap (on/build table ...) calls probably.
        ;;
        (let [{:keys [programmes projects properties devices sensors sensor-select]} tables]
          (println ">>>> Sensors: " sensors)
          ;; (println "Tables: " tables)
          (html [:div
                 ;;(om/build clear-tables data)
                 [:h1 {:id "programmes"} (:title data)]
                 (om/build programmes-table programmes)

                 [:h2 {:id "projects"} "Projects"]
                 [:ul {:class "breadcrumb"}
                  [:li (title-for programmes)]]
                 (om/build table projects {:opts {:histkey :projects}})

                 [:h2  {:id "properties"} "Properties"]
                 [:ul {:class "breadcrumb"}

                                                       selection-key
                                                       template
                                                       nav-event)]
      (doseq [a active-components]
        (om/update! data (vector a :active) true))
      
      ;; (println "Nav Event: " nav-event)
      ;; (println "To Clear: " to-clear)
      ;; (println "URI: " uri " for path " path " selection-key " selection-key)
      (doseq [c to-clear]
        (om/update! data (vector c :active) false)
        (om/update! data (vector c :data) [])
        (om/update! data (vector c :selected) nil))
      
