show-schema

integration-tests
Josha von Gizycki 6 years ago
parent 82cd9ed367
commit 691e1fa6d2

@ -12,7 +12,7 @@ body {
a:link, a:link,
a:visited { a:visited {
color: #555; color: #115577;
text-decoration: none; text-decoration: none;
} }

@ -42,3 +42,17 @@
:s_uuid (neo4j/uuid)}) :s_uuid (neo4j/uuid)})
first first
:uuid)) :uuid))
(neo4j/defquery
find-by-id!
"MATCH (s:schema)
WHERE s.uuid = {uuid}
RETURN s")
(defn find-by-uuid! [uuid]
(->>
(neo4j/exec-query
find-by-id!
{:uuid uuid})
first
:s))

@ -6,7 +6,7 @@
[wanijo.schema.domain :as domain] [wanijo.schema.domain :as domain]
[wanijo.schema.view :as view-schema])) [wanijo.schema.view :as view-schema]))
(defn- new! [req] (defn new! [req]
(if (form/valid? view-schema/new-form req) (if (form/valid? view-schema/new-form req)
(do (do
(domain/create-new! (domain/create-new!
@ -15,6 +15,13 @@
(resp/redirect "/schema")) (resp/redirect "/schema"))
(view-schema/overview! req))) (view-schema/overview! req)))
(defn show-schema! [uuid session]
(println uuid session)
(view-schema/show-schema!
(domain/find-by-uuid! uuid)
session))
(defroutes schema-routes (defroutes schema-routes
(GET "/schema" [] view-schema/overview!) (GET "/schema" [] view-schema/overview!)
(GET "/schema/:uuid" [uuid :as req] (show-schema! uuid (:session req)))
(POST "/schema/new" [] new!)) (POST "/schema/new" [] new!))

@ -15,22 +15,30 @@
uuid (:uuid session) uuid (:uuid session)
schemas (domain/all-created-by! uuid)] schemas (domain/all-created-by! uuid)]
(view/layout! (view/layout!
:session session :session session
:content :content
[[:h1 "Ali jaki ijo"] [[:h1 "Ali jaki ijo"]
[:table [:table
[:thead [:thead
[:tr [:tr
[:th "Nimi"] [:th "Nimi"]
[:th "Tenpo kama"]]] [:th "Tenpo kama"]]]
[:tbody [:tbody
(for [schema schemas] (for [schema schemas]
[:tr [:tr
[:td (:name schema)] [:td
[:td (:created_at schema)]])]] [:a {:href (str "/schema/" (:uuid schema))}
[:h1 "Pali sin e jaki ijo"] (:name schema)]]
(hform/form-to [:td (:created_at schema)]])]]
[:post "/schema/new"] [:h1 "Pali sin e jaki ijo"]
(form/field new-form :schema-name req) (hform/form-to
(hform/submit-button "Pali") [:post "/schema/new"]
(anti-forgery-field))]))) (form/field new-form :schema-name req)
(hform/submit-button "Pali")
(anti-forgery-field))])))
(defn show-schema! [schema session]
(view/layout!
:session session
:content
[[:h1 "Jaki ijo " (:name schema)]]))

Loading…
Cancel
Save