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