       :rows rows
       :cols cols}]))
 
-
-
-(defn toggle-input-mode [key state]
-  (let [key-atom (cursor state [:input_mode])]
-    (if (= key @key-atom) (reset! key-atom nil) (do (reset! key-atom nil) (reset! key-atom key)))))
-
-
-(defn init-resources [key resource-atom]
-  (let [url (case key
-              :page_input "/obpv1/page"
-              :file_input "/obpv1/file")]
-    (ajax/GET
-      (path-for url true)
-      {:handler (fn [data]
-                  (reset! resource-atom data)
-                  )})))
-
-
-(defn remove-url [url coll state]
-  (swap! state assoc-in [:evidence :urls] (remove #(= url %) @coll)))
-
-(defn grid-element [element-data state key]
-  (let [{:keys [id name path visibility mtime badges ctime mime_type]} element-data
+(defn evidence-icon [evidence_type]
+  (let [{:keys [type mime_type]} evidence_type]
+    [:div.evidence-icon
+     (case type
+       "page" [:i.fa.fa-file-text-o]
+       "url" [:i.fa.fa-link]
+       "file" [:i {:class (str "fa " (file-icon mime_type)) } ]
+       [:i.fa.fa-link])]))
+
+(defn grid-element [element-data state key data init-data]
+  (let [{:keys [id name path description visibility mtime badges ctime mime_type]} element-data
         value (case key
                 :page_input (str (session/get :site-url) (path-for (str "/page/view/" id)))
                 :file_input (str (session/get :site-url) "/" path)
                 nil)
         evidence-url-atom (cursor state [:evidence :url])
-        show-url? (cursor state [:evidence :show_url])
-        resource-input-mode (cursor state [:input_mode])
-        update-page-visibility ()]
-    (prn visibility)
-   (when (= "private" visibility) (swap! state assoc :evidence {:update-page-visibility id}))
-    [:div.radio
-     [:label
-      [:input { :name "opt"
-                :type "radio"
-                :value value
-                :on-change #(do
-                              (reset! evidence-url-atom (.-target.value %))
-                              (reset! resource-input-mode nil)
-                              (reset! show-url? true))}]
+        evidence-name-atom (cursor state [:evidence :name])
+        evidence-description-atom (cursor state [:evidence :description])
+        evidence-visibility-atom (cursor state [:evidence :visibility])
+        resource-id-atom (cursor state [:evidence :resource_id])]
+    [:div
+     [:a.resource-link {:href "#"
+                        :on-click #(do
+                                     (.preventDefault %)
+                                     (reset! evidence-url-atom value)
+                                     (reset! evidence-name-atom name)
+                                     (reset! evidence-description-atom description)
+                                     (reset! evidence-visibility-atom visibility)
+                                     (reset! resource-id-atom id)) }
       (case key
-        :page_input [:a {:href "#" :on-click #(do
-                                                (.preventDefault %)
-                                                (mo/open-modal [:page :view] {:page-id id}))} name]
-
-        :file_input [:div [:i {:style {:margin-right "10px"}
-                               :class (str "file-icon-large fa " (file-icon mime_type))}]
-                     [:a {:href (str "/" path) :target "_blank"} name]])]]))
-
-
-
-
-(defn toggle-visible-area [visible-area-atom key]
-  (if (= key @visible-area-atom) (reset! visible-area-atom nil) (reset! visible-area-atom key)))
+        :page_input [:div.resource  [:i.fa.fa-file-text-o] name]
+        :file_input [:div.resource [:i {:style {:margin-right "10px"}
+                                        :class (str "file-icon-large fa " (file-icon mime_type))}]
+                     name])]]))
 
 (defn upload-status [status title message]
   [:div

            [salava.core.ui.helper :refer [plugin-fun path-for hyperlink base-url]]
            [salava.core.ui.ajax-utils :as ajax]
            [salava.core.time :refer [date-from-unix-time]]
            [clojure.string :refer [blank? includes? split trim]]
            [salava.file.icons :refer [file-icon]]
            [salava.file.ui.my :refer [send-file]]))

(defn url? [s]
  (when-not (blank? s)
    (not (blank? (re-find #"^http" (str (trim s)))))))

(defn input [input-data textarea?]
  (let [{:keys [name atom placeholder type error-message-atom rows cols]} input-data]

        (case @resource-input-mode
          :file_input (do
                        (init-resources :file_input resource-atom)
                        [:div [resources-grid :file_input resource-atom state data init-data]])
          :page_input (do
                        (init-resources :page_input resource-atom)
                        [:div [resources-grid :page_input resource-atom state data init-data]])
          :url_input [:div.resource-container {:style {:margin-bottom "10px"}}
                      [input {:name "evidence-url" :atom evidence-url-atom :type "url" :placeholder "http://"}]]
          nil)]])))

(defn evidence-form [data state init-data]
  (let [settings-tab (first (plugin-fun (session/get :plugins) "settings" "settings_tab_content"))
        evidence-name-atom (cursor state [:evidence :name])
        evidence-description-atom (cursor state [:evidence :description])
        evidence-url-atom (cursor state [:evidence :url])
        message (cursor state [:evidence :message])
        input-mode (cursor state [:input_mode])
        {:keys [image_file name]} data]

    [:div {:id "badge-settings" :class "row flip"}
