some tinkering on bulk link creation

neo4j-4
Josha von Gizycki 4 years ago
parent 56fc3dfe01
commit 3f2623d8b6

@ -283,6 +283,10 @@ form.inline {
} }
} }
form.no-grid {
display: block;
}
table { table {
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;
@ -357,6 +361,7 @@ table {
button, input { button, input {
margin-right: @element-margin; margin-right: @element-margin;
margin-bottom: 0;
} }
} }

@ -87,7 +87,7 @@
(defn link-form! [schema-uuid] (defn link-form! [schema-uuid]
(forms-inst/link-form (forms-inst/link-form
(domain/find-by-schema! schema-uuid))) (domain/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)
@ -122,18 +122,19 @@
(defn route-list-starred! [req] (defn route-list-starred! [req]
(starred (starred
(domain/starred-by-user! (-> req :session :uuid)) (domain/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 (domain/full-instance-by-uuid! uuid)
(->> (domain-schema/accessible-schemas! (->> (domain-schema/accessible-schemas!
user-uuid) user-uuid)
(map (fn [schema] (map (fn [schema]
{:form (link-form! (:uuid schema)) {;; :form (link-form! (:uuid schema))
:schema schema})) :schema schema
(forms-inst/bulk-link-form)) :instances (domain/find-by-schema!
(:uuid schema))})))
req))) req)))
(defn route-create-bulk-link! [uuid req] (defn route-create-bulk-link! [uuid req]
@ -142,13 +143,13 @@
(defroutes routes (defroutes routes
(wrap-routes (wrap-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]
(route-list! schema-uuid req)) (route-list! schema-uuid req))
(middleware-schema/wrap-allowed-to-read! (middleware-schema/wrap-allowed-to-read!
#(get-in % [:params :schema-uuid]))) #(get-in % [:params :schema-uuid])))
(POST (register! :instance-new "/instance/new") [] (POST (register! :instance-new "/instance/new") []
route-new!) route-new!)
(GET (register! :instance-show "/instance/:uuid") (GET (register! :instance-show "/instance/:uuid")
[uuid :as req] [uuid :as req]
(route-show! uuid req)) (route-show! uuid req))
@ -157,10 +158,10 @@
(route-edit-form! uuid req)) (route-edit-form! uuid req))
(POST (register! :instance-edit "/instance/:uuid") (POST (register! :instance-edit "/instance/:uuid")
[uuid :as req] [uuid :as req]
(route-edit! uuid req)) (route-edit! uuid req))
(DELETE (register! :instance-delete "/instance/:uuid") (DELETE (register! :instance-delete "/instance/:uuid")
[uuid] [uuid]
(route-delete! uuid)) (route-delete! uuid))
(GET (register! :instance-link-selection (GET (register! :instance-link-selection
"/instance/:uuid/link/:schema-uuid") "/instance/:uuid/link/:schema-uuid")
[uuid schema-uuid :as req] [uuid schema-uuid :as req]
@ -168,19 +169,19 @@
(POST (register! :instance-link-create (POST (register! :instance-link-create
"/instance/:uuid/link/:schema-uuid") "/instance/:uuid/link/:schema-uuid")
[uuid schema-uuid :as req] [uuid schema-uuid :as req]
(route-create-link! uuid schema-uuid req)) (route-create-link! uuid schema-uuid req))
(DELETE (register! :instance-link-delete (DELETE (register! :instance-link-delete
"/instance/:uuid/link/:link-uuid") "/instance/:uuid/link/:link-uuid")
[uuid link-uuid] [uuid link-uuid]
(route-delete-link! uuid link-uuid)) (route-delete-link! uuid link-uuid))
(POST (register! :instance-mark-starred (POST (register! :instance-mark-starred
"/instance/:uuid/starred") "/instance/:uuid/starred")
[uuid :as req] [uuid :as req]
(route-mark-starred! uuid req)) (route-mark-starred! uuid req))
(DELETE (register! :instance-remove-starred (DELETE (register! :instance-remove-starred
"/instance/:uuid/starred") "/instance/:uuid/starred")
[uuid :as req] [uuid :as req]
(route-remove-starred! uuid req)) (route-remove-starred! uuid req))
(GET (register! :instance-list-starred "/instance/starred/list") (GET (register! :instance-list-starred "/instance/starred/list")
[:as req] [:as req]
(route-list-starred! req)) (route-list-starred! req))
@ -189,4 +190,4 @@
(route-bulk-link-selection! uuid req)) (route-bulk-link-selection! uuid req))
(POST (register! :instance-bulk-link-create "/instance/:uuid/bulk-link") (POST (register! :instance-bulk-link-create "/instance/:uuid/bulk-link")
[uuid :as req] [uuid :as req]
(route-create-bulk-link! uuid req))) (route-create-bulk-link! uuid req)))

@ -9,20 +9,33 @@
(defn bulk-link-selection [instance forms req] (defn bulk-link-selection [instance forms req]
(clojure.pprint/pprint forms) (clojure.pprint/pprint forms)
(view/layout (view/layout
:request req :request req
:content :content
[[:h1 [[:h1
[:small "Link " (-> instance :schema :name h) " "] [:small "Link " (-> instance :schema :name h) " "]
(h (:name instance)) (h (:name instance))
[:small " with..."]] [:small " with..."]]
(hform/form-to (hform/form-to
[:post (path :instance-bulk-link-create instance)] {:class "no-grid"}
(anti-forgery-field) [:post (path :instance-bulk-link-create instance)]
(for [{:keys [schema form]} forms] (anti-forgery-field)
[:fieldset (for [{:keys [schema instances]} forms]
[:legend "Schema " [:strong (-> schema :name h)]] (list
(form/render-widgets form [:h2 "Schema " (h (:name schema))]
nil [:label
req "Link name "
{:render-anti-forgery-field? false})]) [:input {:name (str "name[" (:uuid schema) "]")}]]
(hform/submit-button "Link!"))])) [:table
[:thead
[:tr
[:th "Selection"]
[:th "Name"]]]
[:tbody
(for [{:keys [name uuid]} instances]
[:tr
[:td {:style "text-align: center;"}
[:input {:type "checkbox"
:name (str "instances[" (:uuid schema) "]")
:value uuid}]]
[:td (h name)]])]]))
(hform/submit-button "Link!"))]))

Loading…
Cancel
Save