 ;; Purgatory
 
 ;; Exempel till "Export"
+
+;; (defn handle-export []
+;;   (let [export-link (. js/document (getElementById "export-download-link"))]
+;;     (log "Exporting competition")
+;;     (.click export-link)))
+
 ;; <a id="document-download-link" download="project.goy" href=""></a>
 
 ;; (defn save-document []

                            :on-click #(dispatch [:select-page :classes])}]
   [:input.btn.btn-default {:type "button" :value "Time Schedule"
                            :on-click #(dispatch [:select-page :events])}]
   ;; [:input.btn.btn-default {:type "button" :value "NewAdjudicators"
   ;;                          :on-click #(dispatch [:select-page :new-adjudicators])}]
   [:input.btn.btn-default {:type "button" :value "NewAdjudicator panels"
                            :on-click #(dispatch [:select-page :new-adjudicator-panels])}]
   [:input.btn.btn-default {:type "button" :value "Adjudicators"
                            :on-click #(dispatch [:select-page :adjudicators])}]
   [:input.btn.btn-default {:type "button" :value "Adjudicator panels"
                            :on-click #(dispatch [:select-page :adjudicator-panels])}]
   ])

(defn time-schedule-activity-presenter [activity classes]
  (let [round (:activity/source activity)

           (get round-map round-type)))
       "Not Started"))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Components

;; TODO - id is used as entity id and not as presentation, is name enough or should we keep
;; a adj/number or adj/position ?
(defn adjudictors-component []
  [:div
   [:h3 "Domare"]
   [:table.table
    [:thead
     [:tr
      ;[:th {:with "20"} "#"]
      [:th {:with "200"} "Name"]
      [:th {:with "20"} "Country"]]]
    [:tbody
     (for [adjudicator
           (sort-by :adjudicator/name (:competition/adjudicators (:competition @app-state)))]
       ^{:key adjudicator}
       [:tr
        ;[:td (:adjudicator/id adjudicator)]
        [:td (:adjudicator/name adjudicator)]
        [:td (:adjudicator/country adjudicator)]])]]])

(defn adjudictor-panels-component []
  [:div
   [:h3 "Domarpaneler"]
   [:table.table
    [:thead
     [:tr
      [:th {:with "20"} "#"]
      [:th {:with "200"} "Domare"]]]
    [:tbody
     (for [adjudicator-panel (sort-by :adjudicator-panel/name (:competition/panels (:competition @app-state)))]
       ^{:key adjudicator-panel}
       [:tr
        [:td (:adjudicator-panel/name adjudicator-panel)]
        [:td (clojure.string/join
              ", "
              (map :adjudicator/name (:adjudicator-panel/adjudicators adjudicator-panel)))]])]]])

(defn classes-component []
  [:div
   [:h3 "Klasser"]
   [:table.table
    [:thead
     [:tr
