|
|
|
@ -48,10 +48,12 @@
|
|
|
|
|
|
|
|
|
|
(defn edit-form! [uuid req]
|
|
|
|
|
(let [instance (instance! uuid)
|
|
|
|
|
attrs (domain-attr/find-by-instance! uuid)]
|
|
|
|
|
attrs (domain-attr/find-by-instance! uuid)
|
|
|
|
|
user-uuid (get-in req [:session :uuid])]
|
|
|
|
|
(view/edit! instance
|
|
|
|
|
(form! uuid)
|
|
|
|
|
(forms-inst/instance->form-data instance)
|
|
|
|
|
(domain-schema/accessible-schemas! user-uuid)
|
|
|
|
|
req)))
|
|
|
|
|
|
|
|
|
|
(defn edit! [uuid req]
|
|
|
|
@ -72,6 +74,26 @@
|
|
|
|
|
(resp/redirect (path :instance-list
|
|
|
|
|
{:schema-uuid (:uuid schema)}))))
|
|
|
|
|
|
|
|
|
|
(defn link-form! [schema-uuid]
|
|
|
|
|
(forms-inst/link-form
|
|
|
|
|
(domain/find-by-schema! schema-uuid)))
|
|
|
|
|
|
|
|
|
|
(defn link-selection! [uuid schema-uuid req]
|
|
|
|
|
(view/link-selection (instance! uuid)
|
|
|
|
|
(domain-schema/find-by-uuid! schema-uuid)
|
|
|
|
|
(link-form! schema-uuid)
|
|
|
|
|
req))
|
|
|
|
|
|
|
|
|
|
(defn create-link! [uuid schema-uuid req]
|
|
|
|
|
(let [form (link-form! schema-uuid)]
|
|
|
|
|
(if (form/valid? form req)
|
|
|
|
|
(let [form-data (form/form-data form req)]
|
|
|
|
|
(domain/create-link! uuid
|
|
|
|
|
(:name form-data)
|
|
|
|
|
(:instances form-data))
|
|
|
|
|
(resp/redirect (path :instance-show {:uuid uuid})))
|
|
|
|
|
(link-selection! uuid schema-uuid req))))
|
|
|
|
|
|
|
|
|
|
(defroutes routes
|
|
|
|
|
(wrap-routes
|
|
|
|
|
(GET (register! :instance-list "/instance/list/:schema-uuid")
|
|
|
|
@ -92,4 +114,12 @@
|
|
|
|
|
(edit! uuid req))
|
|
|
|
|
(DELETE (register! :instance-delete "/instance/:uuid")
|
|
|
|
|
[uuid :as req]
|
|
|
|
|
(delete! uuid req)))
|
|
|
|
|
(delete! uuid req))
|
|
|
|
|
(GET (register! :instance-link-selection
|
|
|
|
|
"/instance/:uuid/link/:schema-uuid")
|
|
|
|
|
[uuid schema-uuid :as req]
|
|
|
|
|
(link-selection! uuid schema-uuid req))
|
|
|
|
|
(POST (register! :instance-create-link
|
|
|
|
|
"/instance/:uuid/link/:schema-uuid")
|
|
|
|
|
[uuid schema-uuid :as req]
|
|
|
|
|
(create-link! uuid schema-uuid req)))
|
|
|
|
|