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