|
|
|
@ -3,11 +3,13 @@
|
|
|
|
|
[form :as hform]
|
|
|
|
|
[core :refer [h]]]
|
|
|
|
|
[ring.util.anti-forgery :refer [anti-forgery-field]]
|
|
|
|
|
[markdown.core :as md]
|
|
|
|
|
[formulare.core :as form]
|
|
|
|
|
[wanijo.instance.domain :as domain]
|
|
|
|
|
[wanijo.framework.view :as view]
|
|
|
|
|
[wanijo.framework.routing :refer [path]]
|
|
|
|
|
[wanijo.framework.time :refer [prettify-dt]]))
|
|
|
|
|
[wanijo.framework
|
|
|
|
|
[view :as view]
|
|
|
|
|
[routing :refer [path]]
|
|
|
|
|
[time :refer [prettify-dt]]]))
|
|
|
|
|
|
|
|
|
|
(defn list! [schema instances new-form req]
|
|
|
|
|
(view/layout!
|
|
|
|
@ -36,7 +38,7 @@
|
|
|
|
|
(:uuid schema))
|
|
|
|
|
(hform/submit-button "Create!"))]))
|
|
|
|
|
|
|
|
|
|
(defn show! [instance attrs req]
|
|
|
|
|
(defn show! [instance req]
|
|
|
|
|
(view/layout!
|
|
|
|
|
:request req
|
|
|
|
|
:content
|
|
|
|
@ -47,12 +49,18 @@
|
|
|
|
|
[:p
|
|
|
|
|
[:small [:a {:href (path :instance-edit-form instance)}
|
|
|
|
|
"Edit Instance"]]]
|
|
|
|
|
(for [attr attrs
|
|
|
|
|
:let [auuid (:uuid attr)
|
|
|
|
|
prop (first (filter #(= auuid (-> % :attribute :uuid))
|
|
|
|
|
(:properties instance)))]]
|
|
|
|
|
(list [:em (h (:name attr))]
|
|
|
|
|
[:p (h (:value prop))]))]))
|
|
|
|
|
[:h2 "Properties"]
|
|
|
|
|
(for [prop (:properties instance)
|
|
|
|
|
:let [attr (:attribute prop)
|
|
|
|
|
type (:type attr)
|
|
|
|
|
render-fn (case type
|
|
|
|
|
"date" #(str (prettify-dt %))
|
|
|
|
|
"markdown" md/md-to-html-string
|
|
|
|
|
:else #(str "<p>" % "</p>"))]]
|
|
|
|
|
(list [:h3 (h (:name attr))]
|
|
|
|
|
[:div {:class (str "instance-content "
|
|
|
|
|
"attr-type-" type)}
|
|
|
|
|
(render-fn (:value prop))]))]))
|
|
|
|
|
|
|
|
|
|
(defn edit! [instance form form-data req]
|
|
|
|
|
(view/layout!
|
|
|
|
|