|
|
@ -12,22 +12,22 @@
|
|
|
|
[middleware :as middleware-schema]]
|
|
|
|
[middleware :as middleware-schema]]
|
|
|
|
[wanijo.link.db :as domain-link]
|
|
|
|
[wanijo.link.db :as domain-link]
|
|
|
|
[wanijo.infrastructure.routing :refer [register! path]]
|
|
|
|
[wanijo.infrastructure.routing :refer [register! path]]
|
|
|
|
[wanijo.attribute.db :as domain-attr]))
|
|
|
|
[wanijo.attribute.db :as db-attr]))
|
|
|
|
|
|
|
|
|
|
|
|
(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/with-attributes (domain-attr/required! schema-uuid))
|
|
|
|
(forms-inst/with-attributes (db-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])
|
|
|
|
user-uuid (get-in req [:session :uuid])
|
|
|
|
user-uuid (get-in req [:session :uuid])
|
|
|
|
req-attrs (domain-attr/required! schema-uuid)
|
|
|
|
req-attrs (db-attr/required! schema-uuid)
|
|
|
|
form-def (forms-inst/with-attributes req-attrs)]
|
|
|
|
form-def (forms-inst/with-attributes req-attrs)]
|
|
|
|
(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 (db-attr/required! schema-uuid)
|
|
|
|
instance (forms-inst/form-data->instance form-data
|
|
|
|
instance (forms-inst/form-data->instance form-data
|
|
|
|
req-attrs)]
|
|
|
|
req-attrs)]
|
|
|
|
(domain/create! user-uuid
|
|
|
|
(domain/create! user-uuid
|
|
|
@ -55,7 +55,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
(defn edit-form! [uuid req]
|
|
|
|
(defn edit-form! [uuid req]
|
|
|
|
(let [instance (instance! uuid)
|
|
|
|
(let [instance (instance! uuid)
|
|
|
|
attrs (domain-attr/find-by-instance! uuid)
|
|
|
|
attrs (db-attr/find-by-instance! uuid)
|
|
|
|
user-uuid (get-in req [:session :uuid])]
|
|
|
|
user-uuid (get-in req [:session :uuid])]
|
|
|
|
(view/edit! instance
|
|
|
|
(view/edit! instance
|
|
|
|
(form! attrs)
|
|
|
|
(form! attrs)
|
|
|
@ -64,7 +64,7 @@
|
|
|
|
req)))
|
|
|
|
req)))
|
|
|
|
|
|
|
|
|
|
|
|
(defn edit! [uuid req]
|
|
|
|
(defn edit! [uuid req]
|
|
|
|
(let [attrs (domain-attr/find-by-instance! uuid)
|
|
|
|
(let [attrs (db-attr/find-by-instance! uuid)
|
|
|
|
form-def (form! attrs)]
|
|
|
|
form-def (form! attrs)]
|
|
|
|
(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)
|
|
|
|