add deletion of links

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

@ -154,3 +154,12 @@
:schema (:s row)}) :schema (:s row)})
(neo4j/exec-query! outgoing-links (neo4j/exec-query! outgoing-links
{:uuid uuid}))) {: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) :name (:name form-data)
:to (:instances form-data) :to (:instances form-data)
:by (get-in req [:session :uuid])}) :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)))) (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 (defroutes routes
(wrap-routes (wrap-routes
(GET (register! :instance-list "/instance/list/:schema-uuid") (GET (register! :instance-list "/instance/list/:schema-uuid")
@ -122,7 +126,11 @@
"/instance/:uuid/link/:schema-uuid") "/instance/:uuid/link/:schema-uuid")
[uuid schema-uuid :as req] [uuid schema-uuid :as req]
(link-selection! uuid schema-uuid req)) (link-selection! uuid schema-uuid req))
(POST (register! :instance-create-link (POST (register! :instance-link-create
"/instance/:uuid/link/:schema-uuid") "/instance/:uuid/link/:schema-uuid")
[uuid schema-uuid :as req] [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)] (hform/form-to [:delete (path :instance-delete instance)]
(anti-forgery-field) (anti-forgery-field)
(view/delete-btn)) (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..."] [:h2 "Link Instance with Instance of Schema..."]
[:ul [:ul
(for [schema schemas] (for [schema schemas]
@ -112,7 +135,7 @@
(h (:name instance)) (h (:name instance))
[:small " with "] [:small " with "]
(h (:name schema))] (h (:name schema))]
(hform/form-to [:post (path :instance-create-link (hform/form-to [:post (path :instance-link-create
{:uuid (:uuid instance) {:uuid (:uuid instance)
:schema-uuid (:uuid schema)})] :schema-uuid (:uuid schema)})]
(form/render-widgets form nil req) (form/render-widgets form nil req)

Loading…
Cancel
Save