From 71ff06e3ca2938b82171a3f429ff494e83361fee Mon Sep 17 00:00:00 2001 From: Josha von Gizycki Date: Wed, 16 Jan 2019 16:21:36 +0100 Subject: [PATCH] hide properties if none exist --- src/wanijo/instance/view.clj | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/wanijo/instance/view.clj b/src/wanijo/instance/view.clj index abc040c..2a488e3 100644 --- a/src/wanijo/instance/view.clj +++ b/src/wanijo/instance/view.clj @@ -48,18 +48,20 @@ [:small (h (:name instance))]] [:p [:small [:a {:href (path :instance-edit-form instance)} "Edit Instance"]]] - [: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 "

" % "

"))]] - (list [:h3 (h (:name attr))] - [:div {:class (str "instance-content " - "attr-type-" type)} - (render-fn (:value prop))])) + (when-not (empty? (:properties instance)) + [:section.properties + [: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 "

" % "

"))]] + (list [:h3 (h (:name attr))] + [:div {:class (str "instance-content " + "attr-type-" type)} + (render-fn (:value prop))]))]) (when-not (empty? (:links-out instance)) [:section.links [:h2 "Outgoing Links"]