|
|
|
@ -34,32 +34,31 @@
|
|
|
|
|
(:params req))))
|
|
|
|
|
(list! schema-uuid req))))
|
|
|
|
|
|
|
|
|
|
(defn form! [uuid]
|
|
|
|
|
(forms-inst/with-attributes
|
|
|
|
|
(domain-attr/find-by-instance! uuid)))
|
|
|
|
|
|
|
|
|
|
(defn instance! [uuid]
|
|
|
|
|
(domain/full-instance-by-uuid! uuid))
|
|
|
|
|
|
|
|
|
|
(defn show! [uuid req]
|
|
|
|
|
(view/show! (instance! uuid) req))
|
|
|
|
|
|
|
|
|
|
(defn form! [uuid attrs]
|
|
|
|
|
(forms-inst/with-attributes attrs))
|
|
|
|
|
|
|
|
|
|
(defn edit-form! [uuid req]
|
|
|
|
|
(let [instance (instance! uuid)
|
|
|
|
|
attrs (domain-attr/find-by-instance! uuid)
|
|
|
|
|
user-uuid (get-in req [:session :uuid])]
|
|
|
|
|
(view/edit! instance
|
|
|
|
|
(form! uuid)
|
|
|
|
|
(form! uuid attrs)
|
|
|
|
|
(forms-inst/instance->form-data instance)
|
|
|
|
|
(domain-schema/accessible-schemas! user-uuid)
|
|
|
|
|
req)))
|
|
|
|
|
|
|
|
|
|
(defn edit! [uuid req]
|
|
|
|
|
(let [form-def (form! uuid)
|
|
|
|
|
(let [attrs (domain-attr/find-by-instance! uuid)
|
|
|
|
|
form-def (form! uuid attrs)
|
|
|
|
|
instance (instance! uuid)]
|
|
|
|
|
(if (form/valid? form-def req)
|
|
|
|
|
(let [form-data (form/form-data form-def req)
|
|
|
|
|
attrs (domain-attr/find-by-instance! uuid)
|
|
|
|
|
form-instance (forms-inst/form-data->instance form-data attrs)
|
|
|
|
|
instance (assoc form-instance :uuid uuid)]
|
|
|
|
|
(domain/edit! instance)
|
|
|
|
|