add displaying instance links

integration-tests
Josha von Gizycki 6 years ago
parent 16b88a3a57
commit 7eb9a2c7fe

@ -138,3 +138,19 @@
(assoc link (assoc link
:uuid (neo4j/uuid) :uuid (neo4j/uuid)
:created_at (neo4j/now-str)))) :created_at (neo4j/now-str))))
(neo4j/defquery outgoing-links
"MATCH (i:instance {uuid:{uuid}}),
(i)<-[:link_from]-(l:link),
(l)-[:link_to]->(t:instance),
(t)-[:of]->(s:schema)
RETURN i, l, t, s
ORDER BY l.created_at")
(defn outgoing-links! [uuid]
(map (fn [row]
{:link (:l row)
:target (:t row)
:schema (:s row)})
(neo4j/exec-query! outgoing-links
{:uuid uuid})))

@ -41,7 +41,9 @@
(defn instance! [uuid] (defn instance! [uuid]
(assoc (domain/find-by-uuid! uuid) (assoc (domain/find-by-uuid! uuid)
:properties :properties
(domain/find-properties! uuid))) (domain/find-properties! uuid)
:links-out
(domain/outgoing-links! uuid)))
(defn show! [uuid req] (defn show! [uuid req]
(view/show! (instance! uuid) req)) (view/show! (instance! uuid) req))

@ -60,7 +60,24 @@
(list [:h3 (h (:name attr))] (list [:h3 (h (:name attr))]
[:div {:class (str "instance-content " [:div {:class (str "instance-content "
"attr-type-" type)} "attr-type-" type)}
(render-fn (:value prop))]))])) (render-fn (:value prop))]))
(when-not (empty? (:links-out instance))
[:section.links
[:h2 "Outgoing Links"]
[:table
[:thead
[:tr
[:th "Name"]
[:th "Schema"]
[:th "Instance"]
[:th "Created"]]]
[:tbody
(for [{:keys [link target schema]} (:links-out instance)]
[:tr
[:td (h (:name link))]
[:td (h (:name schema))]
[:td (h (:name target))]
[:td (prettify-dt (:created_at link))]])]]])]))
(defn edit! [instance form form-data schemas req] (defn edit! [instance form form-data schemas req]
(view/layout! (view/layout!

Loading…
Cancel
Save