Improve workspace common lenses.

This commit is contained in:
Andrey Antukh 2016-02-21 20:31:49 +02:00
parent e73ffddb50
commit 43d7a5cec2

View file

@ -4,7 +4,7 @@
[cats.labs.lens :as l] [cats.labs.lens :as l]
[uxbox.rstore :as rs] [uxbox.rstore :as rs]
[uxbox.state :as st] [uxbox.state :as st]
[uxbox.data.projects :as dp] [uxbox.state.project :as stpr]
[uxbox.data.workspace :as dw] [uxbox.data.workspace :as dw]
[uxbox.util.geom.point :as gpt] [uxbox.util.geom.point :as gpt]
[uxbox.util.lens :as ul] [uxbox.util.lens :as ul]
@ -16,17 +16,25 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def ^:static project-l (def ^:static project-l
(as-> (ul/dep-in [:projects-by-id] [:workspace :project]) $ (letfn [(getter [state]
(l/focus-atom $ st/state))) (let [project (get-in state [:workspace :project])]
(get-in state [:projects-by-id project])))]
(as-> (ul/getter getter) $
(l/focus-atom $ st/state))))
(def ^:static page-l (def ^:static page-l
(as-> (ul/dep-in [:pages-by-id] [:workspace :page]) $ (letfn [(getter [state]
(l/focus-atom $ st/state))) (let [page (get-in state [:workspace :page])]
(get-in state [:pages-by-id page])))]
(as-> (ul/getter getter) $
(l/focus-atom $ st/state))))
(def ^:static pages-l (def ^:static pages-l
(as-> (ul/getter #(let [pid (get-in % [:workspace :project])] (letfn [(getter [state]
(dp/project-pages % pid))) $ (let [project (get-in state [:workspace :project])]
(l/focus-atom $ st/state))) (stpr/project-pages state project)))]
(as-> (ul/getter getter) $
(l/focus-atom $ st/state))))
(def ^:static workspace-l (def ^:static workspace-l
(as-> (l/in [:workspace]) $ (as-> (l/in [:workspace]) $