Improve history handling on frontend.

This commit is contained in:
Andrey Antukh 2017-03-25 19:35:54 +01:00
parent 691c359985
commit 94677f2f7e
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
11 changed files with 322 additions and 281 deletions

View file

@ -9,21 +9,20 @@
(:require [lentes.core :as l]
[beicon.core :as rx]
[uxbox.main.constants :as c]
[uxbox.main.store :as st]
[uxbox.main.lenses :as ul]))
[uxbox.main.store :as st]))
;; --- Helpers
(defn resolve-project
"Retrieve the current project."
[state]
(let [id (l/focus ul/selected-project state)]
(get-in state [:projects id])))
(let [project-id (get-in state [:workspace :project])]
(get-in state [:projects project-id])))
(defn resolve-page
[state]
(let [id (l/focus ul/selected-page state)]
(get-in state [:pages id])))
(let [page-id (get-in state [:workspace :page])]
(get-in state [:pages page-id])))
(defn- resolve-project-pages
[state]
@ -34,13 +33,19 @@
(sort-by get-order))))
(def workspace
(l/derive ul/workspace st/state))
(-> (l/key :workspace)
(l/derive st/state)))
(def selected-project
"Ref to the current selected project."
(-> (l/lens resolve-project)
(l/derive st/state)))
(def selected-project-id
"Ref to the current selected project id."
(-> (l/key :project)
(l/derive selected-project)))
(def selected-project-pages
(-> (l/lens resolve-project-pages)
(l/derive st/state)))