diff --git a/frontend/uxbox/data/projects.cljs b/frontend/uxbox/data/projects.cljs index 760bbc9aa..2df22b704 100644 --- a/frontend/uxbox/data/projects.cljs +++ b/frontend/uxbox/data/projects.cljs @@ -124,9 +124,10 @@ (reify rs/UpdateEvent (-apply-update [_ state] - (assoc state :workspace {:project projectid - :page pageid - :toolboxes {}})) + (let [s {:project projectid + :page pageid + :toolboxes {}}] + (update state :workspace merge s))) IPrintWithWriter (-pr-writer [mv writer _] diff --git a/frontend/uxbox/data/workspace.cljs b/frontend/uxbox/data/workspace.cljs new file mode 100644 index 000000000..f2b5e92c0 --- /dev/null +++ b/frontend/uxbox/data/workspace.cljs @@ -0,0 +1,25 @@ +(ns uxbox.data.workspace + (:require [uxbox.rstore :as rs] + [uxbox.router :as r] + [uxbox.state :as st] + [uxbox.schema :as sc] + [uxbox.time :as time] + [bouncer.validators :as v])) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Events +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defn toggle-pagesbar + [] + (reify + rs/UpdateEvent + (-apply-update [_ state] + (println "KAKAKA" (get-in state [:workspace :visible-pagebar])) + (update-in state [:workspace :visible-pagebar] (fnil not false))) + + IPrintWithWriter + (-pr-writer [mv writer _] + (-write writer "#")))) + + diff --git a/frontend/uxbox/state.cljs b/frontend/uxbox/state.cljs index 604c35a9a..4550a2349 100644 --- a/frontend/uxbox/state.cljs +++ b/frontend/uxbox/state.cljs @@ -10,6 +10,7 @@ (rs/init {:user {:fullname "Cirilla" :avatar "http://lorempixel.com/50/50/"} :dashboard {:section :dashboard/projects} + :workspace {} :projects-by-id {} :pages-by-id {}})) diff --git a/frontend/uxbox/ui/workspace.cljs b/frontend/uxbox/ui/workspace.cljs index f2b4e5df0..93542d4bf 100644 --- a/frontend/uxbox/ui/workspace.cljs +++ b/frontend/uxbox/ui/workspace.cljs @@ -8,6 +8,7 @@ [uxbox.rstore :as rs] [uxbox.state :as s] [uxbox.data.projects :as dp] + [uxbox.data.workspace :as dw] [uxbox.ui.icons.dashboard :as icons] [uxbox.ui.icons :as i] [uxbox.ui.lightbox :as lightbox] @@ -29,6 +30,10 @@ (dp/project-pages % pid))) $ (l/focus-atom $ s/state))) +(def ^:static workspace-state + (as-> (l/in [:workspace]) $ + (l/focus-atom $ s/state))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Header ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -45,13 +50,14 @@ (defn header-render [own] - (let [page (rum/react page-state)] + (let [page (rum/react page-state) + toggle #(rs/emit! (dw/toggle-pagesbar))] (html [:header#workspace-bar.workspace-bar [:div.main-icon (nav/link (r/route-for :dashboard/projects) i/logo-icon)] [:div.project-tree-btn - {:on-click (constantly nil)} + {:on-click toggle} i/project-tree [:span (:name page)]] [:div.workspace-options @@ -145,7 +151,6 @@ (defn- project-sidebar-pageitem-render [own parent page numpages] - (println "pageitem-render" (:id page)) (letfn [(on-edit [e] (let [data {:edit true :form page}] (reset! parent data)))] @@ -228,8 +233,7 @@ :type "text" :value (get-in @parent [:form :name] "") :on-change on-change - :on-key-up on-key-up - }] + :on-key-up on-key-up}] [:button.btn-primary.btn-small {:disabled (str/empty? (str/trim (get-in @parent [:form :name] ""))) :on-click on-save} @@ -247,11 +251,11 @@ (defn project-sidebar-render [own] (let [local (:rum/local own) - page (rum/react page-state) + workspace (rum/react workspace-state) project (rum/react project-state)] (html [:div#project-bar.project-bar - (when-not (:visible project true) + (when-not (:visible-pagebar workspace false) {:class "toggle"}) (if (:edit @local) (project-sidebar-form local) diff --git a/profiles.clj b/profiles.clj index 665a9b6fd..6e1afb65a 100644 --- a/profiles.clj +++ b/profiles.clj @@ -13,7 +13,7 @@ :common {:dependencies [[org.clojure/clojure "1.7.0"] - [funcool/cats "1.2.0"]]} + [funcool/cats "1.2.1"]]} ;; Backend profile @@ -44,7 +44,6 @@ [bouncer "0.3.3"] [funcool/promesa "0.6.0"] [funcool/beicon "0.3.0"] - [funcool/cats "1.2.0"] [cljsjs/moment "2.10.6-0"] [figwheel-sidecar "0.5.0-2" :scope "test"] [bidi "1.21.0"]