 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; properties
-(defn slugify-property
-  "Create a slug for a property in the UI"
-  [property]
-  (assoc property :slug (apply str (interpose ", " (->> (vector (:property_code property) (:address_street_two property))
-                                                        (keep identity)
-                                                        (remove empty?))))))
-
 (defmulti properties-table-html (fn [properties owner] (:fetching properties)))
 (defmethod properties-table-html :fetching [properties owner]
   (fetching-row properties))


(defn projects-div [data owner]
  (reify
    om/IDidUpdate
    (did-update [_ prev-props prev-state]
      (let [{:keys [programmes projects active-components]} data
            new-programme_id (:programmes active-components)]

        ;; handle selection in programme table
        (when-not new-programme_id
          (om/update! projects :data [])
          (om/update! projects :selected nil))

        ;; get the data if we have a new id
        (if (and new-programme_id
                 (not (= (:programme_id projects) new-programme_id)))
          (do
            (om/update! projects :fetching :fetching)
            (GET (str "/4/programmes/" new-programme_id "/projects/")
                 {:handler  (fn [x]
                              ;; (println "Fetching projects for programme: " new-programme_id)
                              (om/update! projects :data (mapv slugify-project x))
                              (om/update! projects :fetching (if (empty? x) :no-data :has-data))
                              (om/update! projects :selected nil))
                  :error-handler (fn [{:keys [status status-text]}]
                                   (om/update! projects :fetching :error)
                                   (om/update! projects :error-status status)
                                   (om/update! projects :error-text status-text))
                  :headers {"Accept" "application/edn"}
                  :response-format :text})))

        ;; update our current id with the new one
        (om/update! projects :programme_id new-programme_id)

        ;; handle selection in projects table
        (om/update! projects :selected (:projects active-components))))
    om/IRender
    (render [_]
      (let [{:keys [programmes projects active-components]} data


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; programmes
(defn programmes-table [data owner]
  (reify
    om/IRender
