|
|
|
@ -13,12 +13,14 @@
|
|
|
|
|
(defn list! [schema-uuid req]
|
|
|
|
|
(view/list! (domain-schema/find-by-uuid! schema-uuid)
|
|
|
|
|
(domain/find-by-schema! schema-uuid)
|
|
|
|
|
(forms-inst/instance-form schema-uuid)
|
|
|
|
|
(forms-inst/new-form schema-uuid
|
|
|
|
|
(domain-attr/required! schema-uuid))
|
|
|
|
|
req))
|
|
|
|
|
|
|
|
|
|
(defn new! [req]
|
|
|
|
|
(let [schema-uuid (get-in req [:params :schema-uuid])
|
|
|
|
|
form-def (forms-inst/instance-form schema-uuid)]
|
|
|
|
|
form-def (forms-inst/new-form schema-uuid
|
|
|
|
|
(domain-attr/required! schema-uuid))]
|
|
|
|
|
(if (form/valid? form-def req)
|
|
|
|
|
(let [form-data (form/form-data form-def req)
|
|
|
|
|
req-attrs (domain-attr/required! schema-uuid)
|
|
|
|
@ -30,9 +32,18 @@
|
|
|
|
|
(:params req))))
|
|
|
|
|
(list! schema-uuid req))))
|
|
|
|
|
|
|
|
|
|
(defn show! [uuid req]
|
|
|
|
|
(let [instance (assoc (domain/find-by-uuid! uuid)
|
|
|
|
|
:properties
|
|
|
|
|
(domain/find-properties! uuid))]
|
|
|
|
|
(view/show! instance req)))
|
|
|
|
|
|
|
|
|
|
(defroutes routes
|
|
|
|
|
(GET (register! :instance-list "/instance/list/:schema-uuid")
|
|
|
|
|
[schema-uuid :as req]
|
|
|
|
|
(list! schema-uuid req))
|
|
|
|
|
(POST (register! :instance-new "/instance/new") []
|
|
|
|
|
new!))
|
|
|
|
|
new!)
|
|
|
|
|
(GET (register! :instance-show "/instance/:uuid")
|
|
|
|
|
[uuid :as req]
|
|
|
|
|
(show! uuid req)))
|
|
|
|
|