add deletion of links

integration-tests
Josha von Gizycki 6 years ago
parent 1aae4edde3
commit 7be530ff28

@ -154,3 +154,12 @@
:schema (:s row)})
(neo4j/exec-query! outgoing-links
{:uuid uuid})))
(neo4j/defquery delete-link
"MATCH (l:link {uuid:{uuid}}),
(l)-[r]-()
DELETE r, l")
(defn delete-link! [uuid]
(neo4j/exec-query! delete-link
{:uuid uuid}))

@ -94,9 +94,13 @@
:name (:name form-data)
:to (:instances form-data)
:by (get-in req [:session :uuid])})
(resp/redirect (path :instance-show {:uuid uuid})))
(resp/redirect (path :instance-edit-form {:uuid uuid})))
(link-selection! uuid schema-uuid req))))
(defn delete-link! [uuid link-uuid req]
(domain/delete-link! link-uuid)
(resp/redirect (path :instance-edit-form {:uuid uuid})))
(defroutes routes
(wrap-routes
(GET (register! :instance-list "/instance/list/:schema-uuid")
@ -122,7 +126,11 @@
"/instance/:uuid/link/:schema-uuid")
[uuid schema-uuid :as req]
(link-selection! uuid schema-uuid req))
(POST (register! :instance-create-link
(POST (register! :instance-link-create
"/instance/:uuid/link/:schema-uuid")
[uuid schema-uuid :as req]
(create-link! uuid schema-uuid req)))
(create-link! uuid schema-uuid req))
(DELETE (register! :instance-link-delete
"/instance/:uuid/link/:link-uuid")
[uuid link-uuid :as req]
(delete-link! uuid link-uuid req)))

@ -94,6 +94,29 @@
(hform/form-to [:delete (path :instance-delete instance)]
(anti-forgery-field)
(view/delete-btn))
(when-not (empty? (:links-out instance))
[:section.links
[:h2 "Outgoing Links"]
[:table
[:thead
[:tr
[:th "Name"]
[:th "Schema"]
[:th "Instance"]
[:th "Created"]
[:th]]]
[: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))]
[:td (hform/form-to [:delete (path :instance-link-delete
{:uuid (:uuid instance)
:link-uuid (:uuid link)})]
(anti-forgery-field)
(view/delete-btn))]])]]])
[:h2 "Link Instance with Instance of Schema..."]
[:ul
(for [schema schemas]
@ -112,7 +135,7 @@
(h (:name instance))
[:small " with "]
(h (:name schema))]
(hform/form-to [:post (path :instance-create-link
(hform/form-to [:post (path :instance-link-create
{:uuid (:uuid instance)
:schema-uuid (:uuid schema)})]
(form/render-widgets form nil req)

Loading…
Cancel
Save