 
 (defmulti properties-table-html (fn [properties owner] (:fetching properties)))
 (defmethod properties-table-html :fetching [properties owner]
-  [:div.row [:div.col-md-12.text-center [:p.lead {:style {:padding-top 30}} "Fetching properties for selected project." ]]])
+  (fetching-row properties))
 
 (defmethod properties-table-html :no-data [properties owner]
-  [:div.row [:div.col-md-12.text-center [:p.lead {:style {:padding-top 30}} "No data available for this selection."]]])
+  (no-data-row properties))
 
 (defmethod properties-table-html :error [properties owner]
-  [:div.row
-   [:div.col-md-12.text-center
-    [:p.lead {:style {:padding-top 30}}
-     "There has been an error. Please contact " [:a {:href "mailto:support@mastodonc.com"} "support@mastodonc.com"]]
-    [:p "Error Code: " (:error-status properties) " Message: " (:error-text properties)]]])
+  (error-row properties))
 
 (defmethod properties-table-html :has-data [properties owner]
   (let [table-id "properties-table"

  [project]
  (assoc project :slug (:name project)))

(defn projects-table [projects owner]
  (reify
    om/IRender
    (render [_]
      (let [table-id   "projects-table"
            history    (om/get-shared owner :history)]
        (html
         [:table {:className "table table-hover"}
          [:thead
           [:tr [:th "Name"] [:th "Type"] [:th "Description"] [:th "Created At"] [:th "Organisation"] [:th "Project Code"]]]
          [:tbody
           (for [row (sort-by :id (:data projects))]
             (let [{:keys [id name type-of description created-at organisation project-code]} row]
               [:tr {:onClick (fn [_ _]
                                (om/update! projects :selected id)
                                (history/update-token-ids! history :projects id)
                                (fixed-scroll-to-element "properties-div"))
                     :className (if (= id (:selected projects)) "success")
                     :id (str table-id "-selected")}
                [:td name]
                [:td type-of]
                [:td description]
                [:td created-at]
                [:td organisation]
                [:td project-code]]))]])))))

(defn projects-div [data owner]
  (reify


        ;; 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)
