diff --git a/src/uxbox/ui/workspace/base.cljs b/src/uxbox/ui/workspace/base.cljs index feae3329e..3844fe480 100644 --- a/src/uxbox/ui/workspace/base.cljs +++ b/src/uxbox/ui/workspace/base.cljs @@ -22,42 +22,35 @@ ;; Lenses ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(def ^:static project-l +(def ^:const workspace-l + (as-> (l/in [:workspace]) $ + (l/focus-atom $ st/state))) + +(def ^:const project-l (letfn [(getter [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 ^:const page-l (letfn [(getter [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 - (letfn [(getter [state] - (let [project (get-in state [:workspace :project])] - (stpr/project-pages state project)))] - (as-> (ul/getter getter) $ - (l/focus-atom $ st/state)))) - -(def ^:static workspace-l - (as-> (l/in [:workspace]) $ - (l/focus-atom $ st/state))) - (def ^:static selected-shapes-l - (as-> (l/in [:workspace :selected]) $ - (l/focus-atom $ st/state))) + (as-> (l/in [:selected]) $ + (l/focus-atom $ workspace-l))) (def ^:static toolboxes-l - (as-> (l/in [:workspace :toolboxes]) $ - (l/focus-atom $ st/state))) + (as-> (l/in [:toolboxes]) $ + (l/focus-atom $ workspace-l))) (def ^:static flags-l - (as-> (l/in [:workspace :flags]) $ - (l/focus-atom $ st/state))) + (as-> (l/in [:flags]) $ + (l/focus-atom $ workspace-l))) (def ^:static shapes-by-id-l (as-> (l/key :shapes-by-id) $ diff --git a/src/uxbox/ui/workspace/sidebar/sitemap.cljs b/src/uxbox/ui/workspace/sidebar/sitemap.cljs index 8241d8eba..ae8bf3ef8 100644 --- a/src/uxbox/ui/workspace/sidebar/sitemap.cljs +++ b/src/uxbox/ui/workspace/sidebar/sitemap.cljs @@ -14,6 +14,7 @@ [uxbox.router :as r] [uxbox.rstore :as rs] [uxbox.state :as st] + [uxbox.state.project :as stpr] [uxbox.shapes :as shapes] [uxbox.library :as library] [uxbox.data.projects :as dp] @@ -24,12 +25,24 @@ [uxbox.ui.icons :as i] [uxbox.ui.mixins :as mx] [uxbox.ui.lightbox :as lightbox] + [uxbox.util.lens :as ul] [uxbox.util.data :refer (read-string parse-int)] [uxbox.util.dom :as dom])) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Lenses +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(def ^:static pages-l + (letfn [(getter [state] + (let [project (get-in state [:workspace :project])] + (stpr/project-pages state project)))] + (as-> (ul/getter getter) $ + (l/focus-atom $ st/state)))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Component -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defn page-item-render [own page total active?] @@ -60,7 +73,7 @@ (defn sitemap-toolbox-render [own] (let [project (rum/react wb/project-l) - pages (rum/react wb/pages-l) + pages (rum/react pages-l) current (rum/react wb/page-l) create #(lightbox/open! :page-form {:page {:project (:id project)}}) close #(rs/emit! (dw/toggle-flag :sitemap))]