add created and other schemas to sidebar

integration-tests
Josha von Gizycki 6 years ago
parent cfb70fbbf6
commit 62a86ec5fb

@ -44,8 +44,18 @@
(btnlink (path :auth-logout)
"Logout!"
"header-content__link")])]
[:nav (when authed? "nav")]
(vec (concat [:main] content))
[:nav
(when authed?
[:section.schemas
[:h2 "Created Schemas"]
[:ul
(for [schema (:created-schemas session)]
[:li (:name schema)])]
[:h2 "Other Schemas"]
[:ul
(for [schema (:other-schemas session)]
[:li (:name schema)])]])]
(into [:main] content)
[:aside (when authed? "aside")]
[:footer
[:small "Ilo pali e ijo"]]]])))

@ -8,6 +8,7 @@
[ring.middleware.session.cookie :as session-cookie]
[wanijo.home.routes :as home-routes]
[wanijo.schema.routes :as schema-routes]
[wanijo.schema.middleware :as schema-middleware]
[wanijo.user.routes :as user-routes]
[wanijo.attribute.routes :as attr-routes]
[wanijo.framework.auth :as auth]
@ -32,6 +33,7 @@
(def app
(-> app-routes
devmode/wrap-devmode
schema-middleware/wrap-user-schemas
(wrap-defaults
(assoc-in site-defaults
[:session :store]

@ -22,6 +22,16 @@
{:uuid user-uuid})
(map :s)))
(neo4j/defquery
all
"MATCH (s:schema)
RETURN s
ORDER BY s.name")
(defn all! []
(map :s
(neo4j/exec-query! all {})))
(neo4j/defquery
create-new
"MATCH (u:user)

@ -0,0 +1,16 @@
(ns wanijo.schema.middleware
(:require [wanijo.schema.domain :as domain]))
(defn wrap-user-schemas [handler]
(fn [req]
(if-let [uuid (get-in req [:session :uuid])]
(let [created (domain/all-created-by! uuid)
created-uids (map :uuid created)
others (filter (fn [other]
(not (some (partial = (:uuid other))
created-uids)))
(domain/all!))]
(handler (-> req
(assoc-in [:session :created-schemas] created)
(assoc-in [:session :other-schemas] others))))
(handler req))))
Loading…
Cancel
Save