|
|
@ -11,8 +11,10 @@
|
|
|
|
[link-selection :refer [link-selection]]
|
|
|
|
[link-selection :refer [link-selection]]
|
|
|
|
[bulk-link-selection :refer [bulk-link-selection]]
|
|
|
|
[bulk-link-selection :refer [bulk-link-selection]]
|
|
|
|
[starred :refer [starred]]]
|
|
|
|
[starred :refer [starred]]]
|
|
|
|
[wanijo.instance.db :as domain]
|
|
|
|
[wanijo.instance
|
|
|
|
[wanijo.instance.forms :as forms-inst]
|
|
|
|
[db :as db]
|
|
|
|
|
|
|
|
[forms :as forms-inst]
|
|
|
|
|
|
|
|
[domain :as domain]]
|
|
|
|
[wanijo.schema.db :as domain-schema]
|
|
|
|
[wanijo.schema.db :as domain-schema]
|
|
|
|
[wanijo.schema.middleware :as middleware-schema]
|
|
|
|
[wanijo.schema.middleware :as middleware-schema]
|
|
|
|
[wanijo.link.db :as domain-link]
|
|
|
|
[wanijo.link.db :as domain-link]
|
|
|
@ -21,7 +23,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
(defn route-list! [schema-uuid req]
|
|
|
|
(defn route-list! [schema-uuid req]
|
|
|
|
(instances (domain-schema/find-by-uuid! schema-uuid)
|
|
|
|
(instances (domain-schema/find-by-uuid! schema-uuid)
|
|
|
|
(domain/find-by-schema! schema-uuid)
|
|
|
|
(db/find-by-schema! schema-uuid)
|
|
|
|
(forms-inst/with-attributes (db-attr/required! schema-uuid))
|
|
|
|
(forms-inst/with-attributes (db-attr/required! schema-uuid))
|
|
|
|
req))
|
|
|
|
req))
|
|
|
|
|
|
|
|
|
|
|
@ -35,7 +37,7 @@
|
|
|
|
req-attrs (db-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
|
|
|
|
(db/create! user-uuid
|
|
|
|
schema-uuid
|
|
|
|
schema-uuid
|
|
|
|
instance)
|
|
|
|
instance)
|
|
|
|
(resp/redirect (path :instance-list
|
|
|
|
(resp/redirect (path :instance-list
|
|
|
@ -43,13 +45,13 @@
|
|
|
|
(route-list! schema-uuid req))))
|
|
|
|
(route-list! schema-uuid req))))
|
|
|
|
|
|
|
|
|
|
|
|
(defn instance! [uuid]
|
|
|
|
(defn instance! [uuid]
|
|
|
|
(domain/full-instance-by-uuid! uuid))
|
|
|
|
(db/full-instance-by-uuid! uuid))
|
|
|
|
|
|
|
|
|
|
|
|
(defn route-show! [uuid req]
|
|
|
|
(defn route-show! [uuid req]
|
|
|
|
(let [user-uuid (-> req :session :uuid)
|
|
|
|
(let [user-uuid (-> req :session :uuid)
|
|
|
|
instance (assoc (instance! uuid)
|
|
|
|
instance (assoc (instance! uuid)
|
|
|
|
:starred
|
|
|
|
:starred
|
|
|
|
(domain/is-starred! uuid
|
|
|
|
(db/is-starred! uuid
|
|
|
|
user-uuid))]
|
|
|
|
user-uuid))]
|
|
|
|
(show instance
|
|
|
|
(show instance
|
|
|
|
(domain-schema/accessible-schemas! user-uuid)
|
|
|
|
(domain-schema/accessible-schemas! user-uuid)
|
|
|
@ -75,20 +77,19 @@
|
|
|
|
(let [form-data (form/form-data form-def req)
|
|
|
|
(let [form-data (form/form-data form-def req)
|
|
|
|
form-instance (forms-inst/form-data->instance form-data attrs)
|
|
|
|
form-instance (forms-inst/form-data->instance form-data attrs)
|
|
|
|
instance (assoc form-instance :uuid uuid)]
|
|
|
|
instance (assoc form-instance :uuid uuid)]
|
|
|
|
(clojure.pprint/pprint instance)
|
|
|
|
(db/edit! instance (domain/to-revision instance))
|
|
|
|
(domain/edit! instance)
|
|
|
|
|
|
|
|
(resp/redirect (path :instance-show instance)))
|
|
|
|
(resp/redirect (path :instance-show instance)))
|
|
|
|
(route-show! uuid req))))
|
|
|
|
(route-show! uuid req))))
|
|
|
|
|
|
|
|
|
|
|
|
(defn route-delete! [uuid]
|
|
|
|
(defn route-delete! [uuid]
|
|
|
|
(let [schema (domain-schema/find-by-instance! uuid)]
|
|
|
|
(let [schema (domain-schema/find-by-instance! uuid)]
|
|
|
|
(domain/delete! uuid)
|
|
|
|
(db/delete! uuid)
|
|
|
|
(resp/redirect (path :instance-list
|
|
|
|
(resp/redirect (path :instance-list
|
|
|
|
{:schema-uuid (:uuid schema)}))))
|
|
|
|
{:schema-uuid (:uuid schema)}))))
|
|
|
|
|
|
|
|
|
|
|
|
(defn link-form! [schema-uuid]
|
|
|
|
(defn link-form! [schema-uuid]
|
|
|
|
(forms-inst/link-form
|
|
|
|
(forms-inst/link-form
|
|
|
|
(domain/find-by-schema! schema-uuid)))
|
|
|
|
(db/find-by-schema! schema-uuid)))
|
|
|
|
|
|
|
|
|
|
|
|
(defn route-link-selection! [uuid schema-uuid req]
|
|
|
|
(defn route-link-selection! [uuid schema-uuid req]
|
|
|
|
(link-selection (instance! uuid)
|
|
|
|
(link-selection (instance! uuid)
|
|
|
@ -117,28 +118,28 @@
|
|
|
|
(resp/redirect (path :instance-edit-form {:uuid uuid})))
|
|
|
|
(resp/redirect (path :instance-edit-form {:uuid uuid})))
|
|
|
|
|
|
|
|
|
|
|
|
(defn route-mark-starred! [uuid req]
|
|
|
|
(defn route-mark-starred! [uuid req]
|
|
|
|
(domain/mark-starred! uuid
|
|
|
|
(db/mark-starred! uuid
|
|
|
|
(-> req :session :uuid))
|
|
|
|
(-> req :session :uuid))
|
|
|
|
(resp/redirect (path :instance-show {:uuid uuid})))
|
|
|
|
(resp/redirect (path :instance-show {:uuid uuid})))
|
|
|
|
|
|
|
|
|
|
|
|
(defn route-remove-starred! [uuid req]
|
|
|
|
(defn route-remove-starred! [uuid req]
|
|
|
|
(domain/remove-starred! uuid
|
|
|
|
(db/remove-starred! uuid
|
|
|
|
(-> req :session :uuid))
|
|
|
|
(-> req :session :uuid))
|
|
|
|
(resp/redirect (path :instance-show {:uuid uuid})))
|
|
|
|
(resp/redirect (path :instance-show {:uuid uuid})))
|
|
|
|
|
|
|
|
|
|
|
|
(defn route-list-starred! [req]
|
|
|
|
(defn route-list-starred! [req]
|
|
|
|
(starred
|
|
|
|
(starred
|
|
|
|
(domain/starred-by-user! (-> req :session :uuid))
|
|
|
|
(db/starred-by-user! (-> req :session :uuid))
|
|
|
|
req))
|
|
|
|
req))
|
|
|
|
|
|
|
|
|
|
|
|
(defn route-bulk-link-selection! [uuid req]
|
|
|
|
(defn route-bulk-link-selection! [uuid req]
|
|
|
|
(let [user-uuid (-> req :session :uuid)]
|
|
|
|
(let [user-uuid (-> req :session :uuid)]
|
|
|
|
(bulk-link-selection (domain/full-instance-by-uuid! uuid)
|
|
|
|
(bulk-link-selection (db/full-instance-by-uuid! uuid)
|
|
|
|
(->> (domain-schema/accessible-schemas!
|
|
|
|
(->> (domain-schema/accessible-schemas!
|
|
|
|
user-uuid)
|
|
|
|
user-uuid)
|
|
|
|
(map (fn [schema]
|
|
|
|
(map (fn [schema]
|
|
|
|
{:schema schema
|
|
|
|
{:schema schema
|
|
|
|
:instances (domain/find-by-schema!
|
|
|
|
:instances (db/find-by-schema!
|
|
|
|
(:uuid schema))})))
|
|
|
|
(:uuid schema))})))
|
|
|
|
req)))
|
|
|
|
req)))
|
|
|
|
|
|
|
|
|
|
|
|