mirror of
https://github.com/penpot/penpot.git
synced 2025-05-08 08:45:53 +02:00
Replace builtin rstore impl with potok.
This commit is contained in:
parent
6f8f115422
commit
40b48318ff
92 changed files with 965 additions and 1063 deletions
|
@ -4,7 +4,7 @@
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2015-2016 Andrey Antukh <niwi@niwi.nz>
|
;; Copyright (c) 2015-2016 Andrey Antukh <niwi@niwi.nz>
|
||||||
|
|
||||||
(ns uxbox.main.state.colors
|
(ns uxbox.builtins.colors
|
||||||
(:require [uxbox.util.uuid :as uuid]
|
(:require [uxbox.util.uuid :as uuid]
|
||||||
[uxbox.util.data :refer (index-by)]))
|
[uxbox.util.data :refer (index-by)]))
|
||||||
|
|
|
@ -3,17 +3,17 @@
|
||||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2015-2016 Andrey Antukh <niwi@niwi.nz>
|
;; Copyright (c) 2015-2016 Andrey Antukh <niwi@niwi.nz>
|
||||||
;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com>
|
|
||||||
|
|
||||||
(ns uxbox.main
|
(ns uxbox.main
|
||||||
(:require [uxbox.util.rstore :as rs]
|
(:require [uxbox.store :as st]
|
||||||
[uxbox.main.state :as st]
|
|
||||||
[uxbox.main.locales :as lc]
|
[uxbox.main.locales :as lc]
|
||||||
[uxbox.main.ui :as ui]))
|
[uxbox.main.ui :as ui]
|
||||||
|
[uxbox.main.state :refer [initial-state]]
|
||||||
|
[uxbox.util.storage :refer [storage]]))
|
||||||
|
|
||||||
(defn ^:export init
|
(defn ^:export init
|
||||||
[]
|
[]
|
||||||
(lc/init)
|
(lc/init)
|
||||||
(st/init)
|
(st/init initial-state)
|
||||||
(ui/init-routes)
|
(ui/init-routes)
|
||||||
(ui/init))
|
(ui/init))
|
||||||
|
|
|
@ -3,21 +3,21 @@
|
||||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2015-2016 Andrey Antukh <niwi@niwi.nz>
|
;; Copyright (c) 2015-2016 Andrey Antukh <niwi@niwi.nz>
|
||||||
;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com>
|
|
||||||
|
|
||||||
(ns uxbox.main.data.auth
|
(ns uxbox.main.data.auth
|
||||||
(:require [cljs.spec :as s]
|
(:require [cljs.spec :as s]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
|
[potok.core :as ptk]
|
||||||
|
[uxbox.store :as st]
|
||||||
[uxbox.main.repo :as rp]
|
[uxbox.main.repo :as rp]
|
||||||
[uxbox.util.rstore :as rs]
|
[uxbox.main.state :refer [initial-state]]
|
||||||
[uxbox.util.router :as rt]
|
|
||||||
[uxbox.util.spec :as us]
|
|
||||||
[uxbox.util.i18n :refer (tr)]
|
|
||||||
[uxbox.main.state :as st]
|
|
||||||
[uxbox.main.data.projects :as udp]
|
[uxbox.main.data.projects :as udp]
|
||||||
[uxbox.main.data.users :as udu]
|
[uxbox.main.data.users :as udu]
|
||||||
[uxbox.main.data.messages :as udm]
|
[uxbox.main.data.messages :as udm]
|
||||||
[uxbox.util.storage :refer (storage)]))
|
[uxbox.util.router :as rt]
|
||||||
|
[uxbox.util.spec :as us]
|
||||||
|
[uxbox.util.i18n :refer (tr)]
|
||||||
|
[uxbox.util.storage :refer [storage]]))
|
||||||
|
|
||||||
(s/def ::username string?)
|
(s/def ::username string?)
|
||||||
(s/def ::password string?)
|
(s/def ::password string?)
|
||||||
|
@ -28,12 +28,12 @@
|
||||||
;; --- Logged In
|
;; --- Logged In
|
||||||
|
|
||||||
(defrecord LoggedIn [data]
|
(defrecord LoggedIn [data]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [this state]
|
(update [this state]
|
||||||
(assoc state :auth data))
|
(assoc state :auth data))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [this state s]
|
(watch [this state s]
|
||||||
(swap! storage assoc :auth data)
|
(swap! storage assoc :auth data)
|
||||||
(rx/of (udu/fetch-profile)
|
(rx/of (udu/fetch-profile)
|
||||||
(rt/navigate :dashboard/projects))))
|
(rt/navigate :dashboard/projects))))
|
||||||
|
@ -49,12 +49,12 @@
|
||||||
;; --- Login
|
;; --- Login
|
||||||
|
|
||||||
(defrecord Login [username password]
|
(defrecord Login [username password]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(merge state (dissoc (st/initial-state) :route)))
|
(merge state (dissoc (initial-state) :route)))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [this state s]
|
(watch [this state s]
|
||||||
(let [params {:username username
|
(let [params {:username username
|
||||||
:password password
|
:password password
|
||||||
:scope "webapp"}
|
:scope "webapp"}
|
||||||
|
@ -75,13 +75,13 @@
|
||||||
;; --- Logout
|
;; --- Logout
|
||||||
|
|
||||||
(defrecord Logout []
|
(defrecord Logout []
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(swap! storage dissoc :auth)
|
(swap! storage dissoc :auth)
|
||||||
(merge state (dissoc (st/initial-state) :route)))
|
(merge state (dissoc (initial-state) :route)))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(rx/of (rt/navigate :auth/login))))
|
(rx/of (rt/navigate :auth/login))))
|
||||||
|
|
||||||
(defn logout
|
(defn logout
|
||||||
|
@ -93,8 +93,8 @@
|
||||||
;; TODO: clean form on success
|
;; TODO: clean form on success
|
||||||
|
|
||||||
(defrecord Register [data on-error]
|
(defrecord Register [data on-error]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(letfn [(handle-error [{payload :payload}]
|
(letfn [(handle-error [{payload :payload}]
|
||||||
(on-error payload)
|
(on-error payload)
|
||||||
(rx/empty))]
|
(rx/empty))]
|
||||||
|
@ -121,8 +121,8 @@
|
||||||
;; --- Recovery Request
|
;; --- Recovery Request
|
||||||
|
|
||||||
(defrecord RecoveryRequest [data]
|
(defrecord RecoveryRequest [data]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(letfn [(on-error [{payload :payload}]
|
(letfn [(on-error [{payload :payload}]
|
||||||
(println "on-error" payload)
|
(println "on-error" payload)
|
||||||
(rx/empty))]
|
(rx/empty))]
|
||||||
|
@ -146,8 +146,8 @@
|
||||||
;; --- Check Recovery Token
|
;; --- Check Recovery Token
|
||||||
|
|
||||||
(defrecord ValidateRecoveryToken [token]
|
(defrecord ValidateRecoveryToken [token]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(letfn [(on-error [{payload :payload}]
|
(letfn [(on-error [{payload :payload}]
|
||||||
(rx/of
|
(rx/of
|
||||||
(rt/navigate :auth/login)
|
(rt/navigate :auth/login)
|
||||||
|
@ -164,8 +164,8 @@
|
||||||
;; --- Recovery (Password)
|
;; --- Recovery (Password)
|
||||||
|
|
||||||
(defrecord Recovery [token password]
|
(defrecord Recovery [token password]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(letfn [(on-error [{payload :payload}]
|
(letfn [(on-error [{payload :payload}]
|
||||||
(udm/error (tr "errors.auth.invalid-recovery-token")))
|
(udm/error (tr "errors.auth.invalid-recovery-token")))
|
||||||
(on-success [{payload :payload}]
|
(on-success [{payload :payload}]
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[uxbox.util.datetime :as dt]
|
[uxbox.util.datetime :as dt]
|
||||||
[uxbox.util.uuid :as uuid]
|
[uxbox.util.uuid :as uuid]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.color :as color]
|
[uxbox.util.color :as color]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.repo :as rp]))
|
[uxbox.main.repo :as rp]))
|
||||||
|
|
||||||
;; --- Initialize
|
;; --- Initialize
|
||||||
|
@ -22,8 +22,8 @@
|
||||||
(declare collections-fetched?)
|
(declare collections-fetched?)
|
||||||
|
|
||||||
(defrecord Initialize [type id]
|
(defrecord Initialize [type id]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [type (or type :own)
|
(let [type (or type :own)
|
||||||
data {:type type
|
data {:type type
|
||||||
:id id
|
:id id
|
||||||
|
@ -32,8 +32,8 @@
|
||||||
(assoc-in [:dashboard :colors] data)
|
(assoc-in [:dashboard :colors] data)
|
||||||
(assoc-in [:dashboard :section] :dashboard/colors))))
|
(assoc-in [:dashboard :section] :dashboard/colors))))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(rx/of (fetch-collections))))
|
(rx/of (fetch-collections))))
|
||||||
|
|
||||||
(defn initialize
|
(defn initialize
|
||||||
|
@ -43,8 +43,8 @@
|
||||||
;; --- Select a Collection
|
;; --- Select a Collection
|
||||||
|
|
||||||
(defrecord SelectCollection [type id]
|
(defrecord SelectCollection [type id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(rx/of (r/navigate :dashboard/colors
|
(rx/of (r/navigate :dashboard/colors
|
||||||
{:type type :id id}))))
|
{:type type :id id}))))
|
||||||
|
|
||||||
|
@ -58,8 +58,8 @@
|
||||||
;; --- Collections Fetched
|
;; --- Collections Fetched
|
||||||
|
|
||||||
(defrecord CollectionsFetched [data]
|
(defrecord CollectionsFetched [data]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [{:keys [version value]} data]
|
(let [{:keys [version value]} data]
|
||||||
(-> state
|
(-> state
|
||||||
(update :colors-collections merge value)
|
(update :colors-collections merge value)
|
||||||
|
@ -77,8 +77,8 @@
|
||||||
;; --- Fetch Collections
|
;; --- Fetch Collections
|
||||||
|
|
||||||
(defrecord FetchCollections []
|
(defrecord FetchCollections []
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(->> (rp/req :fetch/kvstore "color-collections")
|
(->> (rp/req :fetch/kvstore "color-collections")
|
||||||
(rx/map :payload)
|
(rx/map :payload)
|
||||||
(rx/map collections-fetched))))
|
(rx/map collections-fetched))))
|
||||||
|
@ -90,8 +90,8 @@
|
||||||
;; --- Create Collection
|
;; --- Create Collection
|
||||||
|
|
||||||
(defrecord CreateCollection [id]
|
(defrecord CreateCollection [id]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [item {:name "Unnamed collection"
|
(let [item {:name "Unnamed collection"
|
||||||
:id id
|
:id id
|
||||||
:created-at (dt/now)
|
:created-at (dt/now)
|
||||||
|
@ -99,8 +99,8 @@
|
||||||
:colors #{}}]
|
:colors #{}}]
|
||||||
(assoc-in state [:colors-collections id] item)))
|
(assoc-in state [:colors-collections id] item)))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(rx/of (persist-collections)
|
(rx/of (persist-collections)
|
||||||
(select-collection :own id))))
|
(select-collection :own id))))
|
||||||
|
|
||||||
|
@ -112,8 +112,8 @@
|
||||||
;; --- Persist Collections
|
;; --- Persist Collections
|
||||||
|
|
||||||
(defrecord PersistCollections []
|
(defrecord PersistCollections []
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [builtin? #(= :builtin (:type %))
|
(let [builtin? #(= :builtin (:type %))
|
||||||
xform (remove (comp builtin? second))
|
xform (remove (comp builtin? second))
|
||||||
version (or (get state ::version) -1)
|
version (or (get state ::version) -1)
|
||||||
|
@ -133,12 +133,12 @@
|
||||||
;; --- Rename Collection
|
;; --- Rename Collection
|
||||||
|
|
||||||
(defrecord RenameCollection [id name]
|
(defrecord RenameCollection [id name]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:colors-collections id :name] name))
|
(assoc-in state [:colors-collections id :name] name))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(rx/of (persist-collections))))
|
(rx/of (persist-collections))))
|
||||||
|
|
||||||
(defn rename-collection
|
(defn rename-collection
|
||||||
|
@ -148,12 +148,12 @@
|
||||||
;; --- Delete Collection
|
;; --- Delete Collection
|
||||||
|
|
||||||
(defrecord DeleteCollection [id]
|
(defrecord DeleteCollection [id]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update state :colors-collections dissoc id))
|
(update state :colors-collections dissoc id))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [type (get-in state [:dashboard :colors :type])]
|
(let [type (get-in state [:dashboard :colors :type])]
|
||||||
(rx/of (persist-collections)
|
(rx/of (persist-collections)
|
||||||
(select-collection type)))))
|
(select-collection type)))))
|
||||||
|
@ -165,13 +165,13 @@
|
||||||
;; --- Replace Color
|
;; --- Replace Color
|
||||||
|
|
||||||
(defrecord ReplaceColor [id from to]
|
(defrecord ReplaceColor [id from to]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [replacer #(-> (disj % from) (conj to))]
|
(let [replacer #(-> (disj % from) (conj to))]
|
||||||
(update-in state [:colors-collections id :colors] (fnil replacer #{}))))
|
(update-in state [:colors-collections id :colors] (fnil replacer #{}))))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(rx/of (persist-collections))))
|
(rx/of (persist-collections))))
|
||||||
|
|
||||||
(defn replace-color
|
(defn replace-color
|
||||||
|
@ -182,13 +182,13 @@
|
||||||
;; --- Remove Color
|
;; --- Remove Color
|
||||||
|
|
||||||
(defrecord RemoveColors [id colors]
|
(defrecord RemoveColors [id colors]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:colors-collections id :colors]
|
(update-in state [:colors-collections id :colors]
|
||||||
#(set/difference % colors)))
|
#(set/difference % colors)))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(rx/of (persist-collections))))
|
(rx/of (persist-collections))))
|
||||||
|
|
||||||
(defn remove-colors
|
(defn remove-colors
|
||||||
|
@ -199,18 +199,18 @@
|
||||||
;; --- Select color
|
;; --- Select color
|
||||||
|
|
||||||
(defrecord SelectColor [color]
|
(defrecord SelectColor [color]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:dashboard :colors :selected] conj color)))
|
(update-in state [:dashboard :colors :selected] conj color)))
|
||||||
|
|
||||||
(defrecord DeselectColor [color]
|
(defrecord DeselectColor [color]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:dashboard :colors :selected] disj color)))
|
(update-in state [:dashboard :colors :selected] disj color)))
|
||||||
|
|
||||||
(defrecord ToggleColorSelection [color]
|
(defrecord ToggleColorSelection [color]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [selected (get-in state [:dashboard :colors :selected])]
|
(let [selected (get-in state [:dashboard :colors :selected])]
|
||||||
(rx/of
|
(rx/of
|
||||||
(if (selected color)
|
(if (selected color)
|
||||||
|
@ -225,13 +225,13 @@
|
||||||
;; --- Copy Selected Icon
|
;; --- Copy Selected Icon
|
||||||
|
|
||||||
(defrecord CopySelected [id]
|
(defrecord CopySelected [id]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [selected (get-in state [:dashboard :colors :selected])]
|
(let [selected (get-in state [:dashboard :colors :selected])]
|
||||||
(update-in state [:colors-collections id :colors] set/union selected)))
|
(update-in state [:colors-collections id :colors] set/union selected)))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(rx/of (persist-collections))))
|
(rx/of (persist-collections))))
|
||||||
|
|
||||||
(defn copy-selected
|
(defn copy-selected
|
||||||
|
@ -242,15 +242,15 @@
|
||||||
;; --- Move Selected Icon
|
;; --- Move Selected Icon
|
||||||
|
|
||||||
(defrecord MoveSelected [from to]
|
(defrecord MoveSelected [from to]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [selected (get-in state [:dashboard :colors :selected])]
|
(let [selected (get-in state [:dashboard :colors :selected])]
|
||||||
(-> state
|
(-> state
|
||||||
(update-in [:colors-collections from :colors] set/difference selected)
|
(update-in [:colors-collections from :colors] set/difference selected)
|
||||||
(update-in [:colors-collections to :colors] set/union selected))))
|
(update-in [:colors-collections to :colors] set/union selected))))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(rx/of (persist-collections))))
|
(rx/of (persist-collections))))
|
||||||
|
|
||||||
(defn move-selected
|
(defn move-selected
|
||||||
|
@ -262,8 +262,8 @@
|
||||||
;; --- Delete Selected Colors
|
;; --- Delete Selected Colors
|
||||||
|
|
||||||
(defrecord DeleteSelectedColors []
|
(defrecord DeleteSelectedColors []
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [{:keys [id selected]} (get-in state [:dashboard :colors])]
|
(let [{:keys [id selected]} (get-in state [:dashboard :colors])]
|
||||||
(rx/of (remove-colors id selected)
|
(rx/of (remove-colors id selected)
|
||||||
#(assoc-in % [:dashboard :colors :selected] #{})))))
|
#(assoc-in % [:dashboard :colors :selected] #{})))))
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
(ns uxbox.main.data.core
|
(ns uxbox.main.data.core
|
||||||
"Worker related api and initialization events."
|
"Worker related api and initialization events."
|
||||||
(:require [beicon.core :as rx]
|
(:require [beicon.core :as rx]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.workers :as uw]
|
[uxbox.util.workers :as uw]
|
||||||
[uxbox.main.constants :as c]))
|
[uxbox.main.constants :as c]))
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
(ns uxbox.main.data.dashboard
|
(ns uxbox.main.data.dashboard
|
||||||
(:require [beicon.core :as rx]
|
(:require [beicon.core :as rx]
|
||||||
[uxbox.util.uuid :as uuid]
|
[uxbox.util.uuid :as uuid]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.util.forms :as sc]
|
[uxbox.util.forms :as sc]
|
||||||
[uxbox.main.repo :as rp]
|
[uxbox.main.repo :as rp]
|
||||||
[uxbox.main.data.projects :as dp]
|
[uxbox.main.data.projects :as dp]
|
||||||
|
@ -21,8 +21,8 @@
|
||||||
;; --- Events
|
;; --- Events
|
||||||
|
|
||||||
(defrecord InitializeDashboard [section]
|
(defrecord InitializeDashboard [section]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update state :dashboard assoc
|
(update state :dashboard assoc
|
||||||
:section section
|
:section section
|
||||||
:collection-type :builtin
|
:collection-type :builtin
|
||||||
|
@ -41,8 +41,8 @@
|
||||||
(let [colls (sort-by :id (vals (:colors-by-id state)))]
|
(let [colls (sort-by :id (vals (:colors-by-id state)))]
|
||||||
(assoc-in state [:dashboard :collection-id] (:id (first colls))))))]
|
(assoc-in state [:dashboard :collection-id] (:id (first colls))))))]
|
||||||
(reify
|
(reify
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(as-> state $
|
(as-> state $
|
||||||
(assoc-in $ [:dashboard :collection-type] type)
|
(assoc-in $ [:dashboard :collection-type] type)
|
||||||
(select-first $))))))
|
(select-first $))))))
|
||||||
|
@ -50,6 +50,6 @@
|
||||||
(defn set-collection
|
(defn set-collection
|
||||||
[id]
|
[id]
|
||||||
(reify
|
(reify
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:dashboard :collection-id] id))))
|
(assoc-in state [:dashboard :collection-id] id))))
|
||||||
|
|
|
@ -8,13 +8,13 @@
|
||||||
(:require [cuerdas.core :as str]
|
(:require [cuerdas.core :as str]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.main.repo :as rp]
|
[uxbox.main.repo :as rp]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.forms :as sc]
|
[uxbox.util.forms :as sc]
|
||||||
[uxbox.main.data.pages :as udp]
|
[uxbox.main.data.pages :as udp]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.util.datetime :as dt]
|
[uxbox.util.datetime :as dt]
|
||||||
[uxbox.util.data :refer (without-keys
|
[uxbox.util.data :refer (without-keys
|
||||||
replace-by-id
|
replace-by-id
|
||||||
|
@ -32,9 +32,9 @@
|
||||||
persists the state of the page in an undo stack."
|
persists the state of the page in an undo stack."
|
||||||
[]
|
[]
|
||||||
(letfn [(on-value [id]
|
(letfn [(on-value [id]
|
||||||
(rs/emit! (fetch-page-history id)
|
(st/emit! (fetch-page-history id)
|
||||||
(fetch-pinned-page-history id)))]
|
(fetch-pinned-page-history id)))]
|
||||||
(as-> rs/stream $
|
(as-> st/store $
|
||||||
(rx/filter udp/page-persisted? $)
|
(rx/filter udp/page-persisted? $)
|
||||||
(rx/debounce 500 $)
|
(rx/debounce 500 $)
|
||||||
(rx/map (comp :id :data) $)
|
(rx/map (comp :id :data) $)
|
||||||
|
@ -45,8 +45,8 @@
|
||||||
(declare update-history-index)
|
(declare update-history-index)
|
||||||
|
|
||||||
(defrecord PinnedPageHistoryFetched [history]
|
(defrecord PinnedPageHistoryFetched [history]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(-> state
|
(-> state
|
||||||
(assoc-in [:workspace :history :pinned-items] (mapv :version history))
|
(assoc-in [:workspace :history :pinned-items] (mapv :version history))
|
||||||
(update-history-index history true))))
|
(update-history-index history true))))
|
||||||
|
@ -54,8 +54,8 @@
|
||||||
;; --- Fetch Pinned Page History
|
;; --- Fetch Pinned Page History
|
||||||
|
|
||||||
(defrecord FetchPinnedPageHistory [id]
|
(defrecord FetchPinnedPageHistory [id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(letfn [(on-success [{history :payload}]
|
(letfn [(on-success [{history :payload}]
|
||||||
(->PinnedPageHistoryFetched (into [] history)))]
|
(->PinnedPageHistoryFetched (into [] history)))]
|
||||||
(let [params {:page id :pinned true}]
|
(let [params {:page id :pinned true}]
|
||||||
|
@ -69,8 +69,8 @@
|
||||||
;; --- Page History Fetched
|
;; --- Page History Fetched
|
||||||
|
|
||||||
(defrecord PageHistoryFetched [history append?]
|
(defrecord PageHistoryFetched [history append?]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(letfn [(update-counters [state items]
|
(letfn [(update-counters [state items]
|
||||||
(-> (assoc state :min-version (apply min items))
|
(-> (assoc state :min-version (apply min items))
|
||||||
(assoc :max-version (apply max items))))
|
(assoc :max-version (apply max items))))
|
||||||
|
@ -91,8 +91,8 @@
|
||||||
;; --- Fetch Page History
|
;; --- Fetch Page History
|
||||||
|
|
||||||
(defrecord FetchPageHistory [id since max]
|
(defrecord FetchPageHistory [id since max]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(letfn [(on-success [{history :payload}]
|
(letfn [(on-success [{history :payload}]
|
||||||
(let [history (into [] history)]
|
(let [history (into [] history)]
|
||||||
(->PageHistoryFetched history (not (nil? since)))))]
|
(->PageHistoryFetched history (not (nil? since)))))]
|
||||||
|
@ -111,8 +111,8 @@
|
||||||
;; --- Select Page History
|
;; --- Select Page History
|
||||||
|
|
||||||
(defrecord SelectPageHistory [version]
|
(defrecord SelectPageHistory [version]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [item (get-in state [:workspace :history :by-version version])
|
(let [item (get-in state [:workspace :history :by-version version])
|
||||||
page (get-in state [:pages (:page item)])
|
page (get-in state [:pages (:page item)])
|
||||||
page (assoc page
|
page (assoc page
|
||||||
|
@ -129,14 +129,14 @@
|
||||||
;; --- Apply selected history
|
;; --- Apply selected history
|
||||||
|
|
||||||
(defrecord ApplySelectedHistory [id]
|
(defrecord ApplySelectedHistory [id]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(-> state
|
(-> state
|
||||||
(update-in [:pages id] dissoc :history)
|
(update-in [:pages id] dissoc :history)
|
||||||
(assoc-in [:workspace :history :selected] nil)))
|
(assoc-in [:workspace :history :selected] nil)))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(rx/of (udp/persist-page id))))
|
(rx/of (udp/persist-page id))))
|
||||||
|
|
||||||
(defn apply-selected-history
|
(defn apply-selected-history
|
||||||
|
@ -146,15 +146,15 @@
|
||||||
;; --- Deselect Page History
|
;; --- Deselect Page History
|
||||||
|
|
||||||
(defrecord DeselectPageHistory [id]
|
(defrecord DeselectPageHistory [id]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [packed (get-in state [:packed-pages id])]
|
(let [packed (get-in state [:packed-pages id])]
|
||||||
(-> (udp/assoc-page state packed)
|
(-> (udp/assoc-page state packed)
|
||||||
(assoc-in [:workspace :history :deselecting] true)
|
(assoc-in [:workspace :history :deselecting] true)
|
||||||
(assoc-in [:workspace :history :selected] nil))))
|
(assoc-in [:workspace :history :selected] nil))))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(->> (rx/of #(assoc-in % [:workspace :history :deselecting] false))
|
(->> (rx/of #(assoc-in % [:workspace :history :deselecting] false))
|
||||||
(rx/delay 500))))
|
(rx/delay 500))))
|
||||||
|
|
||||||
|
@ -165,8 +165,8 @@
|
||||||
;; --- History Item Updated
|
;; --- History Item Updated
|
||||||
|
|
||||||
(defrecord HistoryItemUpdated [item]
|
(defrecord HistoryItemUpdated [item]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(-> state
|
(-> state
|
||||||
(update-in [:workspace :history :items] replace-by-id item)
|
(update-in [:workspace :history :items] replace-by-id item)
|
||||||
(update-in [:workspace :history :pinned-items] replace-by-id item))))
|
(update-in [:workspace :history :pinned-items] replace-by-id item))))
|
||||||
|
@ -182,8 +182,8 @@
|
||||||
;; --- Refresh Page History
|
;; --- Refresh Page History
|
||||||
|
|
||||||
(defrecord RefreshPageHistory [id]
|
(defrecord RefreshPageHistory [id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [history (get-in state [:workspace :history])
|
(let [history (get-in state [:workspace :history])
|
||||||
maxitems (count (:items history))]
|
maxitems (count (:items history))]
|
||||||
(rx/of (fetch-page-history id {:max maxitems})
|
(rx/of (fetch-page-history id {:max maxitems})
|
||||||
|
@ -196,8 +196,8 @@
|
||||||
;; --- Update History Item
|
;; --- Update History Item
|
||||||
|
|
||||||
(defrecord UpdateHistoryItem [item]
|
(defrecord UpdateHistoryItem [item]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(letfn [(on-success [{item :payload}]
|
(letfn [(on-success [{item :payload}]
|
||||||
(->HistoryItemUpdated item))]
|
(->HistoryItemUpdated item))]
|
||||||
(rx/merge
|
(rx/merge
|
||||||
|
@ -214,8 +214,8 @@
|
||||||
;; --- Forward to Next Version
|
;; --- Forward to Next Version
|
||||||
|
|
||||||
(defrecord ForwardToNextVersion []
|
(defrecord ForwardToNextVersion []
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [workspace (:workspace state)
|
(let [workspace (:workspace state)
|
||||||
history (:history workspace)
|
history (:history workspace)
|
||||||
version (:selected history)]
|
version (:selected history)]
|
||||||
|
@ -239,8 +239,8 @@
|
||||||
;; --- Backwards to Previous Version
|
;; --- Backwards to Previous Version
|
||||||
|
|
||||||
(defrecord BackwardsToPreviousVersion []
|
(defrecord BackwardsToPreviousVersion []
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [workspace (:workspace state)
|
(let [workspace (:workspace state)
|
||||||
history (:history workspace)
|
history (:history workspace)
|
||||||
version (:selected history)]
|
version (:selected history)]
|
||||||
|
|
|
@ -9,11 +9,11 @@
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[uxbox.util.data :refer (jscoll->vec)]
|
[uxbox.util.data :refer (jscoll->vec)]
|
||||||
[uxbox.util.uuid :as uuid]
|
[uxbox.util.uuid :as uuid]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
[uxbox.util.files :as files]
|
[uxbox.util.files :as files]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.repo :as rp]))
|
[uxbox.main.repo :as rp]))
|
||||||
|
|
||||||
;; --- Initialize
|
;; --- Initialize
|
||||||
|
@ -23,16 +23,16 @@
|
||||||
(declare collections-fetched?)
|
(declare collections-fetched?)
|
||||||
|
|
||||||
(defrecord Initialize [type id]
|
(defrecord Initialize [type id]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [type (or type :own)
|
(let [type (or type :own)
|
||||||
data {:type type :id id :selected #{}}]
|
data {:type type :id id :selected #{}}]
|
||||||
(-> state
|
(-> state
|
||||||
(assoc-in [:dashboard :icons] data)
|
(assoc-in [:dashboard :icons] data)
|
||||||
(assoc-in [:dashboard :section] :dashboard/icons))))
|
(assoc-in [:dashboard :section] :dashboard/icons))))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(rx/merge (rx/of (fetch-collections))
|
(rx/merge (rx/of (fetch-collections))
|
||||||
(rx/of (fetch-icons id)))))
|
(rx/of (fetch-icons id)))))
|
||||||
|
|
||||||
|
@ -43,8 +43,8 @@
|
||||||
;; --- Select a Collection
|
;; --- Select a Collection
|
||||||
|
|
||||||
(defrecord SelectCollection [type id]
|
(defrecord SelectCollection [type id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(rx/of (r/navigate :dashboard/icons
|
(rx/of (r/navigate :dashboard/icons
|
||||||
{:type type :id id}))))
|
{:type type :id id}))))
|
||||||
|
|
||||||
|
@ -58,8 +58,8 @@
|
||||||
;; --- Collections Fetched
|
;; --- Collections Fetched
|
||||||
|
|
||||||
(defrecord CollectionsFetched [items]
|
(defrecord CollectionsFetched [items]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(reduce (fn [state {:keys [id user] :as item}]
|
(reduce (fn [state {:keys [id user] :as item}]
|
||||||
(let [type (if (uuid/zero? (:user item)) :builtin :own)
|
(let [type (if (uuid/zero? (:user item)) :builtin :own)
|
||||||
item (assoc item :type type)]
|
item (assoc item :type type)]
|
||||||
|
@ -74,8 +74,8 @@
|
||||||
;; --- Fetch Collections
|
;; --- Fetch Collections
|
||||||
|
|
||||||
(defrecord FetchCollections []
|
(defrecord FetchCollections []
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(->> (rp/req :fetch/icon-collections)
|
(->> (rp/req :fetch/icon-collections)
|
||||||
(rx/map :payload)
|
(rx/map :payload)
|
||||||
(rx/map collections-fetched))))
|
(rx/map collections-fetched))))
|
||||||
|
@ -87,13 +87,13 @@
|
||||||
;; --- Collection Created
|
;; --- Collection Created
|
||||||
|
|
||||||
(defrecord CollectionCreated [item]
|
(defrecord CollectionCreated [item]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [{:keys [id] :as item} (assoc item :type :own)]
|
(let [{:keys [id] :as item} (assoc item :type :own)]
|
||||||
(update state :icons-collections assoc id item)))
|
(update state :icons-collections assoc id item)))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(rx/of (select-collection :own (:id item)))))
|
(rx/of (select-collection :own (:id item)))))
|
||||||
|
|
||||||
(defn collection-created
|
(defn collection-created
|
||||||
|
@ -103,8 +103,8 @@
|
||||||
;; --- Create Collection
|
;; --- Create Collection
|
||||||
|
|
||||||
(defrecord CreateCollection []
|
(defrecord CreateCollection []
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [name (str "Unnamed Collection (" (gensym "c") ")")
|
(let [name (str "Unnamed Collection (" (gensym "c") ")")
|
||||||
coll {:name name}]
|
coll {:name name}]
|
||||||
(->> (rp/req :create/icon-collection coll)
|
(->> (rp/req :create/icon-collection coll)
|
||||||
|
@ -122,8 +122,8 @@
|
||||||
;; --- Collection Updated
|
;; --- Collection Updated
|
||||||
|
|
||||||
(defrecord CollectionUpdated [item]
|
(defrecord CollectionUpdated [item]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:icons-collections (:id item)] merge item)))
|
(update-in state [:icons-collections (:id item)] merge item)))
|
||||||
|
|
||||||
(defn collection-updated
|
(defn collection-updated
|
||||||
|
@ -133,8 +133,8 @@
|
||||||
;; --- Update Collection
|
;; --- Update Collection
|
||||||
|
|
||||||
(defrecord UpdateCollection [id]
|
(defrecord UpdateCollection [id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [item (get-in state [:icons-collections id])]
|
(let [item (get-in state [:icons-collections id])]
|
||||||
(->> (rp/req :update/icon-collection item)
|
(->> (rp/req :update/icon-collection item)
|
||||||
(rx/map :payload)
|
(rx/map :payload)
|
||||||
|
@ -147,12 +147,12 @@
|
||||||
;; --- Rename Collection
|
;; --- Rename Collection
|
||||||
|
|
||||||
(defrecord RenameCollection [id name]
|
(defrecord RenameCollection [id name]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:icons-collections id :name] name))
|
(assoc-in state [:icons-collections id :name] name))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(rx/of (update-collection id))))
|
(rx/of (update-collection id))))
|
||||||
|
|
||||||
(defn rename-collection
|
(defn rename-collection
|
||||||
|
@ -162,12 +162,12 @@
|
||||||
;; --- Delete Collection
|
;; --- Delete Collection
|
||||||
|
|
||||||
(defrecord DeleteCollection [id]
|
(defrecord DeleteCollection [id]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update state :icons-collections dissoc id))
|
(update state :icons-collections dissoc id))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [type (get-in state [:dashboard :icons :type])]
|
(let [type (get-in state [:dashboard :icons :type])]
|
||||||
(->> (rp/req :delete/icon-collection id)
|
(->> (rp/req :delete/icon-collection id)
|
||||||
(rx/map #(select-collection type))))))
|
(rx/map #(select-collection type))))))
|
||||||
|
@ -179,8 +179,8 @@
|
||||||
;; --- Icon Created
|
;; --- Icon Created
|
||||||
|
|
||||||
(defrecord IconCreated [item]
|
(defrecord IconCreated [item]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [{:keys [id] :as item} (assoc item :type :icon)]
|
(let [{:keys [id] :as item} (assoc item :type :icon)]
|
||||||
(update state :icons assoc id item))))
|
(update state :icons assoc id item))))
|
||||||
|
|
||||||
|
@ -220,8 +220,8 @@
|
||||||
[(dom/get-outer-html g) props])))))
|
[(dom/get-outer-html g) props])))))
|
||||||
|
|
||||||
(defrecord CreateIcons [id files]
|
(defrecord CreateIcons [id files]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(letfn [(parse [file]
|
(letfn [(parse [file]
|
||||||
(->> (files/read-as-text file)
|
(->> (files/read-as-text file)
|
||||||
(rx/map parse-svg)))
|
(rx/map parse-svg)))
|
||||||
|
@ -248,8 +248,8 @@
|
||||||
;; --- Icon Persisted
|
;; --- Icon Persisted
|
||||||
|
|
||||||
(defrecord IconPersisted [id data]
|
(defrecord IconPersisted [id data]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:icons id] data)))
|
(assoc-in state [:icons id] data)))
|
||||||
|
|
||||||
(defn icon-persisted
|
(defn icon-persisted
|
||||||
|
@ -260,8 +260,8 @@
|
||||||
;; --- Persist Icon
|
;; --- Persist Icon
|
||||||
|
|
||||||
(defrecord PersistIcon [id]
|
(defrecord PersistIcon [id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [icon (get-in state [:icons id])]
|
(let [icon (get-in state [:icons id])]
|
||||||
(->> (rp/req :update/icon icon)
|
(->> (rp/req :update/icon icon)
|
||||||
(rx/map :payload)
|
(rx/map :payload)
|
||||||
|
@ -275,8 +275,8 @@
|
||||||
;; --- Icons Fetched
|
;; --- Icons Fetched
|
||||||
|
|
||||||
(defrecord IconsFetched [items]
|
(defrecord IconsFetched [items]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(reduce (fn [state {:keys [id] :as icon}]
|
(reduce (fn [state {:keys [id] :as icon}]
|
||||||
(let [icon (assoc icon :type :icon)]
|
(let [icon (assoc icon :type :icon)]
|
||||||
(assoc-in state [:icons id] icon)))
|
(assoc-in state [:icons id] icon)))
|
||||||
|
@ -290,8 +290,8 @@
|
||||||
;; --- Load Icons
|
;; --- Load Icons
|
||||||
|
|
||||||
(defrecord FetchIcons [id]
|
(defrecord FetchIcons [id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [params {:coll id}]
|
(let [params {:coll id}]
|
||||||
(->> (rp/req :fetch/icons params)
|
(->> (rp/req :fetch/icons params)
|
||||||
(rx/map :payload)
|
(rx/map :payload)
|
||||||
|
@ -305,14 +305,14 @@
|
||||||
;; --- Delete Icons
|
;; --- Delete Icons
|
||||||
|
|
||||||
(defrecord DeleteIcon [id]
|
(defrecord DeleteIcon [id]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(-> state
|
(-> state
|
||||||
(update :icons dissoc id)
|
(update :icons dissoc id)
|
||||||
(update-in [:dashboard :icons :selected] disj id)))
|
(update-in [:dashboard :icons :selected] disj id)))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(->> (rp/req :delete/icon id)
|
(->> (rp/req :delete/icon id)
|
||||||
(rx/ignore))))
|
(rx/ignore))))
|
||||||
|
|
||||||
|
@ -324,12 +324,12 @@
|
||||||
;; --- Rename Icon
|
;; --- Rename Icon
|
||||||
|
|
||||||
(defrecord RenameIcon [id name]
|
(defrecord RenameIcon [id name]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:icons id :name] name))
|
(assoc-in state [:icons id :name] name))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(rx/of (persist-icon id))))
|
(rx/of (persist-icon id))))
|
||||||
|
|
||||||
(defn rename-icon
|
(defn rename-icon
|
||||||
|
@ -340,18 +340,18 @@
|
||||||
;; --- Select icon
|
;; --- Select icon
|
||||||
|
|
||||||
(defrecord SelectIcon [id]
|
(defrecord SelectIcon [id]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:dashboard :icons :selected] conj id)))
|
(update-in state [:dashboard :icons :selected] conj id)))
|
||||||
|
|
||||||
(defrecord DeselectIcon [id]
|
(defrecord DeselectIcon [id]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:dashboard :icons :selected] disj id)))
|
(update-in state [:dashboard :icons :selected] disj id)))
|
||||||
|
|
||||||
(defrecord ToggleIconSelection [id]
|
(defrecord ToggleIconSelection [id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [selected (get-in state [:dashboard :icons :selected])]
|
(let [selected (get-in state [:dashboard :icons :selected])]
|
||||||
(rx/of
|
(rx/of
|
||||||
(if (selected id)
|
(if (selected id)
|
||||||
|
@ -370,8 +370,8 @@
|
||||||
;; --- Copy Selected Icon
|
;; --- Copy Selected Icon
|
||||||
|
|
||||||
(defrecord CopySelected [id]
|
(defrecord CopySelected [id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [selected (get-in state [:dashboard :icons :selected])]
|
(let [selected (get-in state [:dashboard :icons :selected])]
|
||||||
(rx/merge
|
(rx/merge
|
||||||
(->> (rx/from-coll selected)
|
(->> (rx/from-coll selected)
|
||||||
|
@ -392,16 +392,16 @@
|
||||||
;; --- Move Selected Icon
|
;; --- Move Selected Icon
|
||||||
|
|
||||||
(defrecord MoveSelected [id]
|
(defrecord MoveSelected [id]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [selected (get-in state [:dashboard :icons :selected])]
|
(let [selected (get-in state [:dashboard :icons :selected])]
|
||||||
(reduce (fn [state icon]
|
(reduce (fn [state icon]
|
||||||
(assoc-in state [:icons icon :collection] id))
|
(assoc-in state [:icons icon :collection] id))
|
||||||
state
|
state
|
||||||
selected)))
|
selected)))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [selected (get-in state [:dashboard :icons :selected])]
|
(let [selected (get-in state [:dashboard :icons :selected])]
|
||||||
(rx/merge
|
(rx/merge
|
||||||
(->> (rx/from-coll selected)
|
(->> (rx/from-coll selected)
|
||||||
|
@ -417,8 +417,8 @@
|
||||||
;; --- Delete Selected
|
;; --- Delete Selected
|
||||||
|
|
||||||
(defrecord DeleteSelected []
|
(defrecord DeleteSelected []
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [selected (get-in state [:dashboard :icons :selected])]
|
(let [selected (get-in state [:dashboard :icons :selected])]
|
||||||
(->> (rx/from-coll selected)
|
(->> (rx/from-coll selected)
|
||||||
(rx/map delete-icon)))))
|
(rx/map delete-icon)))))
|
||||||
|
@ -430,8 +430,8 @@
|
||||||
;; --- Update Opts (Filtering & Ordering)
|
;; --- Update Opts (Filtering & Ordering)
|
||||||
|
|
||||||
(defrecord UpdateOpts [order filter edition]
|
(defrecord UpdateOpts [order filter edition]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:dashboard :icons] merge
|
(update-in state [:dashboard :icons] merge
|
||||||
{:edition edition}
|
{:edition edition}
|
||||||
(when order {:order order})
|
(when order {:order order})
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[uxbox.util.data :refer (jscoll->vec)]
|
[uxbox.util.data :refer (jscoll->vec)]
|
||||||
[uxbox.util.uuid :as uuid]
|
[uxbox.util.uuid :as uuid]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.files :as files]
|
[uxbox.util.files :as files]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.repo :as rp]))
|
[uxbox.main.repo :as rp]))
|
||||||
|
|
||||||
;; --- Initialize
|
;; --- Initialize
|
||||||
|
@ -22,16 +22,16 @@
|
||||||
(declare collections-fetched?)
|
(declare collections-fetched?)
|
||||||
|
|
||||||
(defrecord Initialize [type id]
|
(defrecord Initialize [type id]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [type (or type :own)
|
(let [type (or type :own)
|
||||||
data {:type type :id id :selected #{}}]
|
data {:type type :id id :selected #{}}]
|
||||||
(-> state
|
(-> state
|
||||||
(assoc-in [:dashboard :images] data)
|
(assoc-in [:dashboard :images] data)
|
||||||
(assoc-in [:dashboard :section] :dashboard/images))))
|
(assoc-in [:dashboard :section] :dashboard/images))))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(rx/merge (rx/of (fetch-collections))
|
(rx/merge (rx/of (fetch-collections))
|
||||||
(rx/of (fetch-images id)))))
|
(rx/of (fetch-images id)))))
|
||||||
|
|
||||||
|
@ -42,8 +42,8 @@
|
||||||
;; --- Select a Collection
|
;; --- Select a Collection
|
||||||
|
|
||||||
(defrecord SelectCollection [type id]
|
(defrecord SelectCollection [type id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(rx/of (r/navigate :dashboard/images
|
(rx/of (r/navigate :dashboard/images
|
||||||
{:type type :id id}))))
|
{:type type :id id}))))
|
||||||
|
|
||||||
|
@ -57,8 +57,8 @@
|
||||||
;; --- Color Collections Fetched
|
;; --- Color Collections Fetched
|
||||||
|
|
||||||
(defrecord CollectionsFetched [items]
|
(defrecord CollectionsFetched [items]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(reduce (fn [state {:keys [id user] :as item}]
|
(reduce (fn [state {:keys [id user] :as item}]
|
||||||
(let [type (if (uuid/zero? (:user item)) :builtin :own)
|
(let [type (if (uuid/zero? (:user item)) :builtin :own)
|
||||||
item (assoc item :type type)]
|
item (assoc item :type type)]
|
||||||
|
@ -73,8 +73,8 @@
|
||||||
;; --- Fetch Color Collections
|
;; --- Fetch Color Collections
|
||||||
|
|
||||||
(defrecord FetchCollections []
|
(defrecord FetchCollections []
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(->> (rp/req :fetch/image-collections)
|
(->> (rp/req :fetch/image-collections)
|
||||||
(rx/map :payload)
|
(rx/map :payload)
|
||||||
(rx/map collections-fetched))))
|
(rx/map collections-fetched))))
|
||||||
|
@ -86,13 +86,13 @@
|
||||||
;; --- Collection Created
|
;; --- Collection Created
|
||||||
|
|
||||||
(defrecord CollectionCreated [item]
|
(defrecord CollectionCreated [item]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [{:keys [id] :as item} (assoc item :type :own)]
|
(let [{:keys [id] :as item} (assoc item :type :own)]
|
||||||
(update state :images-collections assoc id item)))
|
(update state :images-collections assoc id item)))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(rx/of (select-collection :own (:id item)))))
|
(rx/of (select-collection :own (:id item)))))
|
||||||
|
|
||||||
(defn collection-created
|
(defn collection-created
|
||||||
|
@ -102,8 +102,8 @@
|
||||||
;; --- Create Collection
|
;; --- Create Collection
|
||||||
|
|
||||||
(defrecord CreateCollection []
|
(defrecord CreateCollection []
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [coll {:name "Unnamed collection"
|
(let [coll {:name "Unnamed collection"
|
||||||
:id (uuid/random)}]
|
:id (uuid/random)}]
|
||||||
(->> (rp/req :create/image-collection coll)
|
(->> (rp/req :create/image-collection coll)
|
||||||
|
@ -121,8 +121,8 @@
|
||||||
;; --- Collection Updated
|
;; --- Collection Updated
|
||||||
|
|
||||||
(defrecord CollectionUpdated [item]
|
(defrecord CollectionUpdated [item]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:images-collections (:id item)] merge item)))
|
(update-in state [:images-collections (:id item)] merge item)))
|
||||||
|
|
||||||
(defn collection-updated
|
(defn collection-updated
|
||||||
|
@ -132,8 +132,8 @@
|
||||||
;; --- Update Collection
|
;; --- Update Collection
|
||||||
|
|
||||||
(defrecord UpdateCollection [id]
|
(defrecord UpdateCollection [id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [item (get-in state [:images-collections id])]
|
(let [item (get-in state [:images-collections id])]
|
||||||
(->> (rp/req :update/image-collection item)
|
(->> (rp/req :update/image-collection item)
|
||||||
(rx/map :payload)
|
(rx/map :payload)
|
||||||
|
@ -146,12 +146,12 @@
|
||||||
;; --- Rename Collection
|
;; --- Rename Collection
|
||||||
|
|
||||||
(defrecord RenameCollection [id name]
|
(defrecord RenameCollection [id name]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:images-collections id :name] name))
|
(assoc-in state [:images-collections id :name] name))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(rx/of (update-collection id))))
|
(rx/of (update-collection id))))
|
||||||
|
|
||||||
(defn rename-collection
|
(defn rename-collection
|
||||||
|
@ -161,12 +161,12 @@
|
||||||
;; --- Delete Collection
|
;; --- Delete Collection
|
||||||
|
|
||||||
(defrecord DeleteCollection [id]
|
(defrecord DeleteCollection [id]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update state :images-collections dissoc id))
|
(update state :images-collections dissoc id))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [type (get-in state [:dashboard :images :type])]
|
(let [type (get-in state [:dashboard :images :type])]
|
||||||
(->> (rp/req :delete/image-collection id)
|
(->> (rp/req :delete/image-collection id)
|
||||||
(rx/map #(select-collection type))))))
|
(rx/map #(select-collection type))))))
|
||||||
|
@ -178,8 +178,8 @@
|
||||||
;; --- Image Created
|
;; --- Image Created
|
||||||
|
|
||||||
(defrecord ImageCreated [item]
|
(defrecord ImageCreated [item]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update state :images assoc (:id item) item)))
|
(update state :images assoc (:id item) item)))
|
||||||
|
|
||||||
(defn image-created
|
(defn image-created
|
||||||
|
@ -191,12 +191,12 @@
|
||||||
(def allowed-file-types #{"image/jpeg" "image/png"})
|
(def allowed-file-types #{"image/jpeg" "image/png"})
|
||||||
|
|
||||||
(defrecord CreateImages [id files on-uploaded]
|
(defrecord CreateImages [id files on-uploaded]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:dashboard :images :uploading] true))
|
(assoc-in state [:dashboard :images :uploading] true))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(letfn [(image-size [file]
|
(letfn [(image-size [file]
|
||||||
(->> (files/get-image-size file)
|
(->> (files/get-image-size file)
|
||||||
(rx/map (partial vector file))))
|
(rx/map (partial vector file))))
|
||||||
|
@ -218,7 +218,7 @@
|
||||||
(rx/mapcat #(rp/req :create/image %))
|
(rx/mapcat #(rp/req :create/image %))
|
||||||
(rx/map :payload)
|
(rx/map :payload)
|
||||||
(rx/reduce conj [])
|
(rx/reduce conj [])
|
||||||
(rx/do #(rs/emit! finalize-upload))
|
(rx/do #(st/emit! finalize-upload))
|
||||||
(rx/do on-uploaded)
|
(rx/do on-uploaded)
|
||||||
(rx/mapcat identity)
|
(rx/mapcat identity)
|
||||||
(rx/map image-created)))))
|
(rx/map image-created)))))
|
||||||
|
@ -234,8 +234,8 @@
|
||||||
;; --- Image Updated
|
;; --- Image Updated
|
||||||
|
|
||||||
(defrecord ImagePersisted [id data]
|
(defrecord ImagePersisted [id data]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:images id] data)))
|
(assoc-in state [:images id] data)))
|
||||||
|
|
||||||
(defn image-persisted
|
(defn image-persisted
|
||||||
|
@ -246,8 +246,8 @@
|
||||||
;; --- Update Image
|
;; --- Update Image
|
||||||
|
|
||||||
(defrecord PersistImage [id]
|
(defrecord PersistImage [id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [image (get-in state [:images id])]
|
(let [image (get-in state [:images id])]
|
||||||
(->> (rp/req :update/image image)
|
(->> (rp/req :update/image image)
|
||||||
(rx/map :payload)
|
(rx/map :payload)
|
||||||
|
@ -261,8 +261,8 @@
|
||||||
;; --- Images Fetched
|
;; --- Images Fetched
|
||||||
|
|
||||||
(defrecord ImagesFetched [items]
|
(defrecord ImagesFetched [items]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(reduce (fn [state {:keys [id] :as image}]
|
(reduce (fn [state {:keys [id] :as image}]
|
||||||
(assoc-in state [:images id] image))
|
(assoc-in state [:images id] image))
|
||||||
state
|
state
|
||||||
|
@ -275,8 +275,8 @@
|
||||||
;; --- Fetch Images
|
;; --- Fetch Images
|
||||||
|
|
||||||
(defrecord FetchImages [id]
|
(defrecord FetchImages [id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [params {:coll id}]
|
(let [params {:coll id}]
|
||||||
(->> (rp/req :fetch/images params)
|
(->> (rp/req :fetch/images params)
|
||||||
(rx/map :payload)
|
(rx/map :payload)
|
||||||
|
@ -293,8 +293,8 @@
|
||||||
(declare image-fetched)
|
(declare image-fetched)
|
||||||
|
|
||||||
(defrecord FetchImage [id]
|
(defrecord FetchImage [id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [existing (get-in state [:images id])]
|
(let [existing (get-in state [:images id])]
|
||||||
(if existing
|
(if existing
|
||||||
(rx/empty)
|
(rx/empty)
|
||||||
|
@ -312,8 +312,8 @@
|
||||||
;; --- Image Fetched
|
;; --- Image Fetched
|
||||||
|
|
||||||
(defrecord ImageFetched [image]
|
(defrecord ImageFetched [image]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [id (:id image)]
|
(let [id (:id image)]
|
||||||
(update state :images assoc id image))))
|
(update state :images assoc id image))))
|
||||||
|
|
||||||
|
@ -325,14 +325,14 @@
|
||||||
;; --- Delete Images
|
;; --- Delete Images
|
||||||
|
|
||||||
(defrecord DeleteImage [id]
|
(defrecord DeleteImage [id]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(-> state
|
(-> state
|
||||||
(update :images dissoc id)
|
(update :images dissoc id)
|
||||||
(update-in [:dashboard :images :selected] disj id)))
|
(update-in [:dashboard :images :selected] disj id)))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(->> (rp/req :delete/image id)
|
(->> (rp/req :delete/image id)
|
||||||
(rx/ignore))))
|
(rx/ignore))))
|
||||||
|
|
||||||
|
@ -344,12 +344,12 @@
|
||||||
;; --- Rename Image
|
;; --- Rename Image
|
||||||
|
|
||||||
(defrecord RenameImage [id name]
|
(defrecord RenameImage [id name]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:images id :name] name))
|
(assoc-in state [:images id :name] name))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(rx/of (persist-image id))))
|
(rx/of (persist-image id))))
|
||||||
|
|
||||||
(defn rename-image
|
(defn rename-image
|
||||||
|
@ -360,18 +360,18 @@
|
||||||
;; --- Select image
|
;; --- Select image
|
||||||
|
|
||||||
(defrecord SelectImage [id]
|
(defrecord SelectImage [id]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:dashboard :images :selected] conj id)))
|
(update-in state [:dashboard :images :selected] conj id)))
|
||||||
|
|
||||||
(defrecord DeselectImage [id]
|
(defrecord DeselectImage [id]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:dashboard :images :selected] disj id)))
|
(update-in state [:dashboard :images :selected] disj id)))
|
||||||
|
|
||||||
(defrecord ToggleImageSelection [id]
|
(defrecord ToggleImageSelection [id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [selected (get-in state [:dashboard :images :selected])]
|
(let [selected (get-in state [:dashboard :images :selected])]
|
||||||
(rx/of
|
(rx/of
|
||||||
(if (selected id)
|
(if (selected id)
|
||||||
|
@ -390,8 +390,8 @@
|
||||||
;; --- Copy Selected Image
|
;; --- Copy Selected Image
|
||||||
|
|
||||||
(defrecord CopySelected [id]
|
(defrecord CopySelected [id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [selected (get-in state [:dashboard :images :selected])]
|
(let [selected (get-in state [:dashboard :images :selected])]
|
||||||
(rx/merge
|
(rx/merge
|
||||||
(->> (rx/from-coll selected)
|
(->> (rx/from-coll selected)
|
||||||
|
@ -409,16 +409,16 @@
|
||||||
;; --- Move Selected Image
|
;; --- Move Selected Image
|
||||||
|
|
||||||
(defrecord MoveSelected [id]
|
(defrecord MoveSelected [id]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [selected (get-in state [:dashboard :images :selected])]
|
(let [selected (get-in state [:dashboard :images :selected])]
|
||||||
(reduce (fn [state image]
|
(reduce (fn [state image]
|
||||||
(assoc-in state [:images image :collection] id))
|
(assoc-in state [:images image :collection] id))
|
||||||
state
|
state
|
||||||
selected)))
|
selected)))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [selected (get-in state [:dashboard :images :selected])]
|
(let [selected (get-in state [:dashboard :images :selected])]
|
||||||
(rx/merge
|
(rx/merge
|
||||||
(->> (rx/from-coll selected)
|
(->> (rx/from-coll selected)
|
||||||
|
@ -434,8 +434,8 @@
|
||||||
;; --- Delete Selected
|
;; --- Delete Selected
|
||||||
|
|
||||||
(defrecord DeleteSelected []
|
(defrecord DeleteSelected []
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [selected (get-in state [:dashboard :images :selected])]
|
(let [selected (get-in state [:dashboard :images :selected])]
|
||||||
(->> (rx/from-coll selected)
|
(->> (rx/from-coll selected)
|
||||||
(rx/map delete-image)))))
|
(rx/map delete-image)))))
|
||||||
|
@ -447,8 +447,8 @@
|
||||||
;; --- Update Opts (Filtering & Ordering)
|
;; --- Update Opts (Filtering & Ordering)
|
||||||
|
|
||||||
(defrecord UpdateOpts [order filter edition]
|
(defrecord UpdateOpts [order filter edition]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:dashboard :images] merge
|
(update-in state [:dashboard :images] merge
|
||||||
{:edition edition}
|
{:edition edition}
|
||||||
(when order {:order order})
|
(when order {:order order})
|
||||||
|
|
|
@ -7,13 +7,14 @@
|
||||||
(ns uxbox.main.data.lightbox
|
(ns uxbox.main.data.lightbox
|
||||||
(:require [beicon.core :as rx]
|
(:require [beicon.core :as rx]
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.rstore :as rs]))
|
[potok.core :as ptk]
|
||||||
|
[uxbox.store :as st]))
|
||||||
|
|
||||||
;; --- Show Lightbox
|
;; --- Show Lightbox
|
||||||
|
|
||||||
(defrecord ShowLightbox [name params]
|
(defrecord ShowLightbox [name params]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [data (merge {:name name} params)]
|
(let [data (merge {:name name} params)]
|
||||||
(assoc state :lightbox data))))
|
(assoc state :lightbox data))))
|
||||||
|
|
||||||
|
@ -26,8 +27,8 @@
|
||||||
;; --- Hide Lightbox
|
;; --- Hide Lightbox
|
||||||
|
|
||||||
(defrecord HideLightbox []
|
(defrecord HideLightbox []
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(dissoc state :lightbox)))
|
(dissoc state :lightbox)))
|
||||||
|
|
||||||
(defn hide-lightbox
|
(defn hide-lightbox
|
||||||
|
@ -38,8 +39,8 @@
|
||||||
|
|
||||||
(defn open!
|
(defn open!
|
||||||
[& args]
|
[& args]
|
||||||
(rs/emit! (apply show-lightbox args)))
|
(st/emit! (apply show-lightbox args)))
|
||||||
|
|
||||||
(defn close!
|
(defn close!
|
||||||
[& args]
|
[& args]
|
||||||
(rs/emit! (apply hide-lightbox args)))
|
(st/emit! (apply hide-lightbox args)))
|
||||||
|
|
|
@ -8,8 +8,9 @@
|
||||||
(:require [cuerdas.core :as str]
|
(:require [cuerdas.core :as str]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.timers :as ts]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.rstore :as rs]))
|
[uxbox.store :as st]
|
||||||
|
[uxbox.util.timers :as ts]))
|
||||||
|
|
||||||
;; --- Constants
|
;; --- Constants
|
||||||
|
|
||||||
|
@ -21,13 +22,13 @@
|
||||||
(declare show-message?)
|
(declare show-message?)
|
||||||
|
|
||||||
(defrecord ShowMessage [data]
|
(defrecord ShowMessage [data]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [message (assoc data :state :visible)]
|
(let [message (assoc data :state :visible)]
|
||||||
(assoc state :message message)))
|
(assoc state :message message)))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [stoper (->> (rx/filter show-message? s)
|
(let [stoper (->> (rx/filter show-message? s)
|
||||||
(rx/take 1))]
|
(rx/take 1))]
|
||||||
(->> (rx/of (hide-message))
|
(->> (rx/of (hide-message))
|
||||||
|
@ -65,16 +66,16 @@
|
||||||
;; --- Hide Message
|
;; --- Hide Message
|
||||||
|
|
||||||
(defrecord HideMessage [^:mutable canceled?]
|
(defrecord HideMessage [^:mutable canceled?]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update state :message
|
(update state :message
|
||||||
(fn [v]
|
(fn [v]
|
||||||
(if (nil? v)
|
(if (nil? v)
|
||||||
(do (set! canceled? true) nil)
|
(do (set! canceled? true) nil)
|
||||||
(assoc v :state :hide)))))
|
(assoc v :state :hide)))))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(if canceled?
|
(if canceled?
|
||||||
(rx/empty)
|
(rx/empty)
|
||||||
(->> (rx/of #(dissoc state :message))
|
(->> (rx/of #(dissoc state :message))
|
||||||
|
@ -88,19 +89,19 @@
|
||||||
|
|
||||||
(defn error!
|
(defn error!
|
||||||
[& args]
|
[& args]
|
||||||
(ts/schedule 0 #(rs/emit! (apply show-error args))))
|
(ts/schedule 0 #(st/emit! (apply show-error args))))
|
||||||
|
|
||||||
(defn info!
|
(defn info!
|
||||||
[& args]
|
[& args]
|
||||||
(ts/schedule 0 #(rs/emit! (apply show-info args))))
|
(ts/schedule 0 #(st/emit! (apply show-info args))))
|
||||||
|
|
||||||
(defn dialog!
|
(defn dialog!
|
||||||
[& args]
|
[& args]
|
||||||
(ts/schedule 0 #(rs/emit! (apply show-dialog args))))
|
(ts/schedule 0 #(st/emit! (apply show-dialog args))))
|
||||||
|
|
||||||
(defn close!
|
(defn close!
|
||||||
[]
|
[]
|
||||||
(rs/emit! (hide-message)))
|
(st/emit! (hide-message)))
|
||||||
|
|
||||||
(defn error
|
(defn error
|
||||||
[& args]
|
[& args]
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.main.repo :as rp]
|
[uxbox.main.repo :as rp]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.util.spec :as us]
|
[uxbox.util.spec :as us]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.forms :as sc]
|
[uxbox.util.forms :as sc]
|
||||||
|
@ -99,8 +99,8 @@
|
||||||
;; --- Pages Fetched
|
;; --- Pages Fetched
|
||||||
|
|
||||||
(defrecord PagesFetched [pages]
|
(defrecord PagesFetched [pages]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(as-> state $
|
(as-> state $
|
||||||
(reduce assoc-page $ pages)
|
(reduce assoc-page $ pages)
|
||||||
(reduce assoc-packed-page $ pages))))
|
(reduce assoc-packed-page $ pages))))
|
||||||
|
@ -112,8 +112,8 @@
|
||||||
;; --- Fetch Pages (by project id)
|
;; --- Fetch Pages (by project id)
|
||||||
|
|
||||||
(defrecord FetchPages [projectid]
|
(defrecord FetchPages [projectid]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(->> (rp/req :fetch/pages-by-project {:project projectid})
|
(->> (rp/req :fetch/pages-by-project {:project projectid})
|
||||||
(rx/map (comp ->PagesFetched :payload)))))
|
(rx/map (comp ->PagesFetched :payload)))))
|
||||||
|
|
||||||
|
@ -124,8 +124,8 @@
|
||||||
;; --- Page Created
|
;; --- Page Created
|
||||||
|
|
||||||
(defrecord PageCreated [data]
|
(defrecord PageCreated [data]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(-> state
|
(-> state
|
||||||
(assoc-page data)
|
(assoc-page data)
|
||||||
(assoc-packed-page data))))
|
(assoc-packed-page data))))
|
||||||
|
@ -141,8 +141,8 @@
|
||||||
;; --- Create Page
|
;; --- Create Page
|
||||||
|
|
||||||
(defrecord CreatePage [name project width height layout]
|
(defrecord CreatePage [name project width height layout]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [this state s]
|
(watch [this state s]
|
||||||
(let [params {:name name
|
(let [params {:name name
|
||||||
:project project
|
:project project
|
||||||
:data {}
|
:data {}
|
||||||
|
@ -164,8 +164,8 @@
|
||||||
;; --- Page Persisted
|
;; --- Page Persisted
|
||||||
|
|
||||||
(defrecord PagePersisted [data]
|
(defrecord PagePersisted [data]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-page state data)))
|
(assoc-page state data)))
|
||||||
|
|
||||||
(defn- page-persisted?
|
(defn- page-persisted?
|
||||||
|
@ -182,8 +182,8 @@
|
||||||
;; --- Persist Page
|
;; --- Persist Page
|
||||||
|
|
||||||
(defrecord PersistPage [id]
|
(defrecord PersistPage [id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [this state s]
|
(watch [this state s]
|
||||||
(let [page (get-in state [:pages id])]
|
(let [page (get-in state [:pages id])]
|
||||||
(if (:history page)
|
(if (:history page)
|
||||||
(rx/empty)
|
(rx/empty)
|
||||||
|
@ -210,16 +210,16 @@
|
||||||
events with 1sec of delay allowing batch updates
|
events with 1sec of delay allowing batch updates
|
||||||
on fastly performed events."
|
on fastly performed events."
|
||||||
[id]
|
[id]
|
||||||
(as-> rs/stream $
|
(as-> st/store $
|
||||||
(rx/filter #(satisfies? IPageUpdate %) $)
|
(rx/filter #(satisfies? IPageUpdate %) $)
|
||||||
(rx/debounce 1000 $)
|
(rx/debounce 1000 $)
|
||||||
(rx/on-next $ #(rs/emit! (persist-page id)))))
|
(rx/on-next $ #(st/emit! (persist-page id)))))
|
||||||
|
|
||||||
;; --- Page Metadata Persisted
|
;; --- Page Metadata Persisted
|
||||||
|
|
||||||
(defrecord MetadataPersisted [id data]
|
(defrecord MetadataPersisted [id data]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
;; TODO: page-data update
|
;; TODO: page-data update
|
||||||
(assoc-in state [:pages id :version] (:version data))))
|
(assoc-in state [:pages id :version] (:version data))))
|
||||||
|
|
||||||
|
@ -238,8 +238,8 @@
|
||||||
;; and only serves for update other page data.
|
;; and only serves for update other page data.
|
||||||
|
|
||||||
(defrecord PersistMetadata [id]
|
(defrecord PersistMetadata [id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [page (get-in state [:pages id])]
|
(let [page (get-in state [:pages id])]
|
||||||
(->> (rp/req :update/page-metadata page)
|
(->> (rp/req :update/page-metadata page)
|
||||||
(rx/map :payload)
|
(rx/map :payload)
|
||||||
|
@ -253,12 +253,12 @@
|
||||||
;; --- Update Page Options
|
;; --- Update Page Options
|
||||||
|
|
||||||
(defrecord UpdateMetadata [id metadata]
|
(defrecord UpdateMetadata [id metadata]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:pages id :metadata] metadata))
|
(assoc-in state [:pages id :metadata] metadata))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [this state s]
|
(watch [this state s]
|
||||||
(rx/of (persist-metadata id))))
|
(rx/of (persist-metadata id))))
|
||||||
|
|
||||||
(defn update-metadata
|
(defn update-metadata
|
||||||
|
@ -269,8 +269,8 @@
|
||||||
;; --- Update Page
|
;; --- Update Page
|
||||||
|
|
||||||
(defrecord UpdatePage [id name width height layout]
|
(defrecord UpdatePage [id name width height layout]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [this state]
|
(update [this state]
|
||||||
(println "update-page" this)
|
(println "update-page" this)
|
||||||
(-> state
|
(-> state
|
||||||
(assoc-in [:pages id :name] name)
|
(assoc-in [:pages id :name] name)
|
||||||
|
@ -278,8 +278,8 @@
|
||||||
(assoc-in [:pages id :metadata :height] height)
|
(assoc-in [:pages id :metadata :height] height)
|
||||||
(assoc-in [:pages id :metadata :layout] layout)))
|
(assoc-in [:pages id :metadata :layout] layout)))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(rx/of (persist-metadata id))))
|
(rx/of (persist-metadata id))))
|
||||||
|
|
||||||
(s/def ::update-page-event
|
(s/def ::update-page-event
|
||||||
|
@ -293,8 +293,8 @@
|
||||||
;; --- Delete Page (by id)
|
;; --- Delete Page (by id)
|
||||||
|
|
||||||
(defrecord DeletePage [id callback]
|
(defrecord DeletePage [id callback]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(letfn [(on-success [_]
|
(letfn [(on-success [_]
|
||||||
#(purge-page % id))]
|
#(purge-page % id))]
|
||||||
(->> (rp/req :delete/page id)
|
(->> (rp/req :delete/page id)
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
(ns uxbox.main.data.projects
|
(ns uxbox.main.data.projects
|
||||||
(:require [cuerdas.core :as str]
|
(:require [cuerdas.core :as str]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.repo :as rp]
|
[uxbox.main.repo :as rp]
|
||||||
[uxbox.main.data.pages :as udp]
|
[uxbox.main.data.pages :as udp]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.router :as rt]
|
[uxbox.util.router :as rt]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.forms :as sc]
|
[uxbox.util.forms :as sc]
|
||||||
|
@ -54,12 +54,12 @@
|
||||||
(declare projects-fetched?)
|
(declare projects-fetched?)
|
||||||
|
|
||||||
(defrecord Initialize []
|
(defrecord Initialize []
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:dashboard :section] :dashboard/projects))
|
(assoc-in state [:dashboard :section] :dashboard/projects))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(rx/of (fetch-projects))))
|
(rx/of (fetch-projects))))
|
||||||
|
|
||||||
(defn initialize
|
(defn initialize
|
||||||
|
@ -69,8 +69,8 @@
|
||||||
;; --- Projects Fetched
|
;; --- Projects Fetched
|
||||||
|
|
||||||
(defrecord ProjectsFetched [projects]
|
(defrecord ProjectsFetched [projects]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(as-> state $
|
(as-> state $
|
||||||
(reduce assoc-project-page $ projects)
|
(reduce assoc-project-page $ projects)
|
||||||
(reduce assoc-project $ projects))))
|
(reduce assoc-project $ projects))))
|
||||||
|
@ -86,8 +86,8 @@
|
||||||
;; --- Fetch Projects
|
;; --- Fetch Projects
|
||||||
|
|
||||||
(defrecord FetchProjects []
|
(defrecord FetchProjects []
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(->> (rp/req :fetch/projects)
|
(->> (rp/req :fetch/projects)
|
||||||
(rx/map :payload)
|
(rx/map :payload)
|
||||||
(rx/map projects-fetched))))
|
(rx/map projects-fetched))))
|
||||||
|
@ -99,8 +99,8 @@
|
||||||
;; --- Project Persisted
|
;; --- Project Persisted
|
||||||
|
|
||||||
(defrecord ProjectPersisted [data]
|
(defrecord ProjectPersisted [data]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-project state data)))
|
(assoc-project state data)))
|
||||||
|
|
||||||
(defn project-persisted
|
(defn project-persisted
|
||||||
|
@ -111,8 +111,8 @@
|
||||||
;; --- Persist Project
|
;; --- Persist Project
|
||||||
|
|
||||||
(defrecord PersistProject [id]
|
(defrecord PersistProject [id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [project (get-in state [:projects id])]
|
(let [project (get-in state [:projects id])]
|
||||||
(->> (rp/req :update/project project)
|
(->> (rp/req :update/project project)
|
||||||
(rx/map :payload)
|
(rx/map :payload)
|
||||||
|
@ -126,12 +126,12 @@
|
||||||
;; --- Rename Project
|
;; --- Rename Project
|
||||||
|
|
||||||
(defrecord RenameProject [id name]
|
(defrecord RenameProject [id name]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:projects id :name] name))
|
(assoc-in state [:projects id :name] name))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(rx/of (persist-project id))))
|
(rx/of (persist-project id))))
|
||||||
|
|
||||||
(defn rename-project
|
(defn rename-project
|
||||||
|
@ -142,8 +142,8 @@
|
||||||
;; --- Delete Project (by id)
|
;; --- Delete Project (by id)
|
||||||
|
|
||||||
(defrecord DeleteProject [id]
|
(defrecord DeleteProject [id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(letfn [(on-success [_]
|
(letfn [(on-success [_]
|
||||||
#(dissoc-project % id))]
|
#(dissoc-project % id))]
|
||||||
(->> (rp/req :delete/project id)
|
(->> (rp/req :delete/project id)
|
||||||
|
@ -158,8 +158,8 @@
|
||||||
;; --- Create Project
|
;; --- Create Project
|
||||||
|
|
||||||
(defrecord CreateProject [name width height layout]
|
(defrecord CreateProject [name width height layout]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [this state s]
|
(watch [this state s]
|
||||||
(letfn [(on-success [{project :payload}]
|
(letfn [(on-success [{project :payload}]
|
||||||
(rx/of
|
(rx/of
|
||||||
(project-persisted project)
|
(project-persisted project)
|
||||||
|
@ -185,8 +185,8 @@
|
||||||
;; --- Go To & Go To Page
|
;; --- Go To & Go To Page
|
||||||
|
|
||||||
(defrecord GoTo [project-id]
|
(defrecord GoTo [project-id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [page-id (get-in state [:projects project-id :page-id])
|
(let [page-id (get-in state [:projects project-id :page-id])
|
||||||
params {:project project-id
|
params {:project project-id
|
||||||
:page page-id}]
|
:page page-id}]
|
||||||
|
@ -194,8 +194,8 @@
|
||||||
(rt/navigate :workspace/page params)))))
|
(rt/navigate :workspace/page params)))))
|
||||||
|
|
||||||
(defrecord GoToPage [project-id page-id]
|
(defrecord GoToPage [project-id page-id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [params {:project project-id
|
(let [params {:project project-id
|
||||||
:page page-id}]
|
:page page-id}]
|
||||||
(rx/of (rt/navigate :workspace/page params)))))
|
(rx/of (rt/navigate :workspace/page params)))))
|
||||||
|
@ -214,8 +214,8 @@
|
||||||
;; --- Update Opts (Filtering & Ordering)
|
;; --- Update Opts (Filtering & Ordering)
|
||||||
|
|
||||||
(defrecord UpdateOpts [order filter]
|
(defrecord UpdateOpts [order filter]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:dashboard :projects] merge
|
(update-in state [:dashboard :projects] merge
|
||||||
(when order {:order order})
|
(when order {:order order})
|
||||||
(when filter {:filter filter}))))
|
(when filter {:filter filter}))))
|
||||||
|
|
|
@ -8,13 +8,13 @@
|
||||||
(ns uxbox.main.data.shapes
|
(ns uxbox.main.data.shapes
|
||||||
(:require [beicon.core :as rx]
|
(:require [beicon.core :as rx]
|
||||||
[uxbox.util.uuid :as uuid]
|
[uxbox.util.uuid :as uuid]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.forms :as sc]
|
[uxbox.util.forms :as sc]
|
||||||
[uxbox.util.workers :as uw]
|
[uxbox.util.workers :as uw]
|
||||||
[uxbox.main.constants :as c]
|
[uxbox.main.constants :as c]
|
||||||
[uxbox.main.geom :as geom]
|
[uxbox.main.geom :as geom]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.core :refer (worker)]
|
[uxbox.main.data.core :refer (worker)]
|
||||||
[uxbox.main.data.shapes-impl :as impl]
|
[uxbox.main.data.shapes-impl :as impl]
|
||||||
[uxbox.main.data.pages :as udp]
|
[uxbox.main.data.pages :as udp]
|
||||||
|
@ -28,8 +28,8 @@
|
||||||
[shape]
|
[shape]
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [page (get-in state [:workspace :page])
|
(let [page (get-in state [:workspace :page])
|
||||||
shape (geom/setup-proportions shape)]
|
shape (geom/setup-proportions shape)]
|
||||||
(impl/assoc-shape-to-page state shape page)))))
|
(impl/assoc-shape-to-page state shape page)))))
|
||||||
|
@ -39,8 +39,8 @@
|
||||||
[id]
|
[id]
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [shape (get-in state [:shapes id])]
|
(let [shape (get-in state [:shapes id])]
|
||||||
(impl/dissoc-shape state shape)))))
|
(impl/dissoc-shape state shape)))))
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@
|
||||||
[{:keys [id] :as shape}]
|
[{:keys [id] :as shape}]
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:shapes id] merge shape))))
|
(update-in state [:shapes id] merge shape))))
|
||||||
|
|
||||||
;; --- Shape Transformations
|
;; --- Shape Transformations
|
||||||
|
@ -60,8 +60,8 @@
|
||||||
[sid delta]
|
[sid delta]
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [shape (get-in state [:shapes sid])]
|
(let [shape (get-in state [:shapes sid])]
|
||||||
(update-in state [:shapes sid] geom/move delta)))))
|
(update-in state [:shapes sid] geom/move delta)))))
|
||||||
|
|
||||||
|
@ -74,8 +74,8 @@
|
||||||
(defn initial-align-shape
|
(defn initial-align-shape
|
||||||
[id]
|
[id]
|
||||||
(reify
|
(reify
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [shape (get-in state [:shapes id])
|
(let [shape (get-in state [:shapes id])
|
||||||
shape (geom/outer-rect state shape)
|
shape (geom/outer-rect state shape)
|
||||||
point (gpt/point (:x shape) (:y shape))
|
point (gpt/point (:x shape) (:y shape))
|
||||||
|
@ -88,8 +88,8 @@
|
||||||
[sid {:keys [x1 y1 x2 y2] :as opts}]
|
[sid {:keys [x1 y1 x2 y2] :as opts}]
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [shape (get-in state [:shapes sid])
|
(let [shape (get-in state [:shapes sid])
|
||||||
props (select-keys opts [:x1 :y1 :x2 :y2])
|
props (select-keys opts [:x1 :y1 :x2 :y2])
|
||||||
props' (select-keys shape [:x1 :y1 :x2 :y2])]
|
props' (select-keys shape [:x1 :y1 :x2 :y2])]
|
||||||
|
@ -103,8 +103,8 @@
|
||||||
(>= 360 rotation)]}
|
(>= 360 rotation)]}
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:shapes sid]
|
(update-in state [:shapes sid]
|
||||||
geom/rotate rotation))))
|
geom/rotate rotation))))
|
||||||
|
|
||||||
|
@ -116,23 +116,23 @@
|
||||||
{:pre [(uuid? sid)]}
|
{:pre [(uuid? sid)]}
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:shapes sid] geom/resize-dim opts))))
|
(update-in state [:shapes sid] geom/resize-dim opts))))
|
||||||
|
|
||||||
(defn update-vertex-position
|
(defn update-vertex-position
|
||||||
[id {:keys [vid delta]}]
|
[id {:keys [vid delta]}]
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:shapes id] geom/move-vertex vid delta))))
|
(update-in state [:shapes id] geom/move-vertex vid delta))))
|
||||||
|
|
||||||
(defn initial-vertext-align
|
(defn initial-vertext-align
|
||||||
[id vid]
|
[id vid]
|
||||||
(reify
|
(reify
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [shape (get-in state [:shapes id])
|
(let [shape (get-in state [:shapes id])
|
||||||
point (geom/get-vertex-point shape vid)
|
point (geom/get-vertex-point shape vid)
|
||||||
point (gpt/add point canvas-coords)]
|
point (gpt/add point canvas-coords)]
|
||||||
|
@ -144,8 +144,8 @@
|
||||||
"Update the start position coordenate of the shape."
|
"Update the start position coordenate of the shape."
|
||||||
[sid {:keys [x y] :as opts}]
|
[sid {:keys [x y] :as opts}]
|
||||||
(reify
|
(reify
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:shapes sid] geom/absolute-move opts))))
|
(update-in state [:shapes sid] geom/absolute-move opts))))
|
||||||
|
|
||||||
(defn update-text
|
(defn update-text
|
||||||
|
@ -153,16 +153,16 @@
|
||||||
{:pre [(string? content)]}
|
{:pre [(string? content)]}
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:shapes sid :content] content))))
|
(assoc-in state [:shapes sid :content] content))))
|
||||||
|
|
||||||
(defn update-fill-attrs
|
(defn update-fill-attrs
|
||||||
[sid {:keys [color opacity] :as opts}]
|
[sid {:keys [color opacity] :as opts}]
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:shapes sid]
|
(update-in state [:shapes sid]
|
||||||
merge
|
merge
|
||||||
(when color {:fill color})
|
(when color {:fill color})
|
||||||
|
@ -173,8 +173,8 @@
|
||||||
letter-spacing line-height] :as opts}]
|
letter-spacing line-height] :as opts}]
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:shapes sid :font]
|
(update-in state [:shapes sid :font]
|
||||||
merge
|
merge
|
||||||
(when line-height {:line-height line-height})
|
(when line-height {:line-height line-height})
|
||||||
|
@ -189,8 +189,8 @@
|
||||||
[sid {:keys [color opacity type width] :as opts}]
|
[sid {:keys [color opacity type width] :as opts}]
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:shapes sid]
|
(update-in state [:shapes sid]
|
||||||
merge
|
merge
|
||||||
(when type {:stroke-type type})
|
(when type {:stroke-type type})
|
||||||
|
@ -202,8 +202,8 @@
|
||||||
[sid {:keys [rx ry] :as opts}]
|
[sid {:keys [rx ry] :as opts}]
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:shapes sid]
|
(update-in state [:shapes sid]
|
||||||
merge
|
merge
|
||||||
(when rx {:rx rx})
|
(when rx {:rx rx})
|
||||||
|
@ -219,8 +219,8 @@
|
||||||
{:pre [(uuid? sid)]}
|
{:pre [(uuid? sid)]}
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [[width height] (-> (get-in state [:shapes sid])
|
(let [[width height] (-> (get-in state [:shapes sid])
|
||||||
(geom/size)
|
(geom/size)
|
||||||
(keep [:width :height]))
|
(keep [:width :height]))
|
||||||
|
@ -234,8 +234,8 @@
|
||||||
{:pre [(uuid? sid)]}
|
{:pre [(uuid? sid)]}
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:shapes sid] assoc
|
(update-in state [:shapes sid] assoc
|
||||||
:proportion-lock false))))
|
:proportion-lock false))))
|
||||||
|
|
||||||
|
@ -246,8 +246,8 @@
|
||||||
{:pre [(uuid? id)]}
|
{:pre [(uuid? id)]}
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:shapes id] assoc :collapsed true))))
|
(update-in state [:shapes id] assoc :collapsed true))))
|
||||||
|
|
||||||
(defn uncollapse-shape
|
(defn uncollapse-shape
|
||||||
|
@ -255,8 +255,8 @@
|
||||||
{:pre [(uuid? id)]}
|
{:pre [(uuid? id)]}
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:shapes id] assoc :collapsed false))))
|
(update-in state [:shapes id] assoc :collapsed false))))
|
||||||
|
|
||||||
;; --- Shape Visibility
|
;; --- Shape Visibility
|
||||||
|
@ -265,12 +265,12 @@
|
||||||
[sid]
|
[sid]
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:shapes sid :hidden] true))
|
(assoc-in state [:shapes sid :hidden] true))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [shape (get-in state [:shapes sid])]
|
(let [shape (get-in state [:shapes sid])]
|
||||||
(if-not (= (:type shape) :group)
|
(if-not (= (:type shape) :group)
|
||||||
(rx/empty)
|
(rx/empty)
|
||||||
|
@ -281,12 +281,12 @@
|
||||||
[sid]
|
[sid]
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:shapes sid :hidden] false))
|
(assoc-in state [:shapes sid :hidden] false))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [shape (get-in state [:shapes sid])]
|
(let [shape (get-in state [:shapes sid])]
|
||||||
(if-not (= (:type shape) :group)
|
(if-not (= (:type shape) :group)
|
||||||
(rx/empty)
|
(rx/empty)
|
||||||
|
@ -297,12 +297,12 @@
|
||||||
[sid]
|
[sid]
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:shapes sid :blocked] true))
|
(assoc-in state [:shapes sid :blocked] true))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [shape (get-in state [:shapes sid])]
|
(let [shape (get-in state [:shapes sid])]
|
||||||
(if-not (= (:type shape) :group)
|
(if-not (= (:type shape) :group)
|
||||||
(rx/empty)
|
(rx/empty)
|
||||||
|
@ -313,12 +313,12 @@
|
||||||
[sid]
|
[sid]
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:shapes sid :blocked] false))
|
(assoc-in state [:shapes sid :blocked] false))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [shape (get-in state [:shapes sid])]
|
(let [shape (get-in state [:shapes sid])]
|
||||||
(if-not (= (:type shape) :group)
|
(if-not (= (:type shape) :group)
|
||||||
(rx/empty)
|
(rx/empty)
|
||||||
|
@ -329,12 +329,12 @@
|
||||||
[sid]
|
[sid]
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:shapes sid :locked] true))
|
(assoc-in state [:shapes sid :locked] true))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [shape (get-in state [:shapes sid])]
|
(let [shape (get-in state [:shapes sid])]
|
||||||
(if-not (= (:type shape) :group)
|
(if-not (= (:type shape) :group)
|
||||||
(rx/empty)
|
(rx/empty)
|
||||||
|
@ -345,12 +345,12 @@
|
||||||
[sid]
|
[sid]
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:shapes sid :locked] false))
|
(assoc-in state [:shapes sid :locked] false))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [shape (get-in state [:shapes sid])]
|
(let [shape (get-in state [:shapes sid])]
|
||||||
(if-not (= (:type shape) :group)
|
(if-not (= (:type shape) :group)
|
||||||
(rx/empty)
|
(rx/empty)
|
||||||
|
@ -365,16 +365,16 @@
|
||||||
(not (nil? sid))]}
|
(not (nil? sid))]}
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(impl/drop-shape state sid tid loc))))
|
(impl/drop-shape state sid tid loc))))
|
||||||
|
|
||||||
(defn select-first-shape
|
(defn select-first-shape
|
||||||
"Mark a shape selected for drawing in the canvas."
|
"Mark a shape selected for drawing in the canvas."
|
||||||
[]
|
[]
|
||||||
(reify
|
(reify
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [page (get-in state [:workspace :page])
|
(let [page (get-in state [:workspace :page])
|
||||||
id (first (get-in state [:pages page :shapes]))]
|
id (first (get-in state [:pages page :shapes]))]
|
||||||
(assoc-in state [:workspace :selected] #{id})))))
|
(assoc-in state [:workspace :selected] #{id})))))
|
||||||
|
@ -383,8 +383,8 @@
|
||||||
"Mark a shape selected for drawing in the canvas."
|
"Mark a shape selected for drawing in the canvas."
|
||||||
[id]
|
[id]
|
||||||
(reify
|
(reify
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [selected (get-in state [:workspace :selected])
|
(let [selected (get-in state [:workspace :selected])
|
||||||
state (if (contains? selected id)
|
state (if (contains? selected id)
|
||||||
(update-in state [:workspace :selected] disj id)
|
(update-in state [:workspace :selected] disj id)
|
||||||
|
@ -394,8 +394,8 @@
|
||||||
;; --- Select Shapes
|
;; --- Select Shapes
|
||||||
|
|
||||||
(defrecord SelectShapes [selrect]
|
(defrecord SelectShapes [selrect]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [page (get-in state [:workspace :page])
|
(let [page (get-in state [:workspace :page])
|
||||||
shapes (impl/match-by-selrect state page selrect)]
|
shapes (impl/match-by-selrect state page selrect)]
|
||||||
(assoc-in state [:workspace :selected] shapes))))
|
(assoc-in state [:workspace :selected] shapes))))
|
||||||
|
@ -409,8 +409,8 @@
|
||||||
|
|
||||||
(defrecord UpdateInteraction [shape interaction]
|
(defrecord UpdateInteraction [shape interaction]
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [id (or (:id interaction)
|
(let [id (or (:id interaction)
|
||||||
(uuid/random))
|
(uuid/random))
|
||||||
data (assoc interaction :id id)]
|
data (assoc interaction :id id)]
|
||||||
|
@ -424,8 +424,8 @@
|
||||||
|
|
||||||
(defrecord DeleteInteracton [shape id]
|
(defrecord DeleteInteracton [shape id]
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:shapes shape :interactions] dissoc id)))
|
(update-in state [:shapes shape :interactions] dissoc id)))
|
||||||
|
|
||||||
(defn delete-interaction
|
(defn delete-interaction
|
||||||
|
@ -436,8 +436,8 @@
|
||||||
;; --- Path Modifications
|
;; --- Path Modifications
|
||||||
|
|
||||||
(defrecord UpdatePath [id index delta]
|
(defrecord UpdatePath [id index delta]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:shapes id :points index] gpt/add delta)))
|
(update-in state [:shapes id :points index] gpt/add delta)))
|
||||||
|
|
||||||
(defn update-path
|
(defn update-path
|
||||||
|
@ -447,8 +447,8 @@
|
||||||
(UpdatePath. id index delta))
|
(UpdatePath. id index delta))
|
||||||
|
|
||||||
(defrecord InitialPathPointAlign [id index]
|
(defrecord InitialPathPointAlign [id index]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [shape (get-in state [:shapes id])
|
(let [shape (get-in state [:shapes id])
|
||||||
point (get-in shape [:points index])
|
point (get-in shape [:points index])
|
||||||
point (gpt/add point canvas-coords)]
|
point (gpt/add point canvas-coords)]
|
||||||
|
@ -468,12 +468,12 @@
|
||||||
;; --- Start shape "edition mode"
|
;; --- Start shape "edition mode"
|
||||||
|
|
||||||
(defrecord StartEditionMode [id]
|
(defrecord StartEditionMode [id]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:workspace :edition] id))
|
(assoc-in state [:workspace :edition] id))
|
||||||
|
|
||||||
rs/EffectEvent
|
ptk/EffectEvent
|
||||||
(-apply-effect [_ state]
|
(effect [_ state stream]
|
||||||
(rlocks/acquire! :shape/edition)))
|
(rlocks/acquire! :shape/edition)))
|
||||||
|
|
||||||
(defn start-edition-mode
|
(defn start-edition-mode
|
||||||
|
@ -484,15 +484,15 @@
|
||||||
;; --- Events (implicit) (for selected)
|
;; --- Events (implicit) (for selected)
|
||||||
|
|
||||||
(defrecord DeselectAll []
|
(defrecord DeselectAll []
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(-> state
|
(-> state
|
||||||
(assoc-in [:workspace :selected] #{})
|
(assoc-in [:workspace :selected] #{})
|
||||||
(assoc-in [:workspace :edition] nil)
|
(assoc-in [:workspace :edition] nil)
|
||||||
(assoc-in [:workspace :drawing] nil)))
|
(assoc-in [:workspace :drawing] nil)))
|
||||||
|
|
||||||
rs/EffectEvent
|
ptk/EffectEvent
|
||||||
(-apply-effect [_ state]
|
(effect [_ state stream]
|
||||||
(rlocks/release! :shape/edition)))
|
(rlocks/release! :shape/edition)))
|
||||||
|
|
||||||
(defn deselect-all
|
(defn deselect-all
|
||||||
|
@ -505,8 +505,8 @@
|
||||||
[]
|
[]
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [pid (get-in state [:workspace :page])
|
(let [pid (get-in state [:workspace :page])
|
||||||
selected (get-in state [:workspace :selected])]
|
selected (get-in state [:workspace :selected])]
|
||||||
(impl/group-shapes state selected pid)))))
|
(impl/group-shapes state selected pid)))))
|
||||||
|
@ -515,8 +515,8 @@
|
||||||
[]
|
[]
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [pid (get-in state [:workspace :page])
|
(let [pid (get-in state [:workspace :page])
|
||||||
selected (get-in state [:workspace :selected])]
|
selected (get-in state [:workspace :selected])]
|
||||||
(impl/degroup-shapes state selected pid)))))
|
(impl/degroup-shapes state selected pid)))))
|
||||||
|
@ -526,8 +526,8 @@
|
||||||
[]
|
[]
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [selected (get-in state [:workspace :selected])]
|
(let [selected (get-in state [:workspace :selected])]
|
||||||
(impl/duplicate-shapes state selected)))))
|
(impl/duplicate-shapes state selected)))))
|
||||||
|
|
||||||
|
@ -535,8 +535,8 @@
|
||||||
"Deselect all and remove all selected shapes."
|
"Deselect all and remove all selected shapes."
|
||||||
[]
|
[]
|
||||||
(reify
|
(reify
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [selected (get-in state [:workspace :selected])]
|
(let [selected (get-in state [:workspace :selected])]
|
||||||
(rx/from-coll
|
(rx/from-coll
|
||||||
(into [(deselect-all)] (map #(delete-shape %) selected)))))))
|
(into [(deselect-all)] (map #(delete-shape %) selected)))))))
|
||||||
|
@ -547,8 +547,8 @@
|
||||||
([dir n]
|
([dir n]
|
||||||
{:pre [(contains? #{:up :down :right :left} dir)]}
|
{:pre [(contains? #{:up :down :right :left} dir)]}
|
||||||
(reify
|
(reify
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [selected (get-in state [:workspace :selected])
|
(let [selected (get-in state [:workspace :selected])
|
||||||
delta (case dir
|
delta (case dir
|
||||||
:up (gpt/point 0 (- n))
|
:up (gpt/point 0 (- n))
|
||||||
|
@ -563,8 +563,8 @@
|
||||||
selected shapes."
|
selected shapes."
|
||||||
[opts]
|
[opts]
|
||||||
(reify
|
(reify
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(rx/from-coll
|
(rx/from-coll
|
||||||
(->> (get-in state [:workspace :selected])
|
(->> (get-in state [:workspace :selected])
|
||||||
(map #(update-fill-attrs % opts)))))))
|
(map #(update-fill-attrs % opts)))))))
|
||||||
|
@ -575,8 +575,8 @@
|
||||||
selected shapes."
|
selected shapes."
|
||||||
[opts]
|
[opts]
|
||||||
(reify
|
(reify
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(rx/from-coll
|
(rx/from-coll
|
||||||
(->> (get-in state [:workspace :selected])
|
(->> (get-in state [:workspace :selected])
|
||||||
(map #(update-stroke-attrs % opts)))))))
|
(map #(update-stroke-attrs % opts)))))))
|
||||||
|
@ -585,8 +585,8 @@
|
||||||
[loc]
|
[loc]
|
||||||
(reify
|
(reify
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [selected (get-in state [:workspace :selected])]
|
(let [selected (get-in state [:workspace :selected])]
|
||||||
(impl/move-layer state selected loc)))))
|
(impl/move-layer state selected loc)))))
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
(ns uxbox.main.data.undo
|
(ns uxbox.main.data.undo
|
||||||
(:require #_[cljs.pprint :as pp]
|
(:require #_[cljs.pprint :as pp]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.data.pages :as udp]
|
[uxbox.main.data.pages :as udp]
|
||||||
[uxbox.main.state :as st]))
|
[uxbox.store :as st]))
|
||||||
|
|
||||||
;; --- Watch Page Changes
|
;; --- Watch Page Changes
|
||||||
|
|
||||||
|
@ -25,26 +25,26 @@
|
||||||
reacts on them emiting an other event that just
|
reacts on them emiting an other event that just
|
||||||
persists the state of the page in an undo stack."
|
persists the state of the page in an undo stack."
|
||||||
[id]
|
[id]
|
||||||
(rs/emit! (initialize-undo-for-page id))
|
(st/emit! (initialize-undo-for-page id))
|
||||||
(as-> rs/stream $
|
(as-> st/store $
|
||||||
(rx/filter #(satisfies? udp/IPageUpdate %) $)
|
(rx/filter #(satisfies? udp/IPageUpdate %) $)
|
||||||
(rx/filter #(not (undo? %)) $)
|
(rx/filter #(not (undo? %)) $)
|
||||||
(rx/filter #(not (redo? %)) $)
|
(rx/filter #(not (redo? %)) $)
|
||||||
(rx/debounce 500 $)
|
(rx/debounce 500 $)
|
||||||
(rx/on-next $ #(rs/emit! (save-undo-entry id)))))
|
(rx/on-next $ #(st/emit! (save-undo-entry id)))))
|
||||||
|
|
||||||
;; -- Save Undo Entry
|
;; -- Save Undo Entry
|
||||||
|
|
||||||
(defrecord SaveUndoEntry [id]
|
(defrecord SaveUndoEntry [id]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [page (udp/pack-page state id)]
|
(let [page (udp/pack-page state id)]
|
||||||
(-> state
|
(-> state
|
||||||
(update-in [:undo id :stack] #(cons (:data page) %))
|
(update-in [:undo id :stack] #(cons (:data page) %))
|
||||||
(assoc-in [:undo id :selected] 0)))))
|
(assoc-in [:undo id :selected] 0)))))
|
||||||
|
|
||||||
;; rs/EffectEvent
|
;; ptk/EffectEvent
|
||||||
;; (-apply-effect [_ state]
|
;; (effect [_ state]
|
||||||
;; (let [undo (get-in state [:undo id])]
|
;; (let [undo (get-in state [:undo id])]
|
||||||
;; (println (pr-str undo)))))
|
;; (println (pr-str undo)))))
|
||||||
|
|
||||||
|
@ -59,8 +59,8 @@
|
||||||
;; --- Initialize Undo (For page)
|
;; --- Initialize Undo (For page)
|
||||||
|
|
||||||
(defrecord InitializeUndoForPage [id]
|
(defrecord InitializeUndoForPage [id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [initialized? (get-in state [:undo id])
|
(let [initialized? (get-in state [:undo id])
|
||||||
page-loaded? (get-in state [:pages id])]
|
page-loaded? (get-in state [:pages id])]
|
||||||
(cond
|
(cond
|
||||||
|
@ -84,8 +84,8 @@
|
||||||
|
|
||||||
(defrecord Undo []
|
(defrecord Undo []
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [page-id (get-in state [:workspace :page])
|
(let [page-id (get-in state [:workspace :page])
|
||||||
undo (get-in state [:undo page-id])
|
undo (get-in state [:undo page-id])
|
||||||
stack (:stack undo)
|
stack (:stack undo)
|
||||||
|
@ -117,8 +117,8 @@
|
||||||
|
|
||||||
(defrecord Redo []
|
(defrecord Redo []
|
||||||
udp/IPageUpdate
|
udp/IPageUpdate
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [page-id (get-in state [:workspace :page])
|
(let [page-id (get-in state [:workspace :page])
|
||||||
undo (get-in state [:undo page-id])
|
undo (get-in state [:undo page-id])
|
||||||
stack (:stack undo)
|
stack (:stack undo)
|
||||||
|
|
|
@ -7,10 +7,9 @@
|
||||||
(ns uxbox.main.data.users
|
(ns uxbox.main.data.users
|
||||||
(:require [cljs.spec :as s]
|
(:require [cljs.spec :as s]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.spec :as us]
|
[uxbox.util.spec :as us]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.main.state :as st]
|
|
||||||
[uxbox.main.repo :as rp]
|
[uxbox.main.repo :as rp]
|
||||||
[uxbox.main.data.messages :as udm]))
|
[uxbox.main.data.messages :as udm]))
|
||||||
|
|
||||||
|
@ -22,8 +21,8 @@
|
||||||
;; --- Profile Fetched
|
;; --- Profile Fetched
|
||||||
|
|
||||||
(defrecord ProfileFetched [data]
|
(defrecord ProfileFetched [data]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [this state]
|
(update [this state]
|
||||||
(assoc state :profile data)))
|
(assoc state :profile data)))
|
||||||
|
|
||||||
(defn profile-fetched
|
(defn profile-fetched
|
||||||
|
@ -33,8 +32,8 @@
|
||||||
;; --- Fetch Profile
|
;; --- Fetch Profile
|
||||||
|
|
||||||
(defrecord FetchProfile []
|
(defrecord FetchProfile []
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(->> (rp/req :fetch/profile)
|
(->> (rp/req :fetch/profile)
|
||||||
(rx/map :payload)
|
(rx/map :payload)
|
||||||
(rx/map profile-fetched))))
|
(rx/map profile-fetched))))
|
||||||
|
@ -46,12 +45,12 @@
|
||||||
;; --- Profile Updated
|
;; --- Profile Updated
|
||||||
|
|
||||||
(defrecord ProfileUpdated [data]
|
(defrecord ProfileUpdated [data]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(rx/of (profile-fetched data)))
|
(rx/of (profile-fetched data)))
|
||||||
|
|
||||||
rs/EffectEvent
|
ptk/EffectEvent
|
||||||
(-apply-effect [_ state]
|
(effect [_ state stream]
|
||||||
(udm/info! (tr "settings.profile-saved"))))
|
(udm/info! (tr "settings.profile-saved"))))
|
||||||
|
|
||||||
(defn profile-updated
|
(defn profile-updated
|
||||||
|
@ -61,8 +60,8 @@
|
||||||
;; --- Update Profile
|
;; --- Update Profile
|
||||||
|
|
||||||
(defrecord UpdateProfile [data on-success on-error]
|
(defrecord UpdateProfile [data on-success on-error]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(letfn [(handle-error [{payload :payload}]
|
(letfn [(handle-error [{payload :payload}]
|
||||||
(on-error payload)
|
(on-error payload)
|
||||||
(rx/empty))]
|
(rx/empty))]
|
||||||
|
@ -85,8 +84,8 @@
|
||||||
;; --- Password Updated
|
;; --- Password Updated
|
||||||
|
|
||||||
(defrecord PasswordUpdated []
|
(defrecord PasswordUpdated []
|
||||||
rs/EffectEvent
|
ptk/EffectEvent
|
||||||
(-apply-effect [_ state]
|
(effect [_ state stream]
|
||||||
(udm/info! (tr "settings.password-saved"))))
|
(udm/info! (tr "settings.password-saved"))))
|
||||||
|
|
||||||
(defn password-updated
|
(defn password-updated
|
||||||
|
@ -96,8 +95,8 @@
|
||||||
;; --- Update Password (Form)
|
;; --- Update Password (Form)
|
||||||
|
|
||||||
(defrecord UpdatePassword [data]
|
(defrecord UpdatePassword [data]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [params {:old-password (:old-password data)
|
(let [params {:old-password (:old-password data)
|
||||||
:password (:password-1 data)}]
|
:password (:password-1 data)}]
|
||||||
(->> (rp/req :update/profile-password params)
|
(->> (rp/req :update/profile-password params)
|
||||||
|
@ -118,8 +117,8 @@
|
||||||
;; --- Update Photo
|
;; --- Update Photo
|
||||||
|
|
||||||
(defrecord UpdatePhoto [file done]
|
(defrecord UpdatePhoto [file done]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(->> (rp/req :update/profile-photo {:file file})
|
(->> (rp/req :update/profile-photo {:file file})
|
||||||
(rx/do done)
|
(rx/do done)
|
||||||
(rx/map fetch-profile))))
|
(rx/map fetch-profile))))
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[uxbox.util.uuid :as uuid]
|
[uxbox.util.uuid :as uuid]
|
||||||
[uxbox.main.constants :as c]
|
[uxbox.main.constants :as c]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.spec :as us]
|
[uxbox.util.spec :as us]
|
||||||
[uxbox.util.forms :as sc]
|
[uxbox.util.forms :as sc]
|
||||||
[uxbox.util.geom.point :as gpt]
|
[uxbox.util.geom.point :as gpt]
|
||||||
[uxbox.util.workers :as uw]
|
[uxbox.util.workers :as uw]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.core :refer (worker)]
|
[uxbox.main.data.core :refer (worker)]
|
||||||
[uxbox.main.data.projects :as dp]
|
[uxbox.main.data.projects :as dp]
|
||||||
[uxbox.main.data.pages :as udp]
|
[uxbox.main.data.pages :as udp]
|
||||||
|
@ -40,8 +40,8 @@
|
||||||
(declare initialize-alignment-index)
|
(declare initialize-alignment-index)
|
||||||
|
|
||||||
(defrecord InitializeWorkspace [project page]
|
(defrecord InitializeWorkspace [project page]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(if (:workspace state)
|
(if (:workspace state)
|
||||||
(update state :workspace merge
|
(update state :workspace merge
|
||||||
{:project project
|
{:project project
|
||||||
|
@ -56,8 +56,8 @@
|
||||||
:selected #{}
|
:selected #{}
|
||||||
:drawing nil})))
|
:drawing nil})))
|
||||||
|
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [page-id page
|
(let [page-id page
|
||||||
page (get-in state [:pages page-id])]
|
page (get-in state [:pages page-id])]
|
||||||
|
|
||||||
|
@ -79,11 +79,11 @@
|
||||||
(udh/fetch-page-history page-id)
|
(udh/fetch-page-history page-id)
|
||||||
(udh/fetch-pinned-page-history page-id)))))
|
(udh/fetch-pinned-page-history page-id)))))
|
||||||
|
|
||||||
rs/EffectEvent
|
ptk/EffectEvent
|
||||||
(-apply-effect [_ state]
|
(effect [_ state stream]
|
||||||
;; Optimistic prefetch of projects if them are not already fetched
|
;; Optimistic prefetch of projects if them are not already fetched
|
||||||
(when-not (seq (:projects state))
|
(when-not (seq (:projects state))
|
||||||
(rs/emit! (dp/fetch-projects)))))
|
(st/emit! (dp/fetch-projects)))))
|
||||||
|
|
||||||
(defn initialize
|
(defn initialize
|
||||||
"Initialize the workspace state."
|
"Initialize the workspace state."
|
||||||
|
@ -96,8 +96,8 @@
|
||||||
"Toggle the enabled flag of the specified tool."
|
"Toggle the enabled flag of the specified tool."
|
||||||
[key]
|
[key]
|
||||||
(reify
|
(reify
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [flags (get-in state [:workspace :flags])]
|
(let [flags (get-in state [:workspace :flags])]
|
||||||
(if (contains? flags key)
|
(if (contains? flags key)
|
||||||
(assoc-in state [:workspace :flags] (disj flags key))
|
(assoc-in state [:workspace :flags] (disj flags key))
|
||||||
|
@ -107,8 +107,8 @@
|
||||||
"Mark a shape selected for drawing in the canvas."
|
"Mark a shape selected for drawing in the canvas."
|
||||||
[shape]
|
[shape]
|
||||||
(reify
|
(reify
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [current (get-in state [:workspace :drawing])]
|
(let [current (get-in state [:workspace :drawing])]
|
||||||
(if (or (nil? shape)
|
(if (or (nil? shape)
|
||||||
(= shape current))
|
(= shape current))
|
||||||
|
@ -118,8 +118,8 @@
|
||||||
;; --- Activate Workspace Flag
|
;; --- Activate Workspace Flag
|
||||||
|
|
||||||
(defrecord ActivateFlag [flag]
|
(defrecord ActivateFlag [flag]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(update-in state [:workspace :flags] conj flag)))
|
(update-in state [:workspace :flags] conj flag)))
|
||||||
|
|
||||||
(defn activate-flag
|
(defn activate-flag
|
||||||
|
@ -129,8 +129,8 @@
|
||||||
;; --- Copy to Clipboard
|
;; --- Copy to Clipboard
|
||||||
|
|
||||||
(defrecord CopyToClipboard []
|
(defrecord CopyToClipboard []
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [selected (get-in state [:workspace :selected])
|
(let [selected (get-in state [:workspace :selected])
|
||||||
item {:id (uuid/random)
|
item {:id (uuid/random)
|
||||||
:created-at (dt/now)
|
:created-at (dt/now)
|
||||||
|
@ -150,8 +150,8 @@
|
||||||
;; --- Paste from Clipboard
|
;; --- Paste from Clipboard
|
||||||
|
|
||||||
(defrecord PasteFromClipboard [id]
|
(defrecord PasteFromClipboard [id]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [page (get-in state [:workspace :page])
|
(let [page (get-in state [:workspace :page])
|
||||||
selected (if (nil? id)
|
selected (if (nil? id)
|
||||||
(first (:clipboard state))
|
(first (:clipboard state))
|
||||||
|
@ -168,8 +168,8 @@
|
||||||
;; --- Increase Zoom
|
;; --- Increase Zoom
|
||||||
|
|
||||||
(defrecord IncreaseZoom []
|
(defrecord IncreaseZoom []
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [increase #(nth zoom-levels
|
(let [increase #(nth zoom-levels
|
||||||
(+ (index-of zoom-levels %) 1)
|
(+ (index-of zoom-levels %) 1)
|
||||||
(last zoom-levels))]
|
(last zoom-levels))]
|
||||||
|
@ -182,8 +182,8 @@
|
||||||
;; --- Decrease Zoom
|
;; --- Decrease Zoom
|
||||||
|
|
||||||
(defrecord DecreaseZoom []
|
(defrecord DecreaseZoom []
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [decrease #(nth zoom-levels
|
(let [decrease #(nth zoom-levels
|
||||||
(- (index-of zoom-levels %) 1)
|
(- (index-of zoom-levels %) 1)
|
||||||
(first zoom-levels))]
|
(first zoom-levels))]
|
||||||
|
@ -196,8 +196,8 @@
|
||||||
;; --- Reset Zoom
|
;; --- Reset Zoom
|
||||||
|
|
||||||
(defrecord ResetZoom []
|
(defrecord ResetZoom []
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:workspace :zoom] 1)))
|
(assoc-in state [:workspace :zoom] 1)))
|
||||||
|
|
||||||
(defn reset-zoom
|
(defn reset-zoom
|
||||||
|
@ -207,8 +207,8 @@
|
||||||
;; --- Initialize Alignment Index
|
;; --- Initialize Alignment Index
|
||||||
|
|
||||||
(defrecord InitializeAlignmentIndex [id]
|
(defrecord InitializeAlignmentIndex [id]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(let [page (get-in state [:pages id])
|
(let [page (get-in state [:pages id])
|
||||||
opts (:options page)
|
opts (:options page)
|
||||||
message {:cmd :grid-init
|
message {:cmd :grid-init
|
||||||
|
@ -231,8 +231,8 @@
|
||||||
;; Is a workspace aware wrapper over uxbox.data.pages/UpdateMetadata event.
|
;; Is a workspace aware wrapper over uxbox.data.pages/UpdateMetadata event.
|
||||||
|
|
||||||
(defrecord UpdateMetadata [id metadata]
|
(defrecord UpdateMetadata [id metadata]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(rx/of (udp/update-metadata id metadata)
|
(rx/of (udp/update-metadata id metadata)
|
||||||
(initialize-alignment-index id))))
|
(initialize-alignment-index id))))
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
(ns uxbox.main.exports
|
(ns uxbox.main.exports
|
||||||
"The main logic for SVG export functionality."
|
"The main logic for SVG export functionality."
|
||||||
(:require [uxbox.main.state :as st]
|
(:require [uxbox.store :as st]
|
||||||
[uxbox.main.ui.shapes.rect :refer (rect-shape)]
|
[uxbox.main.ui.shapes.rect :refer (rect-shape)]
|
||||||
[uxbox.main.ui.shapes.icon :refer (icon-shape)]
|
[uxbox.main.ui.shapes.icon :refer (icon-shape)]
|
||||||
[uxbox.main.ui.shapes.text :refer (text-shape)]
|
[uxbox.main.ui.shapes.text :refer (text-shape)]
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
(:require [uxbox.util.geom.matrix :as gmt]
|
(:require [uxbox.util.geom.matrix :as gmt]
|
||||||
[uxbox.util.geom.point :as gpt]
|
[uxbox.util.geom.point :as gpt]
|
||||||
[uxbox.util.math :as mth]
|
[uxbox.util.math :as mth]
|
||||||
[uxbox.main.state :as st]))
|
[uxbox.store :as st]))
|
||||||
|
|
||||||
;; --- Relative Movement
|
;; --- Relative Movement
|
||||||
|
|
||||||
|
|
|
@ -5,21 +5,8 @@
|
||||||
;; Copyright (c) 2015-2016 Andrey Antukh <niwi@niwi.nz>
|
;; Copyright (c) 2015-2016 Andrey Antukh <niwi@niwi.nz>
|
||||||
|
|
||||||
(ns uxbox.main.state
|
(ns uxbox.main.state
|
||||||
(:require [beicon.core :as rx]
|
(:require [uxbox.builtins.colors :as colors]
|
||||||
[lentes.core :as l]
|
[uxbox.util.storage :refer [storage]]))
|
||||||
[uxbox.main.state.colors :as colors]
|
|
||||||
[uxbox.util.rstore :as rs]
|
|
||||||
[uxbox.util.i18n :refer (tr)]
|
|
||||||
[uxbox.util.storage :refer (storage)]))
|
|
||||||
|
|
||||||
(enable-console-print!)
|
|
||||||
|
|
||||||
(defonce state (atom {}))
|
|
||||||
(defonce loader (atom false))
|
|
||||||
|
|
||||||
(def auth-ref
|
|
||||||
(-> (l/key :auth)
|
|
||||||
(l/derive state)))
|
|
||||||
|
|
||||||
(defn initial-state
|
(defn initial-state
|
||||||
[]
|
[]
|
||||||
|
@ -41,11 +28,3 @@
|
||||||
:shapes nil
|
:shapes nil
|
||||||
:projects nil
|
:projects nil
|
||||||
:pages nil})
|
:pages nil})
|
||||||
|
|
||||||
(defn init
|
|
||||||
"Initialize the state materialization."
|
|
||||||
([] (init initial-state))
|
|
||||||
([& callbacks]
|
|
||||||
(-> (reduce #(merge %1 (%2)) nil callbacks)
|
|
||||||
(rs/init)
|
|
||||||
(rx/to-atom state))))
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[bide.core :as bc]
|
[bide.core :as bc]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.projects :as dp]
|
[uxbox.main.data.projects :as dp]
|
||||||
[uxbox.main.data.users :as udu]
|
[uxbox.main.data.users :as udu]
|
||||||
[uxbox.main.data.auth :refer [logout]]
|
[uxbox.main.data.auth :refer [logout]]
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
[uxbox.main.ui.workspace :refer (workspace)]
|
[uxbox.main.ui.workspace :refer (workspace)]
|
||||||
[uxbox.util.timers :as ts]
|
[uxbox.util.timers :as ts]
|
||||||
[uxbox.util.router :as rt]
|
[uxbox.util.router :as rt]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.data :refer (parse-int uuid-str?)]
|
[uxbox.util.data :refer (parse-int uuid-str?)]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
|
@ -52,12 +52,13 @@
|
||||||
"A default error handler."
|
"A default error handler."
|
||||||
[{:keys [status] :as error}]
|
[{:keys [status] :as error}]
|
||||||
(js/console.log "on-error:" (pr-str error))
|
(js/console.log "on-error:" (pr-str error))
|
||||||
|
(reset! st/loader false)
|
||||||
(cond
|
(cond
|
||||||
;; Unauthorized or Auth timeout
|
;; Unauthorized or Auth timeout
|
||||||
(and (:status error)
|
(and (:status error)
|
||||||
(or (= (:status error) 403)
|
(or (= (:status error) 403)
|
||||||
(= (:status error) 419)))
|
(= (:status error) 419)))
|
||||||
(rs/emit! (logout))
|
(st/emit! (logout))
|
||||||
|
|
||||||
;; Conflict
|
;; Conflict
|
||||||
(= status 412)
|
(= status 412)
|
||||||
|
@ -75,14 +76,14 @@
|
||||||
(dmsg/error! (tr "errors.generic"))
|
(dmsg/error! (tr "errors.generic"))
|
||||||
(js/console.error "Stack:" (.-stack error)))))
|
(js/console.error "Stack:" (.-stack error)))))
|
||||||
|
|
||||||
(rs/add-error-watcher :ui on-error)
|
(set! st/*on-error* on-error)
|
||||||
|
|
||||||
;; --- Main App (Component)
|
;; --- Main App (Component)
|
||||||
|
|
||||||
(defn app-will-mount
|
(defn app-will-mount
|
||||||
[own]
|
[own]
|
||||||
(when @st/auth-ref
|
(when @st/auth-ref
|
||||||
(rs/emit! (udu/fetch-profile)))
|
(st/emit! (udu/fetch-profile)))
|
||||||
own)
|
own)
|
||||||
|
|
||||||
(mx/defc app
|
(mx/defc app
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[uxbox.util.router :as rt]
|
[uxbox.util.router :as rt]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.forms :as forms]
|
[uxbox.util.forms :as forms]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.auth :as da]
|
[uxbox.main.data.auth :as da]
|
||||||
[uxbox.main.data.messages :as udm]
|
[uxbox.main.data.messages :as udm]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
(set-value! field value)))
|
(set-value! field value)))
|
||||||
(on-submit [event]
|
(on-submit [event]
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(rs/emit! (da/login {:username (:email data)
|
(st/emit! (da/login {:username (:email data)
|
||||||
:password (:password data)})))]
|
:password (:password data)})))]
|
||||||
[:form {:on-submit on-submit}
|
[:form {:on-submit on-submit}
|
||||||
[:div.login-content
|
[:div.login-content
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
(:require [lentes.core :as l]
|
(:require [lentes.core :as l]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[uxbox.util.router :as rt]
|
[uxbox.util.router :as rt]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.forms :as forms]
|
[uxbox.util.forms :as forms]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
(set-value! field value)))
|
(set-value! field value)))
|
||||||
(on-submit [event]
|
(on-submit [event]
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(rs/emit! (uda/recovery data)
|
(st/emit! (uda/recovery data)
|
||||||
(forms/clear :recovery)))]
|
(forms/clear :recovery)))]
|
||||||
[:form {:on-submit on-submit}
|
[:form {:on-submit on-submit}
|
||||||
[:div.login-content
|
[:div.login-content
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
(defn- recovery-page-will-mount
|
(defn- recovery-page-will-mount
|
||||||
[own]
|
[own]
|
||||||
(let [[token] (:rum/args own)]
|
(let [[token] (:rum/args own)]
|
||||||
(rs/emit! (uda/validate-recovery-token token))
|
(st/emit! (uda/validate-recovery-token token))
|
||||||
own))
|
own))
|
||||||
|
|
||||||
(mx/defc recovery-page
|
(mx/defc recovery-page
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
(:require [lentes.core :as l]
|
(:require [lentes.core :as l]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[uxbox.util.router :as rt]
|
[uxbox.util.router :as rt]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.forms :as forms]
|
[uxbox.util.forms :as forms]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.auth :as uda]
|
[uxbox.main.data.auth :as uda]
|
||||||
[uxbox.main.data.messages :as udm]
|
[uxbox.main.data.messages :as udm]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
(set-value! field value)))
|
(set-value! field value)))
|
||||||
(on-submit [event]
|
(on-submit [event]
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(rs/emit! (uda/recovery-request data)
|
(st/emit! (uda/recovery-request data)
|
||||||
(forms/clear :recovery-request)))]
|
(forms/clear :recovery-request)))]
|
||||||
[:form {:on-submit on-submit}
|
[:form {:on-submit on-submit}
|
||||||
[:div.login-content
|
[:div.login-content
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
(:require [lentes.core :as l]
|
(:require [lentes.core :as l]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[uxbox.util.router :as rt]
|
[uxbox.util.router :as rt]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.forms :as forms]
|
[uxbox.util.forms :as forms]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.auth :as uda]
|
[uxbox.main.data.auth :as uda]
|
||||||
[uxbox.main.data.messages :as udm]
|
[uxbox.main.data.messages :as udm]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
(set-error! :username "Username already exists")))
|
(set-error! :username "Username already exists")))
|
||||||
(on-submit [event]
|
(on-submit [event]
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(rs/emit! (uda/register data on-error)))]
|
(st/emit! (uda/register data on-error)))]
|
||||||
[:form {:on-submit on-submit}
|
[:form {:on-submit on-submit}
|
||||||
[:div.login-content
|
[:div.login-content
|
||||||
[:input.input-text
|
[:input.input-text
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
[uxbox.main.data.colors :as dc]
|
[uxbox.main.data.colors :as dc]
|
||||||
[uxbox.main.data.dashboard :as dd]
|
[uxbox.main.data.dashboard :as dd]
|
||||||
[uxbox.main.data.lightbox :as udl]
|
[uxbox.main.data.lightbox :as udl]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.ui.messages :as uum]
|
[uxbox.main.ui.messages :as uum]
|
||||||
[uxbox.main.ui.colorpicker :refer (colorpicker)]
|
[uxbox.main.ui.colorpicker :refer (colorpicker)]
|
||||||
[uxbox.main.ui.dashboard.header :refer (header)]
|
[uxbox.main.ui.dashboard.header :refer (header)]
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
[uxbox.util.i18n :as t :refer (tr)]
|
[uxbox.util.i18n :as t :refer (tr)]
|
||||||
[uxbox.util.lens :as ul]
|
[uxbox.util.lens :as ul]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.rstore :as rs]))
|
[potok.core :as ptk]))
|
||||||
|
|
||||||
;; --- Refs
|
;; --- Refs
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
(letfn [(save []
|
(letfn [(save []
|
||||||
(let [dom (mx/ref-node own "input")
|
(let [dom (mx/ref-node own "input")
|
||||||
name (dom/get-inner-text dom)]
|
name (dom/get-inner-text dom)]
|
||||||
(rs/emit! (dc/rename-collection id (str/trim name)))
|
(st/emit! (dc/rename-collection id (str/trim name)))
|
||||||
(swap! local assoc :edit false)))
|
(swap! local assoc :edit false)))
|
||||||
(cancel []
|
(cancel []
|
||||||
(swap! local assoc :edit false))
|
(swap! local assoc :edit false))
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
(dom/stop-propagation e)
|
(dom/stop-propagation e)
|
||||||
(save))))
|
(save))))
|
||||||
(delete []
|
(delete []
|
||||||
(rs/emit! (dc/delete-collection id)))
|
(st/emit! (dc/delete-collection id)))
|
||||||
(on-delete []
|
(on-delete []
|
||||||
(udl/open! :confirm {:on-accept delete}))]
|
(udl/open! :confirm {:on-accept delete}))]
|
||||||
[:div.dashboard-title
|
[:div.dashboard-title
|
||||||
|
@ -95,7 +95,7 @@
|
||||||
[{:keys [id type name] :as coll} selected?]
|
[{:keys [id type name] :as coll} selected?]
|
||||||
(letfn [(on-click [event]
|
(letfn [(on-click [event]
|
||||||
(let [type (or type :own)]
|
(let [type (or type :own)]
|
||||||
(rs/emit! (dc/select-collection type id))))]
|
(st/emit! (dc/select-collection type id))))]
|
||||||
(let [colors (count (:colors coll))]
|
(let [colors (count (:colors coll))]
|
||||||
[:li {:on-click on-click
|
[:li {:on-click on-click
|
||||||
:class-name (when selected? "current")}
|
:class-name (when selected? "current")}
|
||||||
|
@ -113,7 +113,7 @@
|
||||||
{:mixins [mx/static mx/reactive]}
|
{:mixins [mx/static mx/reactive]}
|
||||||
[selected?]
|
[selected?]
|
||||||
(let [num-colors (mx/react storage-num-colors-ref)
|
(let [num-colors (mx/react storage-num-colors-ref)
|
||||||
on-click #(rs/emit! (dc/select-collection :own nil))]
|
on-click #(st/emit! (dc/select-collection :own nil))]
|
||||||
[:li {:on-click on-click :class (when selected? "current")}
|
[:li {:on-click on-click :class (when selected? "current")}
|
||||||
[:span.element-title "Storage"]
|
[:span.element-title "Storage"]
|
||||||
[:span.element-subtitle
|
[:span.element-subtitle
|
||||||
|
@ -133,7 +133,7 @@
|
||||||
(when own?
|
(when own?
|
||||||
[:li
|
[:li
|
||||||
[:a.btn-primary
|
[:a.btn-primary
|
||||||
{:on-click #(rs/emit! (dc/create-collection))}
|
{:on-click #(st/emit! (dc/create-collection))}
|
||||||
"+ New library"]])
|
"+ New library"]])
|
||||||
(when own?
|
(when own?
|
||||||
(nav-item-storage (nil? selected)))
|
(nav-item-storage (nil? selected)))
|
||||||
|
@ -150,14 +150,14 @@
|
||||||
builtin? (= type :builtin)]
|
builtin? (= type :builtin)]
|
||||||
(letfn [(select-tab [type]
|
(letfn [(select-tab [type]
|
||||||
(if (= type :own)
|
(if (= type :own)
|
||||||
(rs/emit! (dc/select-collection type))
|
(st/emit! (dc/select-collection type))
|
||||||
(let [coll (->> (map second colls)
|
(let [coll (->> (map second colls)
|
||||||
(filter #(= type (:type %)))
|
(filter #(= type (:type %)))
|
||||||
(sort-by :created-at)
|
(sort-by :created-at)
|
||||||
(first))]
|
(first))]
|
||||||
(if coll
|
(if coll
|
||||||
(rs/emit! (dc/select-collection type (:id coll)))
|
(st/emit! (dc/select-collection type (:id coll)))
|
||||||
(rs/emit! (dc/select-collection type))))))]
|
(st/emit! (dc/select-collection type))))))]
|
||||||
[:div.library-bar
|
[:div.library-bar
|
||||||
[:div.library-bar-inside
|
[:div.library-bar-inside
|
||||||
[:ul.library-tabs
|
[:ul.library-tabs
|
||||||
|
@ -207,7 +207,7 @@
|
||||||
(let [editable? (or (= type :own) (nil? id))
|
(let [editable? (or (= type :own) (nil? id))
|
||||||
local (:rum/local own)]
|
local (:rum/local own)]
|
||||||
(letfn [(delete [event]
|
(letfn [(delete [event]
|
||||||
(rs/emit! (dc/delete-selected-colors)))
|
(st/emit! (dc/delete-selected-colors)))
|
||||||
(on-delete [event]
|
(on-delete [event]
|
||||||
(udl/open! :confirm {:on-accept delete}))
|
(udl/open! :confirm {:on-accept delete}))
|
||||||
(on-toggle-copy [event]
|
(on-toggle-copy [event]
|
||||||
|
@ -220,12 +220,12 @@
|
||||||
(swap! local assoc
|
(swap! local assoc
|
||||||
:show-move-tooltip false
|
:show-move-tooltip false
|
||||||
:show-copy-tooltip false)
|
:show-copy-tooltip false)
|
||||||
(rs/emit! (dc/copy-selected selected)))
|
(st/emit! (dc/copy-selected selected)))
|
||||||
(on-move [selected]
|
(on-move [selected]
|
||||||
(swap! local assoc
|
(swap! local assoc
|
||||||
:show-move-tooltip false
|
:show-move-tooltip false
|
||||||
:show-copy-tooltip false)
|
:show-copy-tooltip false)
|
||||||
(rs/emit! (dc/move-selected id selected)))]
|
(st/emit! (dc/move-selected id selected)))]
|
||||||
|
|
||||||
;; MULTISELECT OPTIONS BAR
|
;; MULTISELECT OPTIONS BAR
|
||||||
[:div.multiselect-bar
|
[:div.multiselect-bar
|
||||||
|
@ -263,7 +263,7 @@
|
||||||
[color selected?]
|
[color selected?]
|
||||||
(let [color-rgb (hex->rgb color)]
|
(let [color-rgb (hex->rgb color)]
|
||||||
(letfn [(toggle-selection [event]
|
(letfn [(toggle-selection [event]
|
||||||
(rs/emit! (dc/toggle-color-selection color)))
|
(st/emit! (dc/toggle-color-selection color)))
|
||||||
(toggle-selection-shifted [event]
|
(toggle-selection-shifted [event]
|
||||||
(when (k/shift? event)
|
(when (k/shift? event)
|
||||||
(toggle-selection event)))]
|
(toggle-selection event)))]
|
||||||
|
@ -307,7 +307,7 @@
|
||||||
(defn- colors-page-will-mount
|
(defn- colors-page-will-mount
|
||||||
[own]
|
[own]
|
||||||
(let [[type id] (:rum/args own)]
|
(let [[type id] (:rum/args own)]
|
||||||
(rs/emit! (dc/initialize type id))
|
(st/emit! (dc/initialize type id))
|
||||||
own))
|
own))
|
||||||
|
|
||||||
(defn- colors-page-did-remount
|
(defn- colors-page-did-remount
|
||||||
|
@ -316,7 +316,7 @@
|
||||||
[new-type new-id] (:rum/args own)]
|
[new-type new-id] (:rum/args own)]
|
||||||
(when (or (not= old-type new-type)
|
(when (or (not= old-type new-type)
|
||||||
(not= old-id new-id))
|
(not= old-id new-id))
|
||||||
(rs/emit! (dc/initialize new-type new-id)))
|
(st/emit! (dc/initialize new-type new-id)))
|
||||||
own))
|
own))
|
||||||
|
|
||||||
(mx/defc colors-page
|
(mx/defc colors-page
|
||||||
|
@ -344,7 +344,7 @@
|
||||||
(let [params {:id coll
|
(let [params {:id coll
|
||||||
:from color
|
:from color
|
||||||
:to (:hex @local)}]
|
:to (:hex @local)}]
|
||||||
(rs/emit! (dc/replace-color params))
|
(st/emit! (dc/replace-color params))
|
||||||
(udl/close!)))
|
(udl/close!)))
|
||||||
(on-change [event]
|
(on-change [event]
|
||||||
(let [value (str/trim (dom/event->value event))]
|
(let [value (str/trim (dom/event->value event))]
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
(ns uxbox.main.ui.dashboard.elements
|
(ns uxbox.main.ui.dashboard.elements
|
||||||
(:require [sablono.core :as html :refer-macros [html]]
|
(:require [sablono.core :as html :refer-macros [html]]
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.data.dashboard :as dd]
|
[uxbox.main.data.dashboard :as dd]
|
||||||
[uxbox.main.data.lightbox :as udl]
|
[uxbox.main.data.lightbox :as udl]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
|
@ -144,12 +144,12 @@
|
||||||
|
|
||||||
;; (defn elements-page-will-mount
|
;; (defn elements-page-will-mount
|
||||||
;; [own]
|
;; [own]
|
||||||
;; (rs/emit! (dd/initialize :dashboard/elements))
|
;; (st/emit! (dd/initialize :dashboard/elements))
|
||||||
;; own)
|
;; own)
|
||||||
|
|
||||||
;; (defn elements-page-did-remount
|
;; (defn elements-page-did-remount
|
||||||
;; [old-state state]
|
;; [old-state state]
|
||||||
;; (rs/emit! (dd/initialize :dashboard/elements))
|
;; (st/emit! (dd/initialize :dashboard/elements))
|
||||||
;; state)
|
;; state)
|
||||||
|
|
||||||
;; (def elements-page
|
;; (def elements-page
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
(ns uxbox.main.ui.dashboard.header
|
(ns uxbox.main.ui.dashboard.header
|
||||||
(:require [lentes.core :as l]
|
(:require [lentes.core :as l]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.projects :as dp]
|
[uxbox.main.data.projects :as dp]
|
||||||
[uxbox.main.ui.navigation :as nav]
|
[uxbox.main.ui.navigation :as nav]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.rstore :as rs]))
|
[potok.core :as ptk]))
|
||||||
|
|
||||||
(def header-ref
|
(def header-ref
|
||||||
(-> (l/key :dashboard)
|
(-> (l/key :dashboard)
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
(ns uxbox.main.ui.dashboard.icons
|
(ns uxbox.main.ui.dashboard.icons
|
||||||
(:require [lentes.core :as l]
|
(:require [lentes.core :as l]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.lightbox :as udl]
|
[uxbox.main.data.lightbox :as udl]
|
||||||
[uxbox.main.data.icons :as di]
|
[uxbox.main.data.icons :as di]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
[uxbox.util.data :refer (read-string)]
|
[uxbox.util.data :refer (read-string)]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.datetime :as dt]
|
[uxbox.util.datetime :as dt]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.forms :as sc]
|
[uxbox.util.forms :as sc]
|
||||||
[uxbox.util.lens :as ul]
|
[uxbox.util.lens :as ul]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
|
@ -78,7 +78,7 @@
|
||||||
(letfn [(on-save [e]
|
(letfn [(on-save [e]
|
||||||
(let [dom (mx/ref-node own "input")
|
(let [dom (mx/ref-node own "input")
|
||||||
name (.-innerText dom)]
|
name (.-innerText dom)]
|
||||||
(rs/emit! (di/rename-collection id (str/trim name)))
|
(st/emit! (di/rename-collection id (str/trim name)))
|
||||||
(swap! local assoc :edit false)))
|
(swap! local assoc :edit false)))
|
||||||
(on-cancel [e]
|
(on-cancel [e]
|
||||||
(swap! local assoc :edit false))
|
(swap! local assoc :edit false))
|
||||||
|
@ -93,7 +93,7 @@
|
||||||
(dom/stop-propagation e)
|
(dom/stop-propagation e)
|
||||||
(on-save e))))
|
(on-save e))))
|
||||||
(delete []
|
(delete []
|
||||||
(rs/emit! (di/delete-collection id)))
|
(st/emit! (di/delete-collection id)))
|
||||||
(on-delete []
|
(on-delete []
|
||||||
(udl/open! :confirm {:on-accept delete}))]
|
(udl/open! :confirm {:on-accept delete}))]
|
||||||
[:div.dashboard-title
|
[:div.dashboard-title
|
||||||
|
@ -133,7 +133,7 @@
|
||||||
[{:keys [id type name num-icons] :as coll} selected?]
|
[{:keys [id type name num-icons] :as coll} selected?]
|
||||||
(letfn [(on-click [event]
|
(letfn [(on-click [event]
|
||||||
(let [type (or type :own)]
|
(let [type (or type :own)]
|
||||||
(rs/emit! (di/select-collection type id))))]
|
(st/emit! (di/select-collection type id))))]
|
||||||
(let [num-icons (or num-icons (react-count-icons id))]
|
(let [num-icons (or num-icons (react-count-icons id))]
|
||||||
[:li {:on-click on-click
|
[:li {:on-click on-click
|
||||||
:class-name (when selected? "current")}
|
:class-name (when selected? "current")}
|
||||||
|
@ -155,7 +155,7 @@
|
||||||
(when own?
|
(when own?
|
||||||
[:li
|
[:li
|
||||||
[:a.btn-primary
|
[:a.btn-primary
|
||||||
{:on-click #(rs/emit! (di/create-collection))}
|
{:on-click #(st/emit! (di/create-collection))}
|
||||||
"+ New collection"]])
|
"+ New collection"]])
|
||||||
(when own?
|
(when own?
|
||||||
(nav-item nil (nil? selected)))
|
(nav-item nil (nil? selected)))
|
||||||
|
@ -175,8 +175,8 @@
|
||||||
(let [colls (->> (map second colls)
|
(let [colls (->> (map second colls)
|
||||||
(filter #(= :builtin (:type %)))
|
(filter #(= :builtin (:type %)))
|
||||||
(sort-by :name))]
|
(sort-by :name))]
|
||||||
(rs/emit! (di/select-collection type (:id (first colls)))))
|
(st/emit! (di/select-collection type (:id (first colls)))))
|
||||||
(rs/emit! (di/select-collection type))))]
|
(st/emit! (di/select-collection type))))]
|
||||||
[:div.library-bar
|
[:div.library-bar
|
||||||
[:div.library-bar-inside
|
[:div.library-bar-inside
|
||||||
[:ul.library-tabs
|
[:ul.library-tabs
|
||||||
|
@ -198,7 +198,7 @@
|
||||||
(dom/click (mx/ref-node own "file-input")))
|
(dom/click (mx/ref-node own "file-input")))
|
||||||
(on-file-selected [event]
|
(on-file-selected [event]
|
||||||
(let [files (dom/get-event-files event)]
|
(let [files (dom/get-event-files event)]
|
||||||
(rs/emit! (di/create-icons coll-id files))))]
|
(st/emit! (di/create-icons coll-id files))))]
|
||||||
[:div.grid-item.small-item.add-project {:on-click forward-click}
|
[:div.grid-item.small-item.add-project {:on-click forward-click}
|
||||||
[:span "+ New icon"]
|
[:span "+ New icon"]
|
||||||
[:input.upload-image-input
|
[:input.upload-image-input
|
||||||
|
@ -240,7 +240,7 @@
|
||||||
(let [editable? (or (= type :own) (nil? coll))
|
(let [editable? (or (= type :own) (nil? coll))
|
||||||
local (:rum/local own)]
|
local (:rum/local own)]
|
||||||
(letfn [(delete []
|
(letfn [(delete []
|
||||||
(rs/emit! (di/delete-selected)))
|
(st/emit! (di/delete-selected)))
|
||||||
(on-delete [event]
|
(on-delete [event]
|
||||||
(udl/open! :confirm {:on-accept delete}))
|
(udl/open! :confirm {:on-accept delete}))
|
||||||
(on-toggle-copy [event]
|
(on-toggle-copy [event]
|
||||||
|
@ -252,15 +252,15 @@
|
||||||
(swap! local assoc
|
(swap! local assoc
|
||||||
:show-move-tooltip false
|
:show-move-tooltip false
|
||||||
:show-copy-tooltip false)
|
:show-copy-tooltip false)
|
||||||
(rs/emit! (di/copy-selected selected)))
|
(st/emit! (di/copy-selected selected)))
|
||||||
(on-move [selected]
|
(on-move [selected]
|
||||||
(swap! local assoc
|
(swap! local assoc
|
||||||
:show-move-tooltip false
|
:show-move-tooltip false
|
||||||
:show-copy-tooltip false)
|
:show-copy-tooltip false)
|
||||||
(rs/emit! (di/move-selected selected)))
|
(st/emit! (di/move-selected selected)))
|
||||||
(on-rename [event]
|
(on-rename [event]
|
||||||
(let [selected (first selected)]
|
(let [selected (first selected)]
|
||||||
(rs/emit! (di/update-opts :edition selected))))]
|
(st/emit! (di/update-opts :edition selected))))]
|
||||||
;; MULTISELECT OPTIONS BAR
|
;; MULTISELECT OPTIONS BAR
|
||||||
[:div.multiselect-bar
|
[:div.multiselect-bar
|
||||||
(if editable?
|
(if editable?
|
||||||
|
@ -301,7 +301,7 @@
|
||||||
{:mixins [mx/static]}
|
{:mixins [mx/static]}
|
||||||
[{:keys [id created-at] :as icon} selected? edition?]
|
[{:keys [id created-at] :as icon} selected? edition?]
|
||||||
(letfn [(toggle-selection [event]
|
(letfn [(toggle-selection [event]
|
||||||
(rs/emit! (di/toggle-icon-selection id)))
|
(st/emit! (di/toggle-icon-selection id)))
|
||||||
(toggle-selection-shifted [event]
|
(toggle-selection-shifted [event]
|
||||||
(when (kbd/shift? event)
|
(when (kbd/shift? event)
|
||||||
(toggle-selection event)))
|
(toggle-selection event)))
|
||||||
|
@ -311,12 +311,12 @@
|
||||||
(on-blur [event]
|
(on-blur [event]
|
||||||
(let [target (dom/event->target event)
|
(let [target (dom/event->target event)
|
||||||
name (dom/get-value target)]
|
name (dom/get-value target)]
|
||||||
(rs/emit! (di/update-opts :edition false)
|
(st/emit! (di/update-opts :edition false)
|
||||||
(di/rename-icon id name))))
|
(di/rename-icon id name))))
|
||||||
(on-edit [event]
|
(on-edit [event]
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(rs/emit! (di/update-opts :edition id)))]
|
(st/emit! (di/update-opts :edition id)))]
|
||||||
[:div.grid-item.small-item.project-th
|
[:div.grid-item.small-item.project-th
|
||||||
{:on-click toggle-selection-shifted
|
{:on-click toggle-selection-shifted
|
||||||
:id (str "grid-item-" id)}
|
:id (str "grid-item-" id)}
|
||||||
|
@ -381,13 +381,13 @@
|
||||||
(letfn [(on-term-change [event]
|
(letfn [(on-term-change [event]
|
||||||
(let [term (-> (dom/get-target event)
|
(let [term (-> (dom/get-target event)
|
||||||
(dom/get-value))]
|
(dom/get-value))]
|
||||||
(rs/emit! (di/update-opts :filter term))))
|
(st/emit! (di/update-opts :filter term))))
|
||||||
(on-ordering-change [event]
|
(on-ordering-change [event]
|
||||||
(let [value (dom/event->value event)
|
(let [value (dom/event->value event)
|
||||||
value (read-string value)]
|
value (read-string value)]
|
||||||
(rs/emit! (di/update-opts :order value))))
|
(st/emit! (di/update-opts :order value))))
|
||||||
(on-clear [event]
|
(on-clear [event]
|
||||||
(rs/emit! (di/update-opts :filter "")))]
|
(st/emit! (di/update-opts :filter "")))]
|
||||||
[:section.dashboard-bar.library-gap
|
[:section.dashboard-bar.library-gap
|
||||||
[:div.dashboard-info
|
[:div.dashboard-info
|
||||||
|
|
||||||
|
@ -420,7 +420,7 @@
|
||||||
(defn- icons-page-will-mount
|
(defn- icons-page-will-mount
|
||||||
[own]
|
[own]
|
||||||
(let [[type id] (:rum/args own)]
|
(let [[type id] (:rum/args own)]
|
||||||
(rs/emit! (di/initialize type id))
|
(st/emit! (di/initialize type id))
|
||||||
own))
|
own))
|
||||||
|
|
||||||
(defn- icons-page-did-remount
|
(defn- icons-page-did-remount
|
||||||
|
@ -429,7 +429,7 @@
|
||||||
[new-type new-id] (:rum/args own)]
|
[new-type new-id] (:rum/args own)]
|
||||||
(when (or (not= old-type new-type)
|
(when (or (not= old-type new-type)
|
||||||
(not= old-id new-id))
|
(not= old-id new-id))
|
||||||
(rs/emit! (di/initialize new-type new-id)))
|
(st/emit! (di/initialize new-type new-id)))
|
||||||
own))
|
own))
|
||||||
|
|
||||||
(mx/defc icons-page
|
(mx/defc icons-page
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
(:require [cuerdas.core :as str]
|
(:require [cuerdas.core :as str]
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.i18n :as t :refer (tr)]
|
[uxbox.util.i18n :as t :refer (tr)]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.data.lightbox :as udl]
|
[uxbox.main.data.lightbox :as udl]
|
||||||
[uxbox.main.data.images :as di]
|
[uxbox.main.data.images :as di]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
(letfn [(on-save [e]
|
(letfn [(on-save [e]
|
||||||
(let [dom (mx/ref-node own "input")
|
(let [dom (mx/ref-node own "input")
|
||||||
name (dom/get-inner-text dom)]
|
name (dom/get-inner-text dom)]
|
||||||
(rs/emit! (di/rename-collection id (str/trim name)))
|
(st/emit! (di/rename-collection id (str/trim name)))
|
||||||
(swap! local assoc :edit false)))
|
(swap! local assoc :edit false)))
|
||||||
(on-cancel [e]
|
(on-cancel [e]
|
||||||
(swap! local assoc :edit false))
|
(swap! local assoc :edit false))
|
||||||
|
@ -91,7 +91,7 @@
|
||||||
(dom/stop-propagation e)
|
(dom/stop-propagation e)
|
||||||
(on-save e))))
|
(on-save e))))
|
||||||
(delete []
|
(delete []
|
||||||
(rs/emit! (di/delete-collection id)))
|
(st/emit! (di/delete-collection id)))
|
||||||
(on-delete []
|
(on-delete []
|
||||||
(udl/open! :confirm {:on-accept delete}))]
|
(udl/open! :confirm {:on-accept delete}))]
|
||||||
[:div.dashboard-title
|
[:div.dashboard-title
|
||||||
|
@ -131,7 +131,7 @@
|
||||||
[{:keys [id type name] :as coll} selected?]
|
[{:keys [id type name] :as coll} selected?]
|
||||||
(letfn [(on-click [event]
|
(letfn [(on-click [event]
|
||||||
(let [type (or type :own)]
|
(let [type (or type :own)]
|
||||||
(rs/emit! (di/select-collection type id))))]
|
(st/emit! (di/select-collection type id))))]
|
||||||
(let [num-images (react-count-images id)]
|
(let [num-images (react-count-images id)]
|
||||||
[:li {:on-click on-click
|
[:li {:on-click on-click
|
||||||
:class-name (when selected? "current")}
|
:class-name (when selected? "current")}
|
||||||
|
@ -153,7 +153,7 @@
|
||||||
(when own?
|
(when own?
|
||||||
[:li
|
[:li
|
||||||
[:a.btn-primary
|
[:a.btn-primary
|
||||||
{:on-click #(rs/emit! (di/create-collection))}
|
{:on-click #(st/emit! (di/create-collection))}
|
||||||
"+ New library"]])
|
"+ New library"]])
|
||||||
(when own?
|
(when own?
|
||||||
(nav-item nil (nil? selected)))
|
(nav-item nil (nil? selected)))
|
||||||
|
@ -170,14 +170,14 @@
|
||||||
builtin? (= type :builtin)]
|
builtin? (= type :builtin)]
|
||||||
(letfn [(select-tab [type]
|
(letfn [(select-tab [type]
|
||||||
(if own?
|
(if own?
|
||||||
(rs/emit! (di/select-collection type))
|
(st/emit! (di/select-collection type))
|
||||||
(let [coll (->> (map second colls)
|
(let [coll (->> (map second colls)
|
||||||
(filter #(= type (:type %)))
|
(filter #(= type (:type %)))
|
||||||
(sort-by :name)
|
(sort-by :name)
|
||||||
(first))]
|
(first))]
|
||||||
(if coll
|
(if coll
|
||||||
(rs/emit! (di/select-collection type (:id coll)))
|
(st/emit! (di/select-collection type (:id coll)))
|
||||||
(rs/emit! (di/select-collection type))))))]
|
(st/emit! (di/select-collection type))))))]
|
||||||
[:div.library-bar
|
[:div.library-bar
|
||||||
[:div.library-bar-inside
|
[:div.library-bar-inside
|
||||||
[:ul.library-tabs
|
[:ul.library-tabs
|
||||||
|
@ -199,7 +199,7 @@
|
||||||
(dom/click (mx/ref-node own "file-input")))
|
(dom/click (mx/ref-node own "file-input")))
|
||||||
(on-file-selected [event]
|
(on-file-selected [event]
|
||||||
(let [files (dom/get-event-files event)]
|
(let [files (dom/get-event-files event)]
|
||||||
(rs/emit! (di/create-images coll-id files))))]
|
(st/emit! (di/create-images coll-id files))))]
|
||||||
(let [uploading? (mx/react uploading?-ref)]
|
(let [uploading? (mx/react uploading?-ref)]
|
||||||
[:div.grid-item.add-project {:on-click forward-click}
|
[:div.grid-item.add-project {:on-click forward-click}
|
||||||
(if uploading?
|
(if uploading?
|
||||||
|
@ -244,7 +244,7 @@
|
||||||
(let [editable? (or (= type :own) (nil? coll))
|
(let [editable? (or (= type :own) (nil? coll))
|
||||||
local (:rum/local own)]
|
local (:rum/local own)]
|
||||||
(letfn [(delete []
|
(letfn [(delete []
|
||||||
(rs/emit! (di/delete-selected)))
|
(st/emit! (di/delete-selected)))
|
||||||
(on-delete [event]
|
(on-delete [event]
|
||||||
(udl/open! :confirm {:on-accept delete}))
|
(udl/open! :confirm {:on-accept delete}))
|
||||||
(on-toggle-copy [event]
|
(on-toggle-copy [event]
|
||||||
|
@ -255,15 +255,15 @@
|
||||||
(swap! local assoc
|
(swap! local assoc
|
||||||
:show-move-tooltip false
|
:show-move-tooltip false
|
||||||
:show-copy-tooltip false)
|
:show-copy-tooltip false)
|
||||||
(rs/emit! (di/copy-selected selected)))
|
(st/emit! (di/copy-selected selected)))
|
||||||
(on-move [selected]
|
(on-move [selected]
|
||||||
(swap! local assoc
|
(swap! local assoc
|
||||||
:show-move-tooltip false
|
:show-move-tooltip false
|
||||||
:show-copy-tooltip false)
|
:show-copy-tooltip false)
|
||||||
(rs/emit! (di/move-selected selected)))
|
(st/emit! (di/move-selected selected)))
|
||||||
(on-rename [event]
|
(on-rename [event]
|
||||||
(let [selected (first selected)]
|
(let [selected (first selected)]
|
||||||
(rs/emit! (di/update-opts :edition selected))))]
|
(st/emit! (di/update-opts :edition selected))))]
|
||||||
;; MULTISELECT OPTIONS BAR
|
;; MULTISELECT OPTIONS BAR
|
||||||
[:div.multiselect-bar
|
[:div.multiselect-bar
|
||||||
(if editable?
|
(if editable?
|
||||||
|
@ -304,7 +304,7 @@
|
||||||
{:mixins [mx/static]}
|
{:mixins [mx/static]}
|
||||||
[{:keys [id created-at] :as image} selected? edition?]
|
[{:keys [id created-at] :as image} selected? edition?]
|
||||||
(letfn [(toggle-selection [event]
|
(letfn [(toggle-selection [event]
|
||||||
(rs/emit! (di/toggle-image-selection id)))
|
(st/emit! (di/toggle-image-selection id)))
|
||||||
(toggle-selection-shifted [event]
|
(toggle-selection-shifted [event]
|
||||||
(when (kbd/shift? event)
|
(when (kbd/shift? event)
|
||||||
(toggle-selection event)))
|
(toggle-selection event)))
|
||||||
|
@ -314,12 +314,12 @@
|
||||||
(on-blur [event]
|
(on-blur [event]
|
||||||
(let [target (dom/event->target event)
|
(let [target (dom/event->target event)
|
||||||
name (dom/get-value target)]
|
name (dom/get-value target)]
|
||||||
(rs/emit! (di/update-opts :edition false)
|
(st/emit! (di/update-opts :edition false)
|
||||||
(di/rename-image id name))))
|
(di/rename-image id name))))
|
||||||
(on-edit [event]
|
(on-edit [event]
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(rs/emit! (di/update-opts :edition id)))]
|
(st/emit! (di/update-opts :edition id)))]
|
||||||
[:div.grid-item.images-th
|
[:div.grid-item.images-th
|
||||||
{:on-click toggle-selection-shifted}
|
{:on-click toggle-selection-shifted}
|
||||||
[:div.grid-item-th
|
[:div.grid-item-th
|
||||||
|
@ -385,13 +385,13 @@
|
||||||
(letfn [(on-term-change [event]
|
(letfn [(on-term-change [event]
|
||||||
(let [term (-> (dom/get-target event)
|
(let [term (-> (dom/get-target event)
|
||||||
(dom/get-value))]
|
(dom/get-value))]
|
||||||
(rs/emit! (di/update-opts :filter term))))
|
(st/emit! (di/update-opts :filter term))))
|
||||||
(on-ordering-change [event]
|
(on-ordering-change [event]
|
||||||
(let [value (dom/event->value event)
|
(let [value (dom/event->value event)
|
||||||
value (read-string value)]
|
value (read-string value)]
|
||||||
(rs/emit! (di/update-opts :order value))))
|
(st/emit! (di/update-opts :order value))))
|
||||||
(on-clear [event]
|
(on-clear [event]
|
||||||
(rs/emit! (di/update-opts :filter "")))]
|
(st/emit! (di/update-opts :filter "")))]
|
||||||
[:section.dashboard-bar.library-gap
|
[:section.dashboard-bar.library-gap
|
||||||
[:div.dashboard-info
|
[:div.dashboard-info
|
||||||
|
|
||||||
|
@ -424,7 +424,7 @@
|
||||||
(defn- images-page-will-mount
|
(defn- images-page-will-mount
|
||||||
[own]
|
[own]
|
||||||
(let [[type id] (:rum/args own)]
|
(let [[type id] (:rum/args own)]
|
||||||
(rs/emit! (di/initialize type id))
|
(st/emit! (di/initialize type id))
|
||||||
own))
|
own))
|
||||||
|
|
||||||
(defn- images-page-did-remount
|
(defn- images-page-did-remount
|
||||||
|
@ -433,7 +433,7 @@
|
||||||
[new-type new-id] (:rum/args own)]
|
[new-type new-id] (:rum/args own)]
|
||||||
(when (or (not= old-type new-type)
|
(when (or (not= old-type new-type)
|
||||||
(not= old-id new-id))
|
(not= old-id new-id))
|
||||||
(rs/emit! (di/initialize new-type new-id)))
|
(st/emit! (di/initialize new-type new-id)))
|
||||||
own))
|
own))
|
||||||
|
|
||||||
(mx/defc images-page
|
(mx/defc images-page
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
(ns uxbox.main.ui.dashboard.projects
|
(ns uxbox.main.ui.dashboard.projects
|
||||||
(:require [lentes.core :as l]
|
(:require [lentes.core :as l]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.projects :as udp]
|
[uxbox.main.data.projects :as udp]
|
||||||
[uxbox.main.data.lightbox :as udl]
|
[uxbox.main.data.lightbox :as udl]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
[uxbox.main.exports :as exports]
|
[uxbox.main.exports :as exports]
|
||||||
[uxbox.util.i18n :as t :refer (tr)]
|
[uxbox.util.i18n :as t :refer (tr)]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.data :refer (read-string)]
|
[uxbox.util.data :refer (read-string)]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
[uxbox.util.blob :as blob]
|
[uxbox.util.blob :as blob]
|
||||||
|
@ -109,13 +109,13 @@
|
||||||
(letfn [(on-term-change [event]
|
(letfn [(on-term-change [event]
|
||||||
(let [term (-> (dom/get-target event)
|
(let [term (-> (dom/get-target event)
|
||||||
(dom/get-value))]
|
(dom/get-value))]
|
||||||
(rs/emit! (udp/update-opts :filter term))))
|
(st/emit! (udp/update-opts :filter term))))
|
||||||
(on-ordering-change [event]
|
(on-ordering-change [event]
|
||||||
(let [value (dom/event->value event)
|
(let [value (dom/event->value event)
|
||||||
value (read-string value)]
|
value (read-string value)]
|
||||||
(rs/emit! (udp/update-opts :order value))))
|
(st/emit! (udp/update-opts :order value))))
|
||||||
(on-clear [event]
|
(on-clear [event]
|
||||||
(rs/emit! (udp/update-opts :filter "")))]
|
(st/emit! (udp/update-opts :filter "")))]
|
||||||
[:section.dashboard-bar
|
[:section.dashboard-bar
|
||||||
[:div.dashboard-info
|
[:div.dashboard-info
|
||||||
|
|
||||||
|
@ -177,9 +177,9 @@
|
||||||
{:mixins [mx/static (mx/local)]}
|
{:mixins [mx/static (mx/local)]}
|
||||||
[{:keys [rum/local] :as own} project]
|
[{:keys [rum/local] :as own} project]
|
||||||
(letfn [(on-navigate [event]
|
(letfn [(on-navigate [event]
|
||||||
(rs/emit! (udp/go-to (:id project))))
|
(st/emit! (udp/go-to (:id project))))
|
||||||
(delete []
|
(delete []
|
||||||
(rs/emit! (udp/delete-project project)))
|
(st/emit! (udp/delete-project project)))
|
||||||
(on-delete [event]
|
(on-delete [event]
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(udl/open! :confirm {:on-accept delete}))
|
(udl/open! :confirm {:on-accept delete}))
|
||||||
|
@ -191,7 +191,7 @@
|
||||||
name (dom/get-value target)
|
name (dom/get-value target)
|
||||||
id (:id project)]
|
id (:id project)]
|
||||||
(swap! local assoc :edition false)
|
(swap! local assoc :edition false)
|
||||||
(rs/emit! (udp/rename-project id name))))
|
(st/emit! (udp/rename-project id name))))
|
||||||
(on-edit [event]
|
(on-edit [event]
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
|
@ -251,12 +251,12 @@
|
||||||
|
|
||||||
(defn projects-page-will-mount
|
(defn projects-page-will-mount
|
||||||
[own]
|
[own]
|
||||||
(rs/emit! (udp/initialize))
|
(st/emit! (udp/initialize))
|
||||||
own)
|
own)
|
||||||
|
|
||||||
(defn projects-page-did-remount
|
(defn projects-page-did-remount
|
||||||
[old-own own]
|
[old-own own]
|
||||||
(rs/emit! (udp/initialize))
|
(st/emit! (udp/initialize))
|
||||||
own)
|
own)
|
||||||
|
|
||||||
(mx/defc projects-page
|
(mx/defc projects-page
|
||||||
|
@ -350,7 +350,7 @@
|
||||||
{:value "Go go go!"
|
{:value "Go go go!"
|
||||||
:on-click #(do
|
:on-click #(do
|
||||||
(dom/prevent-default %)
|
(dom/prevent-default %)
|
||||||
(rs/emit! (udp/create-project @local))
|
(st/emit! (udp/create-project @local))
|
||||||
(udl/close!))
|
(udl/close!))
|
||||||
|
|
||||||
:type "submit"}])]
|
:type "submit"}])]
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
(:require [sablono.core :as html :refer-macros [html]]
|
(:require [sablono.core :as html :refer-macros [html]]
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.lightbox :as udl]
|
[uxbox.main.data.lightbox :as udl]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.main.ui.keyboard :as k]
|
[uxbox.main.ui.keyboard :as k]
|
||||||
|
|
|
@ -7,21 +7,11 @@
|
||||||
(ns uxbox.main.ui.loader
|
(ns uxbox.main.ui.loader
|
||||||
(:require [sablono.core :refer-macros [html]]
|
(:require [sablono.core :refer-macros [html]]
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.util.rstore :as rs]
|
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.main.ui.shapes]))
|
[uxbox.main.ui.shapes]))
|
||||||
|
|
||||||
;; --- Error Handling
|
|
||||||
|
|
||||||
(defn- on-error
|
|
||||||
[error]
|
|
||||||
;; Disable loader in case of error.
|
|
||||||
(reset! st/loader false))
|
|
||||||
|
|
||||||
(rs/add-error-watcher :loader on-error)
|
|
||||||
|
|
||||||
;; --- Component
|
;; --- Component
|
||||||
|
|
||||||
(defn loader-render
|
(defn loader-render
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
(:require [sablono.core :as html :refer-macros [html]]
|
(:require [sablono.core :as html :refer-macros [html]]
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.messages :as udm]
|
[uxbox.main.data.messages :as udm]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
[uxbox.util.timers :as ts]
|
[uxbox.util.timers :as ts]
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.projects :as dp]
|
[uxbox.main.data.projects :as dp]
|
||||||
[uxbox.main.ui.navigation :as nav]
|
[uxbox.main.ui.navigation :as nav]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
|
|
|
@ -9,11 +9,11 @@
|
||||||
(:require [lentes.core :as l]
|
(:require [lentes.core :as l]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[uxbox.util.i18n :as t :refer (tr)]
|
[uxbox.util.i18n :as t :refer (tr)]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.forms :as forms]
|
[uxbox.util.forms :as forms]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.users :as udu]
|
[uxbox.main.data.users :as udu]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
[uxbox.main.ui.messages :as uum]
|
[uxbox.main.ui.messages :as uum]
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
(set-value! field value)))
|
(set-value! field value)))
|
||||||
(on-submit [event]
|
(on-submit [event]
|
||||||
(println "on-submit" data)
|
(println "on-submit" data)
|
||||||
#_(rs/emit! (udu/update-password form)))]
|
#_(st/emit! (udu/update-password form)))]
|
||||||
(println "password-form" data)
|
(println "password-form" data)
|
||||||
[:form.password-form
|
[:form.password-form
|
||||||
[:span.user-settings-label "Change password"]
|
[:span.user-settings-label "Change password"]
|
||||||
|
|
|
@ -10,11 +10,11 @@
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.forms :as forms]
|
[uxbox.util.forms :as forms]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.interop :refer (iterable->seq)]
|
[uxbox.util.interop :refer (iterable->seq)]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
[uxbox.main.ui.settings.header :refer (header)]
|
[uxbox.main.ui.settings.header :refer (header)]
|
||||||
[uxbox.main.ui.messages :as uum]
|
[uxbox.main.ui.messages :as uum]
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
(on-success []
|
(on-success []
|
||||||
(forms/clear! :profile))
|
(forms/clear! :profile))
|
||||||
(on-submit [event]
|
(on-submit [event]
|
||||||
(rs/emit! (udu/update-profile data on-success on-error)))]
|
(st/emit! (udu/update-profile data on-success on-error)))]
|
||||||
[:form.profile-form
|
[:form.profile-form
|
||||||
[:span.user-settings-label "Name, username and email"]
|
[:span.user-settings-label "Name, username and email"]
|
||||||
[:input.input-text
|
[:input.input-text
|
||||||
|
@ -124,7 +124,7 @@
|
||||||
file (-> (dom/get-files target)
|
file (-> (dom/get-files target)
|
||||||
(iterable->seq)
|
(iterable->seq)
|
||||||
(first))]
|
(first))]
|
||||||
(rs/emit! (udu/update-photo file))
|
(st/emit! (udu/update-photo file))
|
||||||
(dom/clean-value! target)))]
|
(dom/clean-value! target)))]
|
||||||
(let [{:keys [photo]} (mx/react profile-ref)
|
(let [{:keys [photo]} (mx/react profile-ref)
|
||||||
photo (if (or (str/empty? photo) (nil? photo))
|
photo (if (or (str/empty? photo) (nil? photo))
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
(:require [sablono.core :refer-macros [html]]
|
(:require [sablono.core :refer-macros [html]]
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.main.data.shapes :as uds]
|
||||||
[uxbox.main.ui.keyboard :as kbd]
|
[uxbox.main.ui.keyboard :as kbd]
|
||||||
[uxbox.main.ui.workspace.base :as wb]
|
[uxbox.main.ui.workspace.base :as wb]
|
||||||
|
@ -41,10 +41,10 @@
|
||||||
(rx/filter #(= % :mouse/up))
|
(rx/filter #(= % :mouse/up))
|
||||||
(rx/take 1))
|
(rx/take 1))
|
||||||
stream (rx/take-until stoper wb/mouse-delta-s)
|
stream (rx/take-until stoper wb/mouse-delta-s)
|
||||||
on-move #(rs/emit! (uds/move-shape shape %))
|
on-move #(st/emit! (uds/move-shape shape %))
|
||||||
on-stop #(rlocks/release! :shape/move)]
|
on-stop #(rlocks/release! :shape/move)]
|
||||||
(when @wb/alignment-ref
|
(when @wb/alignment-ref
|
||||||
(rs/emit! (uds/initial-align-shape shape)))
|
(st/emit! (uds/initial-align-shape shape)))
|
||||||
(rx/subscribe stream on-move nil on-stop)))]
|
(rx/subscribe stream on-move nil on-stop)))]
|
||||||
|
|
||||||
(rlocks/acquire! :shape/move)
|
(rlocks/acquire! :shape/move)
|
||||||
|
@ -65,16 +65,16 @@
|
||||||
(and (not selected?) (empty? selected))
|
(and (not selected?) (empty? selected))
|
||||||
(do
|
(do
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(rs/emit! (uds/select-shape id))
|
(st/emit! (uds/select-shape id))
|
||||||
(start-move))
|
(start-move))
|
||||||
|
|
||||||
(and (not selected?) (not (empty? selected)))
|
(and (not selected?) (not (empty? selected)))
|
||||||
(do
|
(do
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(if (kbd/shift? event)
|
(if (kbd/shift? event)
|
||||||
(rs/emit! (uds/select-shape id))
|
(st/emit! (uds/select-shape id))
|
||||||
(do
|
(do
|
||||||
(rs/emit! (uds/deselect-all)
|
(st/emit! (uds/deselect-all)
|
||||||
(uds/select-shape id))
|
(uds/select-shape id))
|
||||||
(start-move))))
|
(start-move))))
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
(ns uxbox.main.ui.shapes.group
|
(ns uxbox.main.ui.shapes.group
|
||||||
(:require [lentes.core :as l]
|
(:require [lentes.core :as l]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.main.ui.shapes.common :as common]
|
[uxbox.main.ui.shapes.common :as common]
|
||||||
[uxbox.main.ui.shapes.attrs :as attrs]
|
[uxbox.main.ui.shapes.attrs :as attrs]
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.http :as http]
|
[uxbox.util.http :as http]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.ui.shapes.common :as common]
|
[uxbox.main.ui.shapes.common :as common]
|
||||||
[uxbox.main.ui.shapes.attrs :as attrs]
|
[uxbox.main.ui.shapes.attrs :as attrs]
|
||||||
[uxbox.main.data.images :as udi]
|
[uxbox.main.data.images :as udi]
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
[own]
|
[own]
|
||||||
(let [{:keys [image]} (first (:rum/args own))]
|
(let [{:keys [image]} (first (:rum/args own))]
|
||||||
(println (:rum/args own))
|
(println (:rum/args own))
|
||||||
(rs/emit! (udi/fetch-image image))
|
(st/emit! (udi/fetch-image image))
|
||||||
own))
|
own))
|
||||||
|
|
||||||
(mx/defcs image-component
|
(mx/defcs image-component
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
|
|
||||||
(ns uxbox.main.ui.shapes.path
|
(ns uxbox.main.ui.shapes.path
|
||||||
(:require [uxbox.util.mixins :as mx :include-macros true]
|
(:require [uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
|
[uxbox.store :as st]
|
||||||
[uxbox.main.ui.shapes.common :as common]
|
[uxbox.main.ui.shapes.common :as common]
|
||||||
[uxbox.main.ui.shapes.attrs :as attrs]
|
[uxbox.main.ui.shapes.attrs :as attrs]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.main.data.shapes :as uds]
|
||||||
|
@ -25,7 +26,7 @@
|
||||||
(common/on-mouse-down event shape selected))
|
(common/on-mouse-down event shape selected))
|
||||||
(on-double-click [event]
|
(on-double-click [event]
|
||||||
(when selected?
|
(when selected?
|
||||||
(rs/emit! (uds/start-edition-mode id))))]
|
(st/emit! (uds/start-edition-mode id))))]
|
||||||
[:g.shape {:class (when selected? "selected")
|
[:g.shape {:class (when selected? "selected")
|
||||||
:on-double-click on-double-click
|
:on-double-click on-double-click
|
||||||
:on-mouse-down on-mouse-down}
|
:on-mouse-down on-mouse-down}
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
"Multiple selection handlers component."
|
"Multiple selection handlers component."
|
||||||
(:require [lentes.core :as l]
|
(:require [lentes.core :as l]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.main.data.shapes :as uds]
|
||||||
[uxbox.main.ui.workspace.base :as wb]
|
[uxbox.main.ui.workspace.base :as wb]
|
||||||
[uxbox.util.rlocks :as rlocks]
|
[uxbox.util.rlocks :as rlocks]
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
[vid sid]
|
[vid sid]
|
||||||
(letfn [(on-resize [[delta ctrl?]]
|
(letfn [(on-resize [[delta ctrl?]]
|
||||||
(let [params {:vid vid :delta (assoc delta :lock ctrl?)}]
|
(let [params {:vid vid :delta (assoc delta :lock ctrl?)}]
|
||||||
(rs/emit! (uds/update-vertex-position sid params))))
|
(st/emit! (uds/update-vertex-position sid params))))
|
||||||
(on-end []
|
(on-end []
|
||||||
(rlocks/release! :shape/resize))]
|
(rlocks/release! :shape/resize))]
|
||||||
(let [stoper (->> wb/events-s
|
(let [stoper (->> wb/events-s
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
(rx/with-latest-from vector wb/mouse-ctrl-s))]
|
(rx/with-latest-from vector wb/mouse-ctrl-s))]
|
||||||
(rlocks/acquire! :shape/resize)
|
(rlocks/acquire! :shape/resize)
|
||||||
(when @wb/alignment-ref
|
(when @wb/alignment-ref
|
||||||
(rs/emit! (uds/initial-vertext-align sid vid)))
|
(st/emit! (uds/initial-vertext-align sid vid)))
|
||||||
(rx/subscribe stream on-resize nil on-end))))
|
(rx/subscribe stream on-resize nil on-end))))
|
||||||
|
|
||||||
;; --- Selection Handlers (Component)
|
;; --- Selection Handlers (Component)
|
||||||
|
@ -145,7 +145,7 @@
|
||||||
(defn start-path-edition
|
(defn start-path-edition
|
||||||
[shape-id index]
|
[shape-id index]
|
||||||
(letfn [(on-move [delta]
|
(letfn [(on-move [delta]
|
||||||
(rs/emit! (uds/update-path shape-id index delta)))
|
(st/emit! (uds/update-path shape-id index delta)))
|
||||||
(on-end []
|
(on-end []
|
||||||
(rlocks/release! :shape/resize))]
|
(rlocks/release! :shape/resize))]
|
||||||
(let [stoper (->> wb/events-s
|
(let [stoper (->> wb/events-s
|
||||||
|
@ -155,7 +155,7 @@
|
||||||
stream (rx/take-until stoper wb/mouse-delta-s)]
|
stream (rx/take-until stoper wb/mouse-delta-s)]
|
||||||
(rlocks/acquire! :shape/resize)
|
(rlocks/acquire! :shape/resize)
|
||||||
(when @wb/alignment-ref
|
(when @wb/alignment-ref
|
||||||
(rs/emit! (uds/initial-path-point-align shape-id index)))
|
(st/emit! (uds/initial-path-point-align shape-id index)))
|
||||||
(rx/subscribe stream on-move nil on-end))))
|
(rx/subscribe stream on-move nil on-end))))
|
||||||
|
|
||||||
(mx/defc path-edition-selection-handlers
|
(mx/defc path-edition-selection-handlers
|
||||||
|
|
|
@ -8,10 +8,11 @@
|
||||||
(:require [cuerdas.core :as str]
|
(:require [cuerdas.core :as str]
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[goog.events :as events]
|
[goog.events :as events]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.color :as color]
|
[uxbox.util.color :as color]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.main.data.shapes :as uds]
|
||||||
[uxbox.main.ui.shapes.common :as common]
|
[uxbox.main.ui.shapes.common :as common]
|
||||||
[uxbox.main.ui.shapes.attrs :as attrs]
|
[uxbox.main.ui.shapes.attrs :as attrs]
|
||||||
|
@ -46,7 +47,7 @@
|
||||||
(handle-mouse-down event shape selected))
|
(handle-mouse-down event shape selected))
|
||||||
(on-double-click [event]
|
(on-double-click [event]
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(rs/emit! (uds/start-edition-mode id)))]
|
(st/emit! (uds/start-edition-mode id)))]
|
||||||
[:g.shape {:class (when selected? "selected")
|
[:g.shape {:class (when selected? "selected")
|
||||||
:ref "main"
|
:ref "main"
|
||||||
:on-double-click on-double-click
|
:on-double-click on-double-click
|
||||||
|
@ -113,7 +114,7 @@
|
||||||
(on-done))
|
(on-done))
|
||||||
(on-input [ev]
|
(on-input [ev]
|
||||||
(let [content (dom/event->inner-text ev)]
|
(let [content (dom/event->inner-text ev)]
|
||||||
(rs/emit! (uds/update-text id {:content content}))))]
|
(st/emit! (uds/update-text id {:content content}))))]
|
||||||
[:g
|
[:g
|
||||||
[:rect (merge props +select-rect-attrs+)]
|
[:rect (merge props +select-rect-attrs+)]
|
||||||
[:foreignObject props
|
[:foreignObject props
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.state :as s]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.auth :as da]
|
[uxbox.main.data.auth :as da]
|
||||||
[uxbox.main.data.lightbox :as udl]
|
[uxbox.main.data.lightbox :as udl]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
[:li {:on-click #(r/go :settings/profile)}
|
[:li {:on-click #(r/go :settings/profile)}
|
||||||
i/user
|
i/user
|
||||||
[:span "Your account"]]
|
[:span "Your account"]]
|
||||||
[:li {:on-click #(rs/emit! (da/logout))}
|
[:li {:on-click #(st/emit! (da/logout))}
|
||||||
i/exit
|
i/exit
|
||||||
[:span "Exit"]]])))
|
[:span "Exit"]]])))
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
|
|
||||||
(def profile-ref
|
(def profile-ref
|
||||||
(as-> (l/key :profile) $
|
(as-> (l/key :profile) $
|
||||||
(l/derive $ s/state)))
|
(l/derive $ st/state)))
|
||||||
|
|
||||||
(defn user-render
|
(defn user-render
|
||||||
[own]
|
[own]
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[uxbox.main.constants :as c]
|
[uxbox.main.constants :as c]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.workspace :as dw]
|
[uxbox.main.data.workspace :as dw]
|
||||||
[uxbox.main.data.pages :as udp]
|
[uxbox.main.data.pages :as udp]
|
||||||
[uxbox.main.data.history :as udh]
|
[uxbox.main.data.history :as udh]
|
||||||
|
@ -39,7 +40,7 @@
|
||||||
(defn- workspace-will-mount
|
(defn- workspace-will-mount
|
||||||
[own]
|
[own]
|
||||||
(let [[projectid pageid] (:rum/args own)]
|
(let [[projectid pageid] (:rum/args own)]
|
||||||
(rs/emit! (dw/initialize projectid pageid))
|
(st/emit! (dw/initialize projectid pageid))
|
||||||
own))
|
own))
|
||||||
|
|
||||||
(defn- workspace-did-mount
|
(defn- workspace-did-mount
|
||||||
|
@ -76,7 +77,7 @@
|
||||||
[oldprojectid oldpageid] (:rum/args old-state)]
|
[oldprojectid oldpageid] (:rum/args old-state)]
|
||||||
(if (not= pageid oldpageid)
|
(if (not= pageid oldpageid)
|
||||||
(do
|
(do
|
||||||
(rs/emit! (dw/initialize projectid pageid))
|
(st/emit! (dw/initialize projectid pageid))
|
||||||
(.close (::sub2 old-state))
|
(.close (::sub2 old-state))
|
||||||
(.close (::sub3 old-state))
|
(.close (::sub3 old-state))
|
||||||
(assoc state
|
(assoc state
|
||||||
|
@ -103,8 +104,8 @@
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(if (pos? (.-deltaY event))
|
(if (pos? (.-deltaY event))
|
||||||
(rs/emit! (dw/increase-zoom))
|
(st/emit! (dw/increase-zoom))
|
||||||
(rs/emit! (dw/decrease-zoom)))
|
(st/emit! (dw/decrease-zoom)))
|
||||||
|
|
||||||
(let [dom (mx/ref-node own "workspace-canvas")]
|
(let [dom (mx/ref-node own "workspace-canvas")]
|
||||||
(set! (.-scrollLeft dom) (* c/canvas-start-scroll-x @wb/zoom-ref))
|
(set! (.-scrollLeft dom) (* c/canvas-start-scroll-x @wb/zoom-ref))
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
(ns uxbox.main.ui.workspace.base
|
(ns uxbox.main.ui.workspace.base
|
||||||
(:require [beicon.core :as rx]
|
(:require [beicon.core :as rx]
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.workspace :as dw]
|
[uxbox.main.data.workspace :as dw]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.main.data.shapes :as uds]
|
||||||
[uxbox.util.geom.point :as gpt]
|
[uxbox.util.geom.point :as gpt]
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
(:require [beicon.core :as rx]
|
(:require [beicon.core :as rx]
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[goog.events :as events]
|
[goog.events :as events]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.geom.point :as gpt]
|
[uxbox.util.geom.point :as gpt]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
[uxbox.util.data :refer (parse-int)]
|
[uxbox.util.data :refer (parse-int)]
|
||||||
|
|
|
@ -7,12 +7,12 @@
|
||||||
|
|
||||||
(ns uxbox.main.ui.workspace.clipboard
|
(ns uxbox.main.ui.workspace.clipboard
|
||||||
(:require [lentes.core :as l]
|
(:require [lentes.core :as l]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.lightbox :as udl]
|
[uxbox.main.data.lightbox :as udl]
|
||||||
[uxbox.main.data.workspace :as udw]
|
[uxbox.main.data.workspace :as udw]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
[uxbox.main.ui.lightbox :as lbx]
|
[uxbox.main.ui.lightbox :as lbx]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
[uxbox.util.datetime :as dt]))
|
[uxbox.util.datetime :as dt]))
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
{:mixins [mx/static mx/reactive]}
|
{:mixins [mx/static mx/reactive]}
|
||||||
[]
|
[]
|
||||||
(letfn [(on-paste [item]
|
(letfn [(on-paste [item]
|
||||||
(rs/emit! (udw/paste-from-clipboard (:id item)))
|
(st/emit! (udw/paste-from-clipboard (:id item)))
|
||||||
(udl/close!))
|
(udl/close!))
|
||||||
(on-close [event]
|
(on-close [event]
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
(ns uxbox.main.ui.workspace.colorpalette
|
(ns uxbox.main.ui.workspace.colorpalette
|
||||||
(:require [beicon.core :as rx]
|
(:require [beicon.core :as rx]
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.workspace :as dw]
|
[uxbox.main.data.workspace :as dw]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.main.data.shapes :as uds]
|
||||||
[uxbox.main.data.colors :as dc]
|
[uxbox.main.data.colors :as dc]
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
[uxbox.main.ui.workspace.base :as wb]
|
[uxbox.main.ui.workspace.base :as wb]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
[uxbox.main.ui.keyboard :as kbd]
|
[uxbox.main.ui.keyboard :as kbd]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.lens :as ul]
|
[uxbox.util.lens :as ul]
|
||||||
[uxbox.util.data :refer (read-string)]
|
[uxbox.util.data :refer (read-string)]
|
||||||
[uxbox.util.color :refer (hex->rgb)]
|
[uxbox.util.color :refer (hex->rgb)]
|
||||||
|
@ -35,8 +35,8 @@
|
||||||
(letfn [(select-color [event color]
|
(letfn [(select-color [event color]
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(if (kbd/shift? event)
|
(if (kbd/shift? event)
|
||||||
(rs/emit! (uds/update-selected-shapes-stroke {:color color}))
|
(st/emit! (uds/update-selected-shapes-stroke {:color color}))
|
||||||
(rs/emit! (uds/update-selected-shapes-fill {:color color}))))]
|
(st/emit! (uds/update-selected-shapes-fill {:color color}))))]
|
||||||
[:div.color-palette-content
|
[:div.color-palette-content
|
||||||
(for [hex-color colors
|
(for [hex-color colors
|
||||||
:let [rgb-vec (hex->rgb hex-color)
|
:let [rgb-vec (hex->rgb hex-color)
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
(let [value (read-string (dom/event->value event))]
|
(let [value (read-string (dom/event->value event))]
|
||||||
(swap! local assoc :selected value)))
|
(swap! local assoc :selected value)))
|
||||||
(close [event]
|
(close [event]
|
||||||
(rs/emit! (dw/toggle-flag :colorpalette)))]
|
(st/emit! (dw/toggle-flag :colorpalette)))]
|
||||||
[:div.color-palette
|
[:div.color-palette
|
||||||
[:div.color-palette-actions
|
[:div.color-palette-actions
|
||||||
[:select.input-select {:on-change select-collection}
|
[:select.input-select {:on-change select-collection}
|
||||||
|
@ -78,7 +78,7 @@
|
||||||
|
|
||||||
(defn- colorpalette-will-mount
|
(defn- colorpalette-will-mount
|
||||||
[own]
|
[own]
|
||||||
(rs/emit! (dc/fetch-collections))
|
(st/emit! (dc/fetch-collections))
|
||||||
own)
|
own)
|
||||||
|
|
||||||
(mx/defc colorpalette
|
(mx/defc colorpalette
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.workspace :as udw]
|
[uxbox.main.data.workspace :as udw]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.main.data.shapes :as uds]
|
||||||
[uxbox.main.ui.workspace.base :as wb]
|
[uxbox.main.ui.workspace.base :as wb]
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
top (- y 50)]
|
top (- y 50)]
|
||||||
(letfn [(change-color [color]
|
(letfn [(change-color [color]
|
||||||
(let [attrs {:color color}]
|
(let [attrs {:color color}]
|
||||||
(rs/emit!
|
(st/emit!
|
||||||
(case attr
|
(case attr
|
||||||
:stroke (uds/update-stroke-attrs (:id shape) attrs)
|
:stroke (uds/update-stroke-attrs (:id shape) attrs)
|
||||||
:fill (uds/update-fill-attrs (:id shape) attrs)))))
|
:fill (uds/update-fill-attrs (:id shape) attrs)))))
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[uxbox.main.data.lightbox :as udl]
|
[uxbox.main.data.lightbox :as udl]
|
||||||
[uxbox.main.exports :as exports]
|
[uxbox.main.exports :as exports]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
[uxbox.main.ui.lightbox :as lbx]
|
[uxbox.main.ui.lightbox :as lbx]
|
||||||
[uxbox.main.ui.workspace.base :as wb]
|
[uxbox.main.ui.workspace.base :as wb]
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
[uxbox.util.datetime :as dt]
|
[uxbox.util.datetime :as dt]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.zip :as zip]
|
[uxbox.util.zip :as zip]
|
||||||
[lentes.core :as l]))
|
[lentes.core :as l]))
|
||||||
|
|
||||||
|
|
|
@ -8,14 +8,15 @@
|
||||||
(ns uxbox.main.ui.workspace.drawarea
|
(ns uxbox.main.ui.workspace.drawarea
|
||||||
"Draw interaction and component."
|
"Draw interaction and component."
|
||||||
(:require [beicon.core :as rx]
|
(:require [beicon.core :as rx]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
|
[uxbox.util.rlocks :as rlocks]
|
||||||
|
[uxbox.store :as st]
|
||||||
[uxbox.main.constants :as c]
|
[uxbox.main.constants :as c]
|
||||||
[uxbox.main.data.workspace :as udw]
|
[uxbox.main.data.workspace :as udw]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.main.data.shapes :as uds]
|
||||||
[uxbox.main.ui.shapes :as shapes]
|
[uxbox.main.ui.shapes :as shapes]
|
||||||
[uxbox.main.ui.workspace.base :as wb]
|
[uxbox.main.ui.workspace.base :as wb]
|
||||||
[uxbox.util.rlocks :as rlocks]
|
|
||||||
[uxbox.main.geom :as geom]
|
[uxbox.main.geom :as geom]
|
||||||
[uxbox.util.geom.point :as gpt]
|
[uxbox.util.geom.point :as gpt]
|
||||||
[uxbox.util.geom.path :as path]
|
[uxbox.util.geom.path :as path]
|
||||||
|
@ -128,7 +129,7 @@
|
||||||
:x2 (+ x 200)
|
:x2 (+ x 200)
|
||||||
:y2 (+ y (/ 200 proportion))}
|
:y2 (+ y (/ 200 proportion))}
|
||||||
shape (geom/setup shape props)]
|
shape (geom/setup shape props)]
|
||||||
(rs/emit! (uds/add-shape shape)
|
(st/emit! (uds/add-shape shape)
|
||||||
(udw/select-for-drawing nil)
|
(udw/select-for-drawing nil)
|
||||||
(uds/select-first-shape))
|
(uds/select-first-shape))
|
||||||
(rlocks/release! :ui/draw)))
|
(rlocks/release! :ui/draw)))
|
||||||
|
@ -232,7 +233,7 @@
|
||||||
|
|
||||||
(on-end []
|
(on-end []
|
||||||
(let [shape @drawing-shape]
|
(let [shape @drawing-shape]
|
||||||
(rs/emit! (uds/add-shape shape)
|
(st/emit! (uds/add-shape shape)
|
||||||
(udw/select-for-drawing nil)
|
(udw/select-for-drawing nil)
|
||||||
(uds/select-first-shape))
|
(uds/select-first-shape))
|
||||||
(reset! drawing-shape nil)
|
(reset! drawing-shape nil)
|
||||||
|
@ -268,7 +269,7 @@
|
||||||
|
|
||||||
(on-end []
|
(on-end []
|
||||||
(let [shape (simplify-shape @drawing-shape)]
|
(let [shape (simplify-shape @drawing-shape)]
|
||||||
(rs/emit! (uds/add-shape shape)
|
(st/emit! (uds/add-shape shape)
|
||||||
(udw/select-for-drawing nil)
|
(udw/select-for-drawing nil)
|
||||||
(uds/select-first-shape))
|
(uds/select-first-shape))
|
||||||
(reset! drawing-shape nil)
|
(reset! drawing-shape nil)
|
||||||
|
@ -301,7 +302,7 @@
|
||||||
(let [shape @drawing-shape
|
(let [shape @drawing-shape
|
||||||
shpos @drawing-position
|
shpos @drawing-position
|
||||||
shape (geom/resize shape shpos)]
|
shape (geom/resize shape shpos)]
|
||||||
(rs/emit! (uds/add-shape shape)
|
(st/emit! (uds/add-shape shape)
|
||||||
(udw/select-for-drawing nil)
|
(udw/select-for-drawing nil)
|
||||||
(uds/select-first-shape))
|
(uds/select-first-shape))
|
||||||
(reset! drawing-position nil)
|
(reset! drawing-position nil)
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[uxbox.config :as cfg]
|
[uxbox.config :as cfg]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.workspace :as dw]
|
[uxbox.main.data.workspace :as dw]
|
||||||
[uxbox.main.data.history :as udh]
|
[uxbox.main.data.history :as udh]
|
||||||
[uxbox.main.data.lightbox :as udl]
|
[uxbox.main.data.lightbox :as udl]
|
||||||
|
@ -33,8 +34,8 @@
|
||||||
coords (some-> (mx/react wb/mouse-canvas-a)
|
coords (some-> (mx/react wb/mouse-canvas-a)
|
||||||
(gpt/divide zoom)
|
(gpt/divide zoom)
|
||||||
(gpt/round 1))
|
(gpt/round 1))
|
||||||
increase #(rs/emit! (dw/increase-zoom))
|
increase #(st/emit! (dw/increase-zoom))
|
||||||
decrease #(rs/emit! (dw/decrease-zoom))]
|
decrease #(st/emit! (dw/decrease-zoom))]
|
||||||
(html
|
(html
|
||||||
[:ul.options-view
|
[:ul.options-view
|
||||||
[:li.coordinates {:alt "x"}
|
[:li.coordinates {:alt "x"}
|
||||||
|
@ -66,9 +67,9 @@
|
||||||
(let [project (mx/react wb/project-ref)
|
(let [project (mx/react wb/project-ref)
|
||||||
page (mx/react wb/page-ref)
|
page (mx/react wb/page-ref)
|
||||||
flags (mx/react wb/flags-ref)
|
flags (mx/react wb/flags-ref)
|
||||||
toggle #(rs/emit! (dw/toggle-flag %))
|
toggle #(st/emit! (dw/toggle-flag %))
|
||||||
on-undo #(rs/emit! (udh/backwards-to-previous-version))
|
on-undo #(st/emit! (udh/backwards-to-previous-version))
|
||||||
on-redo #(rs/emit! (udh/forward-to-next-version))
|
on-redo #(st/emit! (udh/forward-to-next-version))
|
||||||
on-image #(udl/open! :import-image)
|
on-image #(udl/open! :import-image)
|
||||||
on-download #(udl/open! :download)]
|
on-download #(udl/open! :download)]
|
||||||
(html
|
(html
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
(ns uxbox.main.ui.workspace.images
|
(ns uxbox.main.ui.workspace.images
|
||||||
(:require [lentes.core :as l]
|
(:require [lentes.core :as l]
|
||||||
[uxbox.util.i18n :as t :refer (tr)]
|
[uxbox.util.i18n :as t :refer (tr)]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.data :as data :refer (read-string)]
|
[uxbox.util.data :as data :refer (read-string)]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.lightbox :as udl]
|
[uxbox.main.data.lightbox :as udl]
|
||||||
[uxbox.main.data.images :as udi]
|
[uxbox.main.data.images :as udi]
|
||||||
[uxbox.main.data.workspace :as udw]
|
[uxbox.main.data.workspace :as udw]
|
||||||
|
@ -54,11 +54,11 @@
|
||||||
:metadata {:width width
|
:metadata {:width width
|
||||||
:height height}
|
:height height}
|
||||||
:image id}]
|
:image id}]
|
||||||
(rs/emit! (udw/select-for-drawing shape))
|
(st/emit! (udw/select-for-drawing shape))
|
||||||
(udl/close!)))
|
(udl/close!)))
|
||||||
(on-files-selected [event]
|
(on-files-selected [event]
|
||||||
(let [files (dom/get-event-files event)]
|
(let [files (dom/get-event-files event)]
|
||||||
(rs/emit! (udi/create-images nil files on-uploaded))))
|
(st/emit! (udi/create-images nil files on-uploaded))))
|
||||||
(on-select-from-library [event]
|
(on-select-from-library [event]
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(udl/open! :import-image-from-collections))
|
(udl/open! :import-image-from-collections))
|
||||||
|
@ -96,7 +96,7 @@
|
||||||
:metadata {:width width
|
:metadata {:width width
|
||||||
:height height}
|
:height height}
|
||||||
:image id}]
|
:image id}]
|
||||||
(rs/emit! (udw/select-for-drawing shape))
|
(st/emit! (udw/select-for-drawing shape))
|
||||||
(udl/close!)))]
|
(udl/close!)))]
|
||||||
[:div.library-item {:key (str id)
|
[:div.library-item {:key (str id)
|
||||||
:on-double-click on-double-click}
|
:on-double-click on-double-click}
|
||||||
|
@ -115,10 +115,10 @@
|
||||||
(defn will-mount
|
(defn will-mount
|
||||||
[own]
|
[own]
|
||||||
(let [local (:rum/local own)]
|
(let [local (:rum/local own)]
|
||||||
(rs/emit! (udi/fetch-collections))
|
(st/emit! (udi/fetch-collections))
|
||||||
(rs/emit! (udi/fetch-images nil))
|
(st/emit! (udi/fetch-images nil))
|
||||||
(add-watch local ::key (fn [_ _ _ v]
|
(add-watch local ::key (fn [_ _ _ v]
|
||||||
(rs/emit! (udi/fetch-images (:id v)))))
|
(st/emit! (udi/fetch-images (:id v)))))
|
||||||
own))
|
own))
|
||||||
|
|
||||||
(defn will-unmount
|
(defn will-unmount
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.workspace :as dw]
|
[uxbox.main.data.workspace :as dw]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[uxbox.main.constants :as c]
|
[uxbox.main.constants :as c]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.math :as mth]
|
[uxbox.util.math :as mth]
|
||||||
[uxbox.main.ui.workspace.base :as wb]
|
[uxbox.main.ui.workspace.base :as wb]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[uxbox.main.constants :as c]
|
[uxbox.main.constants :as c]
|
||||||
[uxbox.main.state :as s]
|
[uxbox.store :as s]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
[uxbox.main.ui.workspace.base :as wb]
|
[uxbox.main.ui.workspace.base :as wb]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]))
|
[uxbox.util.mixins :as mx :include-macros true]))
|
||||||
|
|
|
@ -8,8 +8,9 @@
|
||||||
(ns uxbox.main.ui.workspace.selrect
|
(ns uxbox.main.ui.workspace.selrect
|
||||||
"Mouse selection interaction and component."
|
"Mouse selection interaction and component."
|
||||||
(:require [beicon.core :as rx]
|
(:require [beicon.core :as rx]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
|
[uxbox.store :as st]
|
||||||
[uxbox.main.constants :as c]
|
[uxbox.main.constants :as c]
|
||||||
[uxbox.main.data.workspace :as dw]
|
[uxbox.main.data.workspace :as dw]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.main.data.shapes :as uds]
|
||||||
|
@ -94,7 +95,7 @@
|
||||||
[]
|
[]
|
||||||
(let [rect (-> (selrect->rect @position)
|
(let [rect (-> (selrect->rect @position)
|
||||||
(translate-to-canvas))]
|
(translate-to-canvas))]
|
||||||
(rs/emit! (uds/deselect-all)
|
(st/emit! (uds/deselect-all)
|
||||||
(uds/select-shapes rect))
|
(uds/select-shapes rect))
|
||||||
(rlocks/release! :ui/selrect)
|
(rlocks/release! :ui/selrect)
|
||||||
(reset! position nil)))
|
(reset! position nil)))
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
(ns uxbox.main.ui.workspace.settings
|
(ns uxbox.main.ui.workspace.settings
|
||||||
(:require [lentes.core :as l]
|
(:require [lentes.core :as l]
|
||||||
[uxbox.main.constants :as c]
|
[uxbox.main.constants :as c]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.data.pages :as udp]
|
[uxbox.main.data.pages :as udp]
|
||||||
[uxbox.main.data.workspace :as udw]
|
[uxbox.main.data.workspace :as udw]
|
||||||
[uxbox.main.data.lightbox :as udl]
|
[uxbox.main.data.lightbox :as udl]
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
(let [[errors data] (forms/validate data +settings-form+)]
|
(let [[errors data] (forms/validate data +settings-form+)]
|
||||||
(if errors
|
(if errors
|
||||||
(set-errors! errors)
|
(set-errors! errors)
|
||||||
(rs/emit! (udw/update-metadata id data)
|
(st/emit! (udw/update-metadata id data)
|
||||||
(forms/clear :workspace-settings)
|
(forms/clear :workspace-settings)
|
||||||
(udl/hide-lightbox)))))]
|
(udl/hide-lightbox)))))]
|
||||||
[:form {:on-submit on-submit}
|
[:form {:on-submit on-submit}
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
(ns uxbox.main.ui.workspace.shortcuts
|
(ns uxbox.main.ui.workspace.shortcuts
|
||||||
(:require [goog.events :as events]
|
(:require [goog.events :as events]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.lightbox :as udl]
|
[uxbox.main.data.lightbox :as udl]
|
||||||
[uxbox.main.data.workspace :as dw]
|
[uxbox.main.data.workspace :as dw]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.main.data.shapes :as uds]
|
||||||
|
@ -25,30 +26,30 @@
|
||||||
;; --- Shortcuts
|
;; --- Shortcuts
|
||||||
|
|
||||||
(defonce +shortcuts+
|
(defonce +shortcuts+
|
||||||
{:shift+g #(rs/emit! (dw/toggle-flag :grid))
|
{:shift+g #(st/emit! (dw/toggle-flag :grid))
|
||||||
:ctrl+g #(rs/emit! (uds/group-selected))
|
:ctrl+g #(st/emit! (uds/group-selected))
|
||||||
:ctrl+shift+g #(rs/emit! (uds/degroup-selected))
|
:ctrl+shift+g #(st/emit! (uds/degroup-selected))
|
||||||
:ctrl+shift+m #(rs/emit! (dw/toggle-flag :sitemap))
|
:ctrl+shift+m #(st/emit! (dw/toggle-flag :sitemap))
|
||||||
:ctrl+shift+f #(rs/emit! (dw/toggle-flag :drawtools))
|
:ctrl+shift+f #(st/emit! (dw/toggle-flag :drawtools))
|
||||||
:ctrl+shift+i #(rs/emit! (dw/toggle-flag :icons))
|
:ctrl+shift+i #(st/emit! (dw/toggle-flag :icons))
|
||||||
:ctrl+shift+l #(rs/emit! (dw/toggle-flag :layers))
|
:ctrl+shift+l #(st/emit! (dw/toggle-flag :layers))
|
||||||
:ctrl+0 #(rs/emit! (dw/reset-zoom))
|
:ctrl+0 #(st/emit! (dw/reset-zoom))
|
||||||
:ctrl+r #(rs/emit! (dw/toggle-flag :ruler))
|
:ctrl+r #(st/emit! (dw/toggle-flag :ruler))
|
||||||
:ctrl+d #(rs/emit! (uds/duplicate-selected))
|
:ctrl+d #(st/emit! (uds/duplicate-selected))
|
||||||
:ctrl+c #(rs/emit! (dw/copy-to-clipboard))
|
:ctrl+c #(st/emit! (dw/copy-to-clipboard))
|
||||||
:ctrl+v #(rs/emit! (dw/paste-from-clipboard))
|
:ctrl+v #(st/emit! (dw/paste-from-clipboard))
|
||||||
:ctrl+shift+v #(udl/open! :clipboard)
|
:ctrl+shift+v #(udl/open! :clipboard)
|
||||||
:ctrl+z #(rs/emit! (udu/undo))
|
:ctrl+z #(st/emit! (udu/undo))
|
||||||
:ctrl+shift+z #(rs/emit! (udu/redo))
|
:ctrl+shift+z #(st/emit! (udu/redo))
|
||||||
:ctrl+b #(rs/emit! (dw/select-for-drawing wsd/+draw-tool-rect+))
|
:ctrl+b #(st/emit! (dw/select-for-drawing wsd/+draw-tool-rect+))
|
||||||
:ctrl+e #(rs/emit! (dw/select-for-drawing wsd/+draw-tool-circle+))
|
:ctrl+e #(st/emit! (dw/select-for-drawing wsd/+draw-tool-circle+))
|
||||||
:ctrl+t #(rs/emit! (dw/select-for-drawing wsd/+draw-tool-text+))
|
:ctrl+t #(st/emit! (dw/select-for-drawing wsd/+draw-tool-text+))
|
||||||
:esc #(rs/emit! (uds/deselect-all))
|
:esc #(st/emit! (uds/deselect-all))
|
||||||
:delete #(rs/emit! (uds/delete-selected))
|
:delete #(st/emit! (uds/delete-selected))
|
||||||
:ctrl+up #(rs/emit! (uds/move-selected-layer :up))
|
:ctrl+up #(st/emit! (uds/move-selected-layer :up))
|
||||||
:ctrl+down #(rs/emit! (uds/move-selected-layer :down))
|
:ctrl+down #(st/emit! (uds/move-selected-layer :down))
|
||||||
:ctrl+shift+up #(rs/emit! (uds/move-selected-layer :top))
|
:ctrl+shift+up #(st/emit! (uds/move-selected-layer :top))
|
||||||
:ctrl+shift+down #(rs/emit! (uds/move-selected-layer :bottom))
|
:ctrl+shift+down #(st/emit! (uds/move-selected-layer :bottom))
|
||||||
:shift+up #(move-selected :up :fast)
|
:shift+up #(move-selected :up :fast)
|
||||||
:shift+down #(move-selected :down :fast)
|
:shift+down #(move-selected :down :fast)
|
||||||
:shift+right #(move-selected :right :fast)
|
:shift+right #(move-selected :right :fast)
|
||||||
|
@ -90,8 +91,8 @@
|
||||||
(defn- move-selected
|
(defn- move-selected
|
||||||
[dir speed]
|
[dir speed]
|
||||||
(case speed
|
(case speed
|
||||||
:std (rs/emit! (uds/move-selected dir 1))
|
:std (st/emit! (uds/move-selected dir 1))
|
||||||
:fast (rs/emit! (uds/move-selected dir 20))))
|
:fast (st/emit! (uds/move-selected dir 20))))
|
||||||
|
|
||||||
;; --- Mixin
|
;; --- Mixin
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
(ns uxbox.main.ui.workspace.sidebar
|
(ns uxbox.main.ui.workspace.sidebar
|
||||||
(:require [lentes.core :as l]
|
(:require [lentes.core :as l]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.main.ui.workspace.base :as wb]
|
[uxbox.main.ui.workspace.base :as wb]
|
||||||
[uxbox.main.ui.workspace.sidebar.options :refer (options-toolbox)]
|
[uxbox.main.ui.workspace.sidebar.options :refer (options-toolbox)]
|
||||||
|
|
|
@ -10,11 +10,11 @@
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.data :refer (read-string)]
|
[uxbox.util.data :refer (read-string)]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.workspace :as dw]
|
[uxbox.main.data.workspace :as dw]
|
||||||
[uxbox.main.ui.workspace.base :as wb]
|
[uxbox.main.ui.workspace.base :as wb]
|
||||||
[uxbox.main.ui.icons :as i]))
|
[uxbox.main.ui.icons :as i]))
|
||||||
|
@ -82,14 +82,14 @@
|
||||||
|
|
||||||
(defn- select-for-draw
|
(defn- select-for-draw
|
||||||
[shape]
|
[shape]
|
||||||
(rs/emit! (dw/select-for-drawing shape)))
|
(st/emit! (dw/select-for-drawing shape)))
|
||||||
|
|
||||||
(mx/defc draw-toolbox
|
(mx/defc draw-toolbox
|
||||||
{:mixins [mx/static mx/reactive]}
|
{:mixins [mx/static mx/reactive]}
|
||||||
[own]
|
[own]
|
||||||
(let [workspace (mx/react wb/workspace-ref)
|
(let [workspace (mx/react wb/workspace-ref)
|
||||||
drawing (mx/react drawing-shape)
|
drawing (mx/react drawing-shape)
|
||||||
close #(rs/emit! (dw/toggle-flag :drawtools))
|
close #(st/emit! (dw/toggle-flag :drawtools))
|
||||||
tools (->> (into [] +draw-tools+)
|
tools (->> (into [] +draw-tools+)
|
||||||
(sort-by (comp :priority second)))]
|
(sort-by (comp :priority second)))]
|
||||||
[:div#form-tools.tool-window.drawing-tools
|
[:div#form-tools.tool-window.drawing-tools
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.workspace :as dw]
|
[uxbox.main.data.workspace :as dw]
|
||||||
[uxbox.main.data.pages :as udp]
|
[uxbox.main.data.pages :as udp]
|
||||||
[uxbox.main.data.history :as udh]
|
[uxbox.main.data.history :as udh]
|
||||||
|
@ -36,14 +36,14 @@
|
||||||
[own item selected]
|
[own item selected]
|
||||||
(letfn [(on-select [event]
|
(letfn [(on-select [event]
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(rs/emit! (udh/select-page-history (:version item))))
|
(st/emit! (udh/select-page-history (:version item))))
|
||||||
(on-pinned [event]
|
(on-pinned [event]
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(let [item (assoc item
|
(let [item (assoc item
|
||||||
:label "no label"
|
:label "no label"
|
||||||
:pinned (not (:pinned item)))]
|
:pinned (not (:pinned item)))]
|
||||||
(rs/emit! (udh/update-history-item item))))]
|
(st/emit! (udh/update-history-item item))))]
|
||||||
(let [selected? (= (:version item) selected)]
|
(let [selected? (= (:version item) selected)]
|
||||||
(html
|
(html
|
||||||
[:li {:class (when selected? "current") :on-click on-select}
|
[:li {:class (when selected? "current") :on-click on-select}
|
||||||
|
@ -65,13 +65,13 @@
|
||||||
[own page history]
|
[own page history]
|
||||||
(letfn [(on-select [event]
|
(letfn [(on-select [event]
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(rs/emit! (udh/deselect-page-history (:id page))))
|
(st/emit! (udh/deselect-page-history (:id page))))
|
||||||
|
|
||||||
(on-load-more [event]
|
(on-load-more [event]
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(let [since (:min-version history)
|
(let [since (:min-version history)
|
||||||
params {:since since}]
|
params {:since since}]
|
||||||
(rs/emit! (udh/fetch-page-history (:id page) params))))]
|
(st/emit! (udh/fetch-page-history (:id page) params))))]
|
||||||
|
|
||||||
(let [selected (:selected history)
|
(let [selected (:selected history)
|
||||||
show-more? (pos? (:min-version history))]
|
show-more? (pos? (:min-version history))]
|
||||||
|
@ -121,7 +121,7 @@
|
||||||
page (mx/react wb/page-ref)
|
page (mx/react wb/page-ref)
|
||||||
history (mx/react history-ref)
|
history (mx/react history-ref)
|
||||||
section (:section @local :main)
|
section (:section @local :main)
|
||||||
close #(rs/emit! (dw/toggle-flag :document-history))
|
close #(st/emit! (dw/toggle-flag :document-history))
|
||||||
main? (= section :main)
|
main? (= section :main)
|
||||||
pinned? (= section :pinned)
|
pinned? (= section :pinned)
|
||||||
show-main #(swap! local assoc :section :main)
|
show-main #(swap! local assoc :section :main)
|
||||||
|
@ -156,8 +156,8 @@
|
||||||
[own page]
|
[own page]
|
||||||
(let [history (mx/react history-ref)
|
(let [history (mx/react history-ref)
|
||||||
version (:selected history)
|
version (:selected history)
|
||||||
on-accept #(rs/emit! (udh/apply-selected-history page))
|
on-accept #(st/emit! (udh/apply-selected-history page))
|
||||||
on-cancel #(rs/emit! (udh/deselect-page-history page))]
|
on-cancel #(st/emit! (udh/deselect-page-history page))]
|
||||||
(when (or version (:deselecting history))
|
(when (or version (:deselecting history))
|
||||||
(html
|
(html
|
||||||
[:div.message-version
|
[:div.message-version
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
(ns uxbox.main.ui.workspace.sidebar.icons
|
(ns uxbox.main.ui.workspace.sidebar.icons
|
||||||
(:require [lentes.core :as l]
|
(:require [lentes.core :as l]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.workspace :as dw]
|
[uxbox.main.data.workspace :as dw]
|
||||||
[uxbox.main.data.icons :as udi]
|
[uxbox.main.data.icons :as udi]
|
||||||
[uxbox.main.ui.shapes.icon :as icon]
|
[uxbox.main.ui.shapes.icon :as icon]
|
||||||
|
@ -40,10 +40,10 @@
|
||||||
(defn- icons-toolbox-will-mount
|
(defn- icons-toolbox-will-mount
|
||||||
[own]
|
[own]
|
||||||
(let [local (:rum/local own)]
|
(let [local (:rum/local own)]
|
||||||
(rs/emit! (udi/fetch-collections))
|
(st/emit! (udi/fetch-collections))
|
||||||
(rs/emit! (udi/fetch-icons nil))
|
(st/emit! (udi/fetch-icons nil))
|
||||||
(add-watch local ::key (fn [_ _ _ {:keys [id]}]
|
(add-watch local ::key (fn [_ _ _ {:keys [id]}]
|
||||||
(rs/emit! (udi/fetch-icons id))))
|
(st/emit! (udi/fetch-icons id))))
|
||||||
own))
|
own))
|
||||||
|
|
||||||
(defn- icons-toolbox-will-unmount
|
(defn- icons-toolbox-will-unmount
|
||||||
|
@ -69,14 +69,14 @@
|
||||||
(filter #(= (:id coll) (:collection %))))]
|
(filter #(= (:id coll) (:collection %))))]
|
||||||
|
|
||||||
(letfn [(on-close [event]
|
(letfn [(on-close [event]
|
||||||
(rs/emit! (dw/toggle-flag :icons)))
|
(st/emit! (dw/toggle-flag :icons)))
|
||||||
(on-select [icon event]
|
(on-select [icon event]
|
||||||
(rs/emit! (dw/select-for-drawing icon)))
|
(st/emit! (dw/select-for-drawing icon)))
|
||||||
(on-change [event]
|
(on-change [event]
|
||||||
(let [value (-> (dom/event->value event)
|
(let [value (-> (dom/event->value event)
|
||||||
(read-string))]
|
(read-string))]
|
||||||
(swap! local assoc :id value)
|
(swap! local assoc :id value)
|
||||||
(rs/emit! (dw/select-for-drawing nil))))]
|
(st/emit! (dw/select-for-drawing nil))))]
|
||||||
[:div#form-figures.tool-window
|
[:div#form-figures.tool-window
|
||||||
[:div.tool-window-bar
|
[:div.tool-window-bar
|
||||||
[:div.tool-window-icon i/icon-set]
|
[:div.tool-window-icon i/icon-set]
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[goog.events :as events]
|
[goog.events :as events]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.util.data :refer (read-string classnames)]
|
[uxbox.util.data :refer (read-string classnames)]
|
||||||
[uxbox.main.data.workspace :as udw]
|
[uxbox.main.data.workspace :as udw]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.main.data.shapes :as uds]
|
||||||
|
@ -41,17 +41,17 @@
|
||||||
nil
|
nil
|
||||||
|
|
||||||
(.-ctrlKey event)
|
(.-ctrlKey event)
|
||||||
(rs/emit! (uds/select-shape id))
|
(st/emit! (uds/select-shape id))
|
||||||
|
|
||||||
(> (count selected) 1)
|
(> (count selected) 1)
|
||||||
(rs/emit! (uds/deselect-all)
|
(st/emit! (uds/deselect-all)
|
||||||
(uds/select-shape id))
|
(uds/select-shape id))
|
||||||
|
|
||||||
(contains? selected id)
|
(contains? selected id)
|
||||||
(rs/emit! (uds/select-shape id))
|
(st/emit! (uds/select-shape id))
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(rs/emit! (uds/deselect-all)
|
(st/emit! (uds/deselect-all)
|
||||||
(uds/select-shape id)))))
|
(uds/select-shape id)))))
|
||||||
|
|
||||||
(defn- toggle-visibility
|
(defn- toggle-visibility
|
||||||
|
@ -60,10 +60,10 @@
|
||||||
(let [id (:id item)
|
(let [id (:id item)
|
||||||
hidden? (:hidden item)]
|
hidden? (:hidden item)]
|
||||||
(if hidden?
|
(if hidden?
|
||||||
(rs/emit! (uds/show-shape id))
|
(st/emit! (uds/show-shape id))
|
||||||
(rs/emit! (uds/hide-shape id)))
|
(st/emit! (uds/hide-shape id)))
|
||||||
(when (contains? selected id)
|
(when (contains? selected id)
|
||||||
(rs/emit! (uds/select-shape id)))))
|
(st/emit! (uds/select-shape id)))))
|
||||||
|
|
||||||
(defn- toggle-blocking
|
(defn- toggle-blocking
|
||||||
[item event]
|
[item event]
|
||||||
|
@ -71,8 +71,8 @@
|
||||||
(let [id (:id item)
|
(let [id (:id item)
|
||||||
blocked? (:blocked item)]
|
blocked? (:blocked item)]
|
||||||
(if blocked?
|
(if blocked?
|
||||||
(rs/emit! (uds/unblock-shape id))
|
(st/emit! (uds/unblock-shape id))
|
||||||
(rs/emit! (uds/block-shape id)))))
|
(st/emit! (uds/block-shape id)))))
|
||||||
|
|
||||||
(defn- element-icon
|
(defn- element-icon
|
||||||
[item]
|
[item]
|
||||||
|
@ -116,7 +116,7 @@
|
||||||
data {:id (:id shape)
|
data {:id (:id shape)
|
||||||
:name (dom/get-value target)}]
|
:name (dom/get-value target)}]
|
||||||
(set! (.-draggable parent) true)
|
(set! (.-draggable parent) true)
|
||||||
(rs/emit! (uds/update-shape data))
|
(st/emit! (uds/update-shape data))
|
||||||
(swap! local assoc :edition false)))
|
(swap! local assoc :edition false)))
|
||||||
(on-key-down [event]
|
(on-key-down [event]
|
||||||
(js/console.log event)
|
(js/console.log event)
|
||||||
|
@ -168,8 +168,8 @@
|
||||||
(let [id (dnd/get-data event)
|
(let [id (dnd/get-data event)
|
||||||
over (:over @local)]
|
over (:over @local)]
|
||||||
(case (:over @local)
|
(case (:over @local)
|
||||||
:top (rs/emit! (uds/drop-shape id (:id item) :before))
|
:top (st/emit! (uds/drop-shape id (:id item) :before))
|
||||||
:bottom (rs/emit! (uds/drop-shape id (:id item) :after)))
|
:bottom (st/emit! (uds/drop-shape id (:id item) :after)))
|
||||||
(swap! local assoc :dragging false :over nil)))
|
(swap! local assoc :dragging false :over nil)))
|
||||||
(on-drag-over [event]
|
(on-drag-over [event]
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
|
@ -228,13 +228,13 @@
|
||||||
(letfn [(toggle-collapse [event]
|
(letfn [(toggle-collapse [event]
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(if (:collapsed item)
|
(if (:collapsed item)
|
||||||
(rs/emit! (uds/uncollapse-shape id))
|
(st/emit! (uds/uncollapse-shape id))
|
||||||
(rs/emit! (uds/collapse-shape id))))
|
(st/emit! (uds/collapse-shape id))))
|
||||||
(toggle-locking [event]
|
(toggle-locking [event]
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(if (:locked item)
|
(if (:locked item)
|
||||||
(rs/emit! (uds/unlock-shape id))
|
(st/emit! (uds/unlock-shape id))
|
||||||
(rs/emit! (uds/lock-shape id))))
|
(st/emit! (uds/lock-shape id))))
|
||||||
(on-drag-start [event]
|
(on-drag-start [event]
|
||||||
(let [target (dom/event->target event)]
|
(let [target (dom/event->target event)]
|
||||||
(dnd/set-allowed-effect! event "move")
|
(dnd/set-allowed-effect! event "move")
|
||||||
|
@ -247,9 +247,9 @@
|
||||||
(let [coming-id (dnd/get-data event)
|
(let [coming-id (dnd/get-data event)
|
||||||
over (:over @local)]
|
over (:over @local)]
|
||||||
(case (:over @local)
|
(case (:over @local)
|
||||||
:top (rs/emit! (uds/drop-shape coming-id id :before))
|
:top (st/emit! (uds/drop-shape coming-id id :before))
|
||||||
:bottom (rs/emit! (uds/drop-shape coming-id id :after))
|
:bottom (st/emit! (uds/drop-shape coming-id id :after))
|
||||||
:middle (rs/emit! (uds/drop-shape coming-id id :inside)))
|
:middle (st/emit! (uds/drop-shape coming-id id :inside)))
|
||||||
(swap! local assoc :dragging false :over nil)))
|
(swap! local assoc :dragging false :over nil)))
|
||||||
(on-drag-over [event]
|
(on-drag-over [event]
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
|
@ -309,11 +309,11 @@
|
||||||
selected (:selected workspace)
|
selected (:selected workspace)
|
||||||
shapes-map (mx/react wb/shapes-by-id-ref)
|
shapes-map (mx/react wb/shapes-by-id-ref)
|
||||||
page (mx/react (focus-page (:page workspace)))
|
page (mx/react (focus-page (:page workspace)))
|
||||||
close #(rs/emit! (udw/toggle-flag :layers))
|
close #(st/emit! (udw/toggle-flag :layers))
|
||||||
duplicate #(rs/emit! (uds/duplicate-selected))
|
duplicate #(st/emit! (uds/duplicate-selected))
|
||||||
group #(rs/emit! (uds/group-selected))
|
group #(st/emit! (uds/group-selected))
|
||||||
degroup #(rs/emit! (uds/degroup-selected))
|
degroup #(st/emit! (uds/degroup-selected))
|
||||||
delete #(rs/emit! (uds/delete-selected))
|
delete #(st/emit! (uds/delete-selected))
|
||||||
dragel (volatile! nil)]
|
dragel (volatile! nil)]
|
||||||
[:div#layers.tool-window
|
[:div#layers.tool-window
|
||||||
[:div.tool-window-bar
|
[:div.tool-window-bar
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.workspace :as udw]
|
[uxbox.main.data.workspace :as udw]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.main.data.shapes :as uds]
|
||||||
[uxbox.main.ui.workspace.base :as wb]
|
[uxbox.main.ui.workspace.base :as wb]
|
||||||
|
@ -132,7 +132,7 @@
|
||||||
{:mixins [mx/static mx/reactive]}
|
{:mixins [mx/static mx/reactive]}
|
||||||
[]
|
[]
|
||||||
(let [shape (mx/react selected-shape-ref)
|
(let [shape (mx/react selected-shape-ref)
|
||||||
close #(rs/emit! (udw/toggle-flag :element-options))]
|
close #(st/emit! (udw/toggle-flag :element-options))]
|
||||||
[:div.elementa-options.tool-window
|
[:div.elementa-options.tool-window
|
||||||
[:div.tool-window-bar
|
[:div.tool-window-bar
|
||||||
[:div.tool-window-icon i/options]
|
[:div.tool-window-icon i/options]
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.workspace :as udw]
|
[uxbox.main.data.workspace :as udw]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.main.data.shapes :as uds]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
|
@ -31,22 +31,22 @@
|
||||||
value (parse-int value 0)
|
value (parse-int value 0)
|
||||||
sid (:id shape)
|
sid (:id shape)
|
||||||
props {attr value}]
|
props {attr value}]
|
||||||
(rs/emit! (uds/update-size sid props))))
|
(st/emit! (uds/update-size sid props))))
|
||||||
(on-rotation-change [event]
|
(on-rotation-change [event]
|
||||||
(let [value (dom/event->value event)
|
(let [value (dom/event->value event)
|
||||||
value (parse-int value 0)
|
value (parse-int value 0)
|
||||||
sid (:id shape)]
|
sid (:id shape)]
|
||||||
(rs/emit! (uds/update-rotation sid value))))
|
(st/emit! (uds/update-rotation sid value))))
|
||||||
(on-pos-change [attr event]
|
(on-pos-change [attr event]
|
||||||
(let [value (dom/event->value event)
|
(let [value (dom/event->value event)
|
||||||
value (parse-int value nil)
|
value (parse-int value nil)
|
||||||
sid (:id shape)
|
sid (:id shape)
|
||||||
props {attr value}]
|
props {attr value}]
|
||||||
(rs/emit! (uds/update-position sid props))))
|
(st/emit! (uds/update-position sid props))))
|
||||||
(on-proportion-lock-change [event]
|
(on-proportion-lock-change [event]
|
||||||
(if (:proportion-lock shape)
|
(if (:proportion-lock shape)
|
||||||
(rs/emit! (uds/unlock-proportions id))
|
(st/emit! (uds/unlock-proportions id))
|
||||||
(rs/emit! (uds/lock-proportions id))))]
|
(st/emit! (uds/lock-proportions id))))]
|
||||||
[:div.element-set {:key (str (:id menu))}
|
[:div.element-set {:key (str (:id menu))}
|
||||||
[:div.element-set-title (:name menu)]
|
[:div.element-set-title (:name menu)]
|
||||||
[:div.element-set-content
|
[:div.element-set-content
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.main.data.shapes :as uds]
|
||||||
[uxbox.main.data.lightbox :as udl]
|
[uxbox.main.data.lightbox :as udl]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
[own menu shape]
|
[own menu shape]
|
||||||
(letfn [(change-fill [value]
|
(letfn [(change-fill [value]
|
||||||
(let [sid (:id shape)]
|
(let [sid (:id shape)]
|
||||||
(rs/emit! (uds/update-fill-attrs sid value))))
|
(st/emit! (uds/update-fill-attrs sid value))))
|
||||||
(on-color-change [event]
|
(on-color-change [event]
|
||||||
(let [value (dom/event->value event)]
|
(let [value (dom/event->value event)]
|
||||||
(change-fill {:color value})))
|
(change-fill {:color value})))
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.workspace :as udw]
|
[uxbox.main.data.workspace :as udw]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.main.data.shapes :as uds]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
|
@ -30,18 +30,18 @@
|
||||||
value (parse-int value 0)
|
value (parse-int value 0)
|
||||||
sid (:id shape)
|
sid (:id shape)
|
||||||
props {attr value}]
|
props {attr value}]
|
||||||
(rs/emit! (uds/update-size sid props))))
|
(st/emit! (uds/update-size sid props))))
|
||||||
(on-rotation-change [event]
|
(on-rotation-change [event]
|
||||||
(let [value (dom/event->value event)
|
(let [value (dom/event->value event)
|
||||||
value (parse-int value 0)
|
value (parse-int value 0)
|
||||||
sid (:id shape)]
|
sid (:id shape)]
|
||||||
(rs/emit! (uds/update-rotation sid value))))
|
(st/emit! (uds/update-rotation sid value))))
|
||||||
(on-pos-change [attr event]
|
(on-pos-change [attr event]
|
||||||
(let [value (dom/event->value event)
|
(let [value (dom/event->value event)
|
||||||
value (parse-int value nil)
|
value (parse-int value nil)
|
||||||
sid (:id shape)
|
sid (:id shape)
|
||||||
props {attr value}]
|
props {attr value}]
|
||||||
(rs/emit! (uds/update-position sid props))))]
|
(st/emit! (uds/update-position sid props))))]
|
||||||
(let [size (geom/size shape)]
|
(let [size (geom/size shape)]
|
||||||
(html
|
(html
|
||||||
[:div.element-set {:key (str (:id menu))}
|
[:div.element-set {:key (str (:id menu))}
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.main.data.shapes :as uds]
|
||||||
[uxbox.main.data.lightbox :as udl]
|
[uxbox.main.data.lightbox :as udl]
|
||||||
[uxbox.main.ui.workspace.sidebar.sitemap :refer (pages-ref)]
|
[uxbox.main.ui.workspace.sidebar.sitemap :refer (pages-ref)]
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
(delete [item]
|
(delete [item]
|
||||||
(let [sid (:id shape)
|
(let [sid (:id shape)
|
||||||
id (:id item)]
|
id (:id item)]
|
||||||
(rs/emit! (uds/delete-interaction sid id))))
|
(st/emit! (uds/delete-interaction sid id))))
|
||||||
(on-delete [item event]
|
(on-delete [item event]
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(let [delete (partial delete item)]
|
(let [delete (partial delete item)]
|
||||||
|
@ -543,7 +543,7 @@
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(let [shape-id (:id shape)
|
(let [shape-id (:id shape)
|
||||||
data (deref form-ref)]
|
data (deref form-ref)]
|
||||||
(rs/emit! (uds/update-interaction shape-id data))
|
(st/emit! (uds/update-interaction shape-id data))
|
||||||
(reset! form-ref nil)))
|
(reset! form-ref nil)))
|
||||||
(on-cancel [event]
|
(on-cancel [event]
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.workspace :as udw]
|
[uxbox.main.data.workspace :as udw]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.main.data.shapes :as uds]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
|
@ -29,13 +29,13 @@
|
||||||
(let [value (dom/event->value event)
|
(let [value (dom/event->value event)
|
||||||
value (parse-int value 0)
|
value (parse-int value 0)
|
||||||
sid (:id shape)]
|
sid (:id shape)]
|
||||||
(rs/emit! (uds/update-rotation sid value))))
|
(st/emit! (uds/update-rotation sid value))))
|
||||||
(on-pos-change [attr event]
|
(on-pos-change [attr event]
|
||||||
(let [value (dom/event->value event)
|
(let [value (dom/event->value event)
|
||||||
value (parse-int value nil)
|
value (parse-int value nil)
|
||||||
sid (:id shape)
|
sid (:id shape)
|
||||||
props {attr value}]
|
props {attr value}]
|
||||||
(rs/emit! (uds/update-line-attrs sid props))))]
|
(st/emit! (uds/update-line-attrs sid props))))]
|
||||||
(html
|
(html
|
||||||
[:div.element-set {:key (str (:id menu))}
|
[:div.element-set {:key (str (:id menu))}
|
||||||
[:div.element-set-title (:name menu)]
|
[:div.element-set-title (:name menu)]
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
(:require [lentes.core :as l]
|
(:require [lentes.core :as l]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.workspace :as udw]
|
[uxbox.main.data.workspace :as udw]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.main.data.shapes :as uds]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
(:require [lentes.core :as l]
|
(:require [lentes.core :as l]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.workspace :as udw]
|
[uxbox.main.data.workspace :as udw]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.main.data.shapes :as uds]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
|
@ -28,28 +28,28 @@
|
||||||
(let [value (-> (dom/event->value event) (parse-int 0))
|
(let [value (-> (dom/event->value event) (parse-int 0))
|
||||||
sid (:id shape)
|
sid (:id shape)
|
||||||
props {attr value}]
|
props {attr value}]
|
||||||
(rs/emit! (uds/update-size sid props))))
|
(st/emit! (uds/update-size sid props))))
|
||||||
(on-rotation-change [event]
|
(on-rotation-change [event]
|
||||||
(let [value (dom/event->value event)
|
(let [value (dom/event->value event)
|
||||||
value (parse-int value 0)
|
value (parse-int value 0)
|
||||||
sid (:id shape)]
|
sid (:id shape)]
|
||||||
(rs/emit! (uds/update-rotation sid value))))
|
(st/emit! (uds/update-rotation sid value))))
|
||||||
(on-pos-change [attr event]
|
(on-pos-change [attr event]
|
||||||
(let [value (dom/event->value event)
|
(let [value (dom/event->value event)
|
||||||
value (parse-int value nil)
|
value (parse-int value nil)
|
||||||
sid (:id shape)
|
sid (:id shape)
|
||||||
props {attr value}]
|
props {attr value}]
|
||||||
(rs/emit! (uds/update-position sid props))))
|
(st/emit! (uds/update-position sid props))))
|
||||||
(on-border-change [attr event]
|
(on-border-change [attr event]
|
||||||
(let [value (dom/event->value event)
|
(let [value (dom/event->value event)
|
||||||
value (parse-int value nil)
|
value (parse-int value nil)
|
||||||
sid (:id shape)
|
sid (:id shape)
|
||||||
props {attr value}]
|
props {attr value}]
|
||||||
(rs/emit! (uds/update-radius-attrs sid props))))
|
(st/emit! (uds/update-radius-attrs sid props))))
|
||||||
(on-proportion-lock-change [event]
|
(on-proportion-lock-change [event]
|
||||||
(if (:proportion-lock shape)
|
(if (:proportion-lock shape)
|
||||||
(rs/emit! (uds/unlock-proportions id))
|
(st/emit! (uds/unlock-proportions id))
|
||||||
(rs/emit! (uds/lock-proportions id))))]
|
(st/emit! (uds/lock-proportions id))))]
|
||||||
(let [size (geom/size shape)]
|
(let [size (geom/size shape)]
|
||||||
[:div.element-set
|
[:div.element-set
|
||||||
[:div.element-set-title (:name menu)]
|
[:div.element-set-title (:name menu)]
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.main.data.shapes :as uds]
|
||||||
[uxbox.main.data.lightbox :as udl]
|
[uxbox.main.data.lightbox :as udl]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
[own menu shape]
|
[own menu shape]
|
||||||
(letfn [(change-stroke [value]
|
(letfn [(change-stroke [value]
|
||||||
(let [sid (:id shape)]
|
(let [sid (:id shape)]
|
||||||
(rs/emit! (uds/update-stroke-attrs sid value))))
|
(st/emit! (uds/update-stroke-attrs sid value))))
|
||||||
(on-width-change [event]
|
(on-width-change [event]
|
||||||
(let [value (dom/event->value event)
|
(let [value (dom/event->value event)
|
||||||
value (parse-float value 1)]
|
value (parse-float value 1)]
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.workspace :as udw]
|
[uxbox.main.data.workspace :as udw]
|
||||||
[uxbox.main.data.shapes :as uds]
|
[uxbox.main.data.shapes :as uds]
|
||||||
[uxbox.main.ui.workspace.base :as wb]
|
[uxbox.main.ui.workspace.base :as wb]
|
||||||
|
@ -39,26 +39,26 @@
|
||||||
params {:family (read-string value)
|
params {:family (read-string value)
|
||||||
:weight "normal"
|
:weight "normal"
|
||||||
:style "normal"}]
|
:style "normal"}]
|
||||||
(rs/emit! (uds/update-font-attrs sid params))))
|
(st/emit! (uds/update-font-attrs sid params))))
|
||||||
(on-font-size-change [event]
|
(on-font-size-change [event]
|
||||||
(let [value (dom/event->value event)
|
(let [value (dom/event->value event)
|
||||||
params {:size (parse-int value)}
|
params {:size (parse-int value)}
|
||||||
sid (:id shape)]
|
sid (:id shape)]
|
||||||
(rs/emit! (uds/update-font-attrs sid params))))
|
(st/emit! (uds/update-font-attrs sid params))))
|
||||||
(on-font-letter-spacing-change [event]
|
(on-font-letter-spacing-change [event]
|
||||||
(let [value (dom/event->value event)
|
(let [value (dom/event->value event)
|
||||||
params {:letter-spacing (parse-float value)}
|
params {:letter-spacing (parse-float value)}
|
||||||
sid (:id shape)]
|
sid (:id shape)]
|
||||||
(rs/emit! (uds/update-font-attrs sid params))))
|
(st/emit! (uds/update-font-attrs sid params))))
|
||||||
(on-font-line-height-change [event]
|
(on-font-line-height-change [event]
|
||||||
(let [value (dom/event->value event)
|
(let [value (dom/event->value event)
|
||||||
params {:line-height (parse-float value)}
|
params {:line-height (parse-float value)}
|
||||||
sid (:id shape)]
|
sid (:id shape)]
|
||||||
(rs/emit! (uds/update-font-attrs sid params))))
|
(st/emit! (uds/update-font-attrs sid params))))
|
||||||
(on-font-align-change [event value]
|
(on-font-align-change [event value]
|
||||||
(let [params {:align value}
|
(let [params {:align value}
|
||||||
sid (:id shape)]
|
sid (:id shape)]
|
||||||
(rs/emit! (uds/update-font-attrs sid params))))
|
(st/emit! (uds/update-font-attrs sid params))))
|
||||||
|
|
||||||
(on-font-style-change [event]
|
(on-font-style-change [event]
|
||||||
(let [value (dom/event->value event)
|
(let [value (dom/event->value event)
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
sid (:id shape)
|
sid (:id shape)
|
||||||
params {:style style
|
params {:style style
|
||||||
:weight weight}]
|
:weight weight}]
|
||||||
(rs/emit! (uds/update-font-attrs sid params))))]
|
(st/emit! (uds/update-font-attrs sid params))))]
|
||||||
(let [{:keys [family style weight size align line-height letter-spacing]
|
(let [{:keys [family style weight size align line-height letter-spacing]
|
||||||
:or {family "sourcesanspro"
|
:or {family "sourcesanspro"
|
||||||
align "left"
|
align "left"
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.projects :as dp]
|
[uxbox.main.data.projects :as dp]
|
||||||
[uxbox.main.data.pages :as udp]
|
[uxbox.main.data.pages :as udp]
|
||||||
[uxbox.main.data.workspace :as dw]
|
[uxbox.main.data.workspace :as dw]
|
||||||
|
@ -45,11 +45,11 @@
|
||||||
(udl/open! :page-form {:page page}))
|
(udl/open! :page-form {:page page}))
|
||||||
|
|
||||||
(on-navigate [event]
|
(on-navigate [event]
|
||||||
(rs/emit! (dp/go-to (:project page) (:id page))))
|
(st/emit! (dp/go-to (:project page) (:id page))))
|
||||||
|
|
||||||
(delete []
|
(delete []
|
||||||
(let [next #(rs/emit! (dp/go-to (:project page)))]
|
(let [next #(st/emit! (dp/go-to (:project page)))]
|
||||||
(rs/emit! (udp/delete-page (:id page) next))))
|
(st/emit! (udp/delete-page (:id page) next))))
|
||||||
|
|
||||||
(on-delete [event]
|
(on-delete [event]
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
|
@ -71,7 +71,7 @@
|
||||||
pages (mx/react pages-ref)
|
pages (mx/react pages-ref)
|
||||||
current (mx/react wb/page-ref)
|
current (mx/react wb/page-ref)
|
||||||
create #(udl/open! :page-form {:page {:project (:id project)}})
|
create #(udl/open! :page-form {:page {:project (:id project)}})
|
||||||
close #(rs/emit! (dw/toggle-flag :sitemap))]
|
close #(st/emit! (dw/toggle-flag :sitemap))]
|
||||||
[:div.sitemap.tool-window
|
[:div.sitemap.tool-window
|
||||||
[:div.tool-window-bar
|
[:div.tool-window-bar
|
||||||
[:div.tool-window-icon i/project-tree]
|
[:div.tool-window-icon i/project-tree]
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
(ns uxbox.main.ui.workspace.sidebar.sitemap-pageform
|
(ns uxbox.main.ui.workspace.sidebar.sitemap-pageform
|
||||||
(:require [lentes.core :as l]
|
(:require [lentes.core :as l]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.data.pages :as udp]
|
[uxbox.main.data.pages :as udp]
|
||||||
[uxbox.main.data.workspace :as dw]
|
[uxbox.main.data.workspace :as dw]
|
||||||
[uxbox.main.data.lightbox :as udl]
|
[uxbox.main.data.lightbox :as udl]
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
[uxbox.main.ui.lightbox :as lbx]
|
[uxbox.main.ui.lightbox :as lbx]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.forms :as forms]
|
[uxbox.util.forms :as forms]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.data :refer (deep-merge parse-int)]
|
[uxbox.util.data :refer (deep-merge parse-int)]
|
||||||
|
@ -81,8 +81,8 @@
|
||||||
(dom/prevent-default e)
|
(dom/prevent-default e)
|
||||||
(udl/close!)
|
(udl/close!)
|
||||||
(if (nil? id)
|
(if (nil? id)
|
||||||
(rs/emit! (udp/create-page data))
|
(st/emit! (udp/create-page data))
|
||||||
(rs/emit! (udp/update-page id data))))]
|
(st/emit! (udp/update-page id data))))]
|
||||||
[:form
|
[:form
|
||||||
[:input#project-name.input-text
|
[:input#project-name.input-text
|
||||||
{:placeholder "Page name"
|
{:placeholder "Page name"
|
||||||
|
|
35
frontend/src/uxbox/store.cljs
Normal file
35
frontend/src/uxbox/store.cljs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
;;
|
||||||
|
;; Copyright (c) 2015-2016 Andrey Antukh <niwi@niwi.nz>
|
||||||
|
|
||||||
|
(ns uxbox.store
|
||||||
|
(:require [beicon.core :as rx]
|
||||||
|
[lentes.core :as l]
|
||||||
|
[potok.core :as ptk]))
|
||||||
|
|
||||||
|
(enable-console-print!)
|
||||||
|
|
||||||
|
(def ^:dynamic *on-error* identity)
|
||||||
|
|
||||||
|
(defonce state (atom {}))
|
||||||
|
(defonce loader (atom false))
|
||||||
|
(defonce store (ptk/store {:on-error #(*on-error* %)}))
|
||||||
|
|
||||||
|
(def auth-ref
|
||||||
|
(-> (l/key :auth)
|
||||||
|
(l/derive state)))
|
||||||
|
|
||||||
|
(defn emit!
|
||||||
|
([event]
|
||||||
|
(ptk/emit! store event))
|
||||||
|
([event & events]
|
||||||
|
(apply ptk/emit! store (cons event events))))
|
||||||
|
|
||||||
|
(defn init
|
||||||
|
"Initialize the state materialization."
|
||||||
|
[initial-state]
|
||||||
|
(let [istate (if (fn? initial-state) (initial-state) initial-state)]
|
||||||
|
(emit! (constantly istate))
|
||||||
|
(rx/to-atom store state)))
|
|
@ -7,10 +7,11 @@
|
||||||
|
|
||||||
(ns uxbox.util.forms
|
(ns uxbox.util.forms
|
||||||
(:refer-clojure :exclude [keyword uuid vector boolean map set])
|
(:refer-clojure :exclude [keyword uuid vector boolean map set])
|
||||||
(:require [struct.core :as st]
|
(:require [struct.core :as f]
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
|
[uxbox.store :as st]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.i18n :refer (tr)]))
|
[uxbox.util.i18n :refer (tr)]))
|
||||||
|
|
||||||
|
@ -21,35 +22,35 @@
|
||||||
;; --- Form Validators
|
;; --- Form Validators
|
||||||
|
|
||||||
(def required
|
(def required
|
||||||
(assoc st/required :message "errors.form.required"))
|
(assoc f/required :message "errors.form.required"))
|
||||||
|
|
||||||
(def string
|
(def string
|
||||||
(assoc st/string :message "errors.form.string"))
|
(assoc f/string :message "errors.form.string"))
|
||||||
|
|
||||||
(def number
|
(def number
|
||||||
(assoc st/number :message "errors.form.number"))
|
(assoc f/number :message "errors.form.number"))
|
||||||
|
|
||||||
(def integer
|
(def integer
|
||||||
(assoc st/integer :message "errors.form.integer"))
|
(assoc f/integer :message "errors.form.integer"))
|
||||||
|
|
||||||
(def boolean
|
(def boolean
|
||||||
(assoc st/boolean :message "errors.form.bool"))
|
(assoc f/boolean :message "errors.form.bool"))
|
||||||
|
|
||||||
(def identical-to
|
(def identical-to
|
||||||
(assoc st/identical-to :message "errors.form.identical-to"))
|
(assoc f/identical-to :message "errors.form.identical-to"))
|
||||||
|
|
||||||
(def in-range st/in-range)
|
(def in-range f/in-range)
|
||||||
;; (def uuid-like st/uuid-like)
|
;; (def uuid-like f/uuid-like)
|
||||||
(def uuid st/uuid)
|
(def uuid f/uuid)
|
||||||
(def keyword st/keyword)
|
(def keyword f/keyword)
|
||||||
(def integer-str st/integer-str)
|
(def integer-str f/integer-str)
|
||||||
(def number-str st/number-str)
|
(def number-str f/number-str)
|
||||||
;; (def boolean-like st/boolean-like)
|
;; (def boolean-like f/boolean-like)
|
||||||
(def email st/email)
|
(def email f/email)
|
||||||
;; (def function st/function)
|
;; (def function f/function)
|
||||||
(def positive st/positive)
|
(def positive f/positive)
|
||||||
;; (def validate st/validate)
|
;; (def validate f/validate)
|
||||||
;; (def validate! st/validate!)
|
;; (def validate! f/validate!)
|
||||||
|
|
||||||
(def max-len
|
(def max-len
|
||||||
{:message "errors.form.max-len"
|
{:message "errors.form.max-len"
|
||||||
|
@ -75,7 +76,7 @@
|
||||||
([data schema]
|
([data schema]
|
||||||
(validate data schema nil))
|
(validate data schema nil))
|
||||||
([data schema opts]
|
([data schema opts]
|
||||||
(st/validate data schema opts)))
|
(f/validate data schema opts)))
|
||||||
|
|
||||||
(defn validate!
|
(defn validate!
|
||||||
([data schema]
|
([data schema]
|
||||||
|
@ -98,8 +99,8 @@
|
||||||
;; --- Set Error
|
;; --- Set Error
|
||||||
|
|
||||||
(defrecord SetError [type field error]
|
(defrecord SetError [type field error]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:errors type field] error)))
|
(assoc-in state [:errors type field] error)))
|
||||||
|
|
||||||
(defn set-error
|
(defn set-error
|
||||||
|
@ -113,13 +114,13 @@
|
||||||
|
|
||||||
(defn set-error!
|
(defn set-error!
|
||||||
[& args]
|
[& args]
|
||||||
(rs/emit! (apply set-error args)))
|
(st/emit! (apply set-error args)))
|
||||||
|
|
||||||
;; --- Set Errors
|
;; --- Set Errors
|
||||||
|
|
||||||
(defrecord SetErrors [type errors]
|
(defrecord SetErrors [type errors]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:errors type] errors)))
|
(assoc-in state [:errors type] errors)))
|
||||||
|
|
||||||
(defn set-errors
|
(defn set-errors
|
||||||
|
@ -133,13 +134,13 @@
|
||||||
|
|
||||||
(defn set-errors!
|
(defn set-errors!
|
||||||
[& args]
|
[& args]
|
||||||
(rs/emit! (apply set-errors args)))
|
(st/emit! (apply set-errors args)))
|
||||||
|
|
||||||
;; --- Set Value
|
;; --- Set Value
|
||||||
|
|
||||||
(defrecord SetValue [type field value]
|
(defrecord SetValue [type field value]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [form-path (into [:forms type] (if (coll? field) field [field]))
|
(let [form-path (into [:forms type] (if (coll? field) field [field]))
|
||||||
errors-path (into [:errors type] (if (coll? field) field [field]))]
|
errors-path (into [:errors type] (if (coll? field) field [field]))]
|
||||||
(-> state
|
(-> state
|
||||||
|
@ -155,13 +156,13 @@
|
||||||
|
|
||||||
(defn set-value!
|
(defn set-value!
|
||||||
[type field value]
|
[type field value]
|
||||||
(rs/emit! (set-value type field value)))
|
(st/emit! (set-value type field value)))
|
||||||
|
|
||||||
;; --- Validate Form
|
;; --- Validate Form
|
||||||
|
|
||||||
;; (defrecord ValidateForm [type form data on-success]
|
;; (defrecord ValidateForm [type form data on-success]
|
||||||
;; rs/WatchEvent
|
;; ptk/WatchEvent
|
||||||
;; (-apply-watch [_ state stream]
|
;; (watch [_ state stream]
|
||||||
;; (let [[errors data] (validate data form)]
|
;; (let [[errors data] (validate data form)]
|
||||||
;; (if errors
|
;; (if errors
|
||||||
;; (rx/of (set-errors type errors))
|
;; (rx/of (set-errors type errors))
|
||||||
|
@ -179,13 +180,13 @@
|
||||||
|
|
||||||
;; (defn validate-form!
|
;; (defn validate-form!
|
||||||
;; [& args]
|
;; [& args]
|
||||||
;; (rs/emit! (apply validate-form args)))
|
;; (f/emit! (apply validate-form args)))
|
||||||
|
|
||||||
;; --- Clear Form
|
;; --- Clear Form
|
||||||
|
|
||||||
(defrecord ClearForm [type]
|
(defrecord ClearForm [type]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:forms type] nil)))
|
(assoc-in state [:forms type] nil)))
|
||||||
|
|
||||||
(defn clear-form
|
(defn clear-form
|
||||||
|
@ -195,13 +196,13 @@
|
||||||
|
|
||||||
(defn clear-form!
|
(defn clear-form!
|
||||||
[type]
|
[type]
|
||||||
(rs/emit! (clear-form type)))
|
(st/emit! (clear-form type)))
|
||||||
|
|
||||||
;; --- Clear Form
|
;; --- Clear Form
|
||||||
|
|
||||||
(defrecord ClearErrors [type]
|
(defrecord ClearErrors [type]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:errors type] nil)))
|
(assoc-in state [:errors type] nil)))
|
||||||
|
|
||||||
(defn clear-errors
|
(defn clear-errors
|
||||||
|
@ -211,13 +212,13 @@
|
||||||
|
|
||||||
(defn clear-errors!
|
(defn clear-errors!
|
||||||
[type]
|
[type]
|
||||||
(rs/emit! (clear-errors type)))
|
(st/emit! (clear-errors type)))
|
||||||
|
|
||||||
;; --- Clear
|
;; --- Clear
|
||||||
|
|
||||||
(defrecord Clear [type]
|
(defrecord Clear [type]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(rx/of (clear-form type)
|
(rx/of (clear-form type)
|
||||||
(clear-errors type))))
|
(clear-errors type))))
|
||||||
|
|
||||||
|
@ -227,7 +228,7 @@
|
||||||
|
|
||||||
(defn clear!
|
(defn clear!
|
||||||
[type]
|
[type]
|
||||||
(rs/emit! (clear type)))
|
(st/emit! (clear type)))
|
||||||
|
|
||||||
;; --- Helpers
|
;; --- Helpers
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
(ns uxbox.util.router
|
(ns uxbox.util.router
|
||||||
(:require [bide.core :as r]
|
(:require [bide.core :as r]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[uxbox.util.rstore :as rs]))
|
[potok.core :as ptk]
|
||||||
|
[uxbox.store :as st]))
|
||||||
|
|
||||||
(enable-console-print!)
|
(enable-console-print!)
|
||||||
|
|
||||||
|
@ -17,8 +18,8 @@
|
||||||
;; --- Update Location (Event)
|
;; --- Update Location (Event)
|
||||||
|
|
||||||
(defrecord UpdateLocation [id params]
|
(defrecord UpdateLocation [id params]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [route (merge {:id id}
|
(let [route (merge {:id id}
|
||||||
(when params
|
(when params
|
||||||
{:params params}))]
|
{:params params}))]
|
||||||
|
@ -35,8 +36,8 @@
|
||||||
;; --- Navigate (Event)
|
;; --- Navigate (Event)
|
||||||
|
|
||||||
(defrecord Navigate [id params]
|
(defrecord Navigate [id params]
|
||||||
rs/EffectEvent
|
ptk/EffectEvent
|
||||||
(-apply-effect [_ state]
|
(effect [_ state stream]
|
||||||
(r/navigate! +router+ id params)))
|
(r/navigate! +router+ id params)))
|
||||||
|
|
||||||
(defn navigate
|
(defn navigate
|
||||||
|
@ -51,7 +52,7 @@
|
||||||
([routes]
|
([routes]
|
||||||
(init routes nil))
|
(init routes nil))
|
||||||
([routes {:keys [default] :or {default :auth/login}}]
|
([routes {:keys [default] :or {default :auth/login}}]
|
||||||
(let [opts {:on-navigate #(rs/emit! (update-location %1 %2))
|
(let [opts {:on-navigate #(st/emit! (update-location %1 %2))
|
||||||
:default default}
|
:default default}
|
||||||
router (-> (r/router routes)
|
router (-> (r/router routes)
|
||||||
(r/start! opts))]
|
(r/start! opts))]
|
||||||
|
@ -62,7 +63,7 @@
|
||||||
"Redirect the user to other url."
|
"Redirect the user to other url."
|
||||||
([id] (go id nil))
|
([id] (go id nil))
|
||||||
([id params]
|
([id params]
|
||||||
(rs/emit! (navigate id params))))
|
(st/emit! (navigate id params))))
|
||||||
|
|
||||||
(defn route-for
|
(defn route-for
|
||||||
"Given a location handler and optional parameter map, return the URI
|
"Given a location handler and optional parameter map, return the URI
|
||||||
|
|
|
@ -1,115 +0,0 @@
|
||||||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
;;
|
|
||||||
;; Copyright (c) 2015-2016 Andrey Antukh <niwi@niwi.nz>
|
|
||||||
;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com>
|
|
||||||
|
|
||||||
(ns uxbox.util.rstore
|
|
||||||
"Reactive storage management architecture helpers."
|
|
||||||
(:require [beicon.core :as rx]))
|
|
||||||
|
|
||||||
;; An abstraction for implement a simple state
|
|
||||||
;; transition. The `-apply-update` function receives
|
|
||||||
;; the state and shoudl return the transformed state.
|
|
||||||
|
|
||||||
(defprotocol UpdateEvent
|
|
||||||
(-apply-update [event state]))
|
|
||||||
|
|
||||||
;; An abstraction for perform some async stuff such
|
|
||||||
;; as communicate with api rest or other resources
|
|
||||||
;; that implies asynchronous access.
|
|
||||||
;; The `-apply-watch` receives the state and should
|
|
||||||
;; return a reactive stream of events (that can be
|
|
||||||
;; of `UpdateEvent`, `WatchEvent` or `EffectEvent`.
|
|
||||||
|
|
||||||
(defprotocol WatchEvent
|
|
||||||
(-apply-watch [event state s]))
|
|
||||||
|
|
||||||
;; An abstraction for perform just side effects. It
|
|
||||||
;; receives state and its return value is completly
|
|
||||||
;; ignored.
|
|
||||||
|
|
||||||
(defprotocol EffectEvent
|
|
||||||
(-apply-effect [event state]))
|
|
||||||
|
|
||||||
(defn update?
|
|
||||||
"Return `true` when `e` satisfies
|
|
||||||
the UpdateEvent protocol."
|
|
||||||
[e]
|
|
||||||
(satisfies? UpdateEvent e))
|
|
||||||
|
|
||||||
(defn watch?
|
|
||||||
"Return `true` when `e` satisfies
|
|
||||||
the WatchEvent protocol."
|
|
||||||
[e]
|
|
||||||
(satisfies? WatchEvent e))
|
|
||||||
|
|
||||||
(defn effect?
|
|
||||||
"Return `true` when `e` satisfies
|
|
||||||
the EffectEvent protocol."
|
|
||||||
[e]
|
|
||||||
(satisfies? EffectEvent e))
|
|
||||||
|
|
||||||
(extend-protocol UpdateEvent
|
|
||||||
function
|
|
||||||
(-apply-update [func state]
|
|
||||||
(func state)))
|
|
||||||
|
|
||||||
(defonce ^:private bus (rx/bus))
|
|
||||||
(defonce stream (rx/map identity bus))
|
|
||||||
|
|
||||||
(defn emit!
|
|
||||||
"Emits an event or a collection of them."
|
|
||||||
([event]
|
|
||||||
(rx/push! bus event))
|
|
||||||
([event & events]
|
|
||||||
(run! emit! (cons event events))))
|
|
||||||
|
|
||||||
(defonce ^:private error-handlers
|
|
||||||
(atom {}))
|
|
||||||
|
|
||||||
(defn add-error-watcher
|
|
||||||
[key callable]
|
|
||||||
(swap! error-handlers assoc key callable))
|
|
||||||
|
|
||||||
(defn remove-error-watcher
|
|
||||||
[key]
|
|
||||||
(swap! error-handlers dissoc key))
|
|
||||||
|
|
||||||
(defn- on-error
|
|
||||||
[error]
|
|
||||||
(doseq [[key value] @error-handlers]
|
|
||||||
(value error))
|
|
||||||
(throw error))
|
|
||||||
|
|
||||||
(defn init
|
|
||||||
"Initializes the stream event loop and
|
|
||||||
return a stream with model changes."
|
|
||||||
[state]
|
|
||||||
(let [watch-s (rx/filter watch? stream)
|
|
||||||
effect-s (rx/filter effect? stream)
|
|
||||||
update-s (rx/filter update? stream)
|
|
||||||
state-s (->> update-s
|
|
||||||
(rx/scan #(-apply-update %2 %1) state)
|
|
||||||
(rx/catch on-error)
|
|
||||||
(rx/retry 1024)
|
|
||||||
(rx/share))]
|
|
||||||
|
|
||||||
;; Process event sources: combine with the latest model and the result will be
|
|
||||||
;; pushed to the event-stream bus
|
|
||||||
(as-> watch-s $
|
|
||||||
(rx/with-latest-from vector state-s $)
|
|
||||||
(rx/flat-map (fn [[event model]] (-apply-watch event model stream)) $)
|
|
||||||
(rx/catch on-error $)
|
|
||||||
(rx/retry 1024 $)
|
|
||||||
(rx/on-value $ emit!))
|
|
||||||
|
|
||||||
;; Process effects: combine with the latest model to process the new effect
|
|
||||||
(as-> effect-s $
|
|
||||||
(rx/with-latest-from vector state-s $)
|
|
||||||
(rx/subscribe $ (fn [[event model]] (-apply-effect event model))))
|
|
||||||
|
|
||||||
;; Initialize the stream machinary with initial state.
|
|
||||||
(emit! #(merge % state))
|
|
||||||
state-s))
|
|
|
@ -6,10 +6,10 @@
|
||||||
|
|
||||||
(ns uxbox.view
|
(ns uxbox.view
|
||||||
(:require [uxbox.config]
|
(:require [uxbox.config]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.view.ui :as ui]))
|
[uxbox.view.ui :as ui]))
|
||||||
|
|
||||||
(defn initial-state
|
(defn- initial-state
|
||||||
[]
|
[]
|
||||||
{:route nil
|
{:route nil
|
||||||
:project nil
|
:project nil
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
(ns uxbox.view.data.viewer
|
(ns uxbox.view.data.viewer
|
||||||
(:require [beicon.core :as rx]
|
(:require [beicon.core :as rx]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.router :as rt]
|
[uxbox.util.router :as rt]
|
||||||
[uxbox.util.forms :as sc]
|
[uxbox.util.forms :as sc]
|
||||||
[uxbox.util.data :refer (parse-int)]
|
[uxbox.util.data :refer (parse-int)]
|
||||||
|
@ -19,8 +19,8 @@
|
||||||
(declare load-data)
|
(declare load-data)
|
||||||
|
|
||||||
(defrecord Initialize [token]
|
(defrecord Initialize [token]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(watch [_ state s]
|
||||||
(rx/of (load-data token))))
|
(rx/of (load-data token))))
|
||||||
|
|
||||||
(defn initialize
|
(defn initialize
|
||||||
|
@ -44,8 +44,8 @@
|
||||||
(update :pages conj page))))
|
(update :pages conj page))))
|
||||||
|
|
||||||
(defrecord DataLoaded [data]
|
(defrecord DataLoaded [data]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [project (dissoc data :pages)
|
(let [project (dissoc data :pages)
|
||||||
pages (sort-by :created-at (:pages data))]
|
pages (sort-by :created-at (:pages data))]
|
||||||
(as-> state $
|
(as-> state $
|
||||||
|
@ -60,8 +60,8 @@
|
||||||
;; --- Load Data
|
;; --- Load Data
|
||||||
|
|
||||||
(defrecord LoadData [token]
|
(defrecord LoadData [token]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(->> (rp/req :fetch/project-by-token token)
|
(->> (rp/req :fetch/project-by-token token)
|
||||||
(rx/map :payload)
|
(rx/map :payload)
|
||||||
(rx/map data-loaded))))
|
(rx/map data-loaded))))
|
||||||
|
@ -73,8 +73,8 @@
|
||||||
;; --- Select Page
|
;; --- Select Page
|
||||||
|
|
||||||
(defrecord SelectPage [index]
|
(defrecord SelectPage [index]
|
||||||
rs/WatchEvent
|
ptk/WatchEvent
|
||||||
(-apply-watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [token (get-in state [:route :params :token])]
|
(let [token (get-in state [:route :params :token])]
|
||||||
(rx/of (rt/navigate :view/viewer {:token token :id index})))))
|
(rx/of (rt/navigate :view/viewer {:token token :id index})))))
|
||||||
|
|
||||||
|
@ -85,8 +85,8 @@
|
||||||
;; --- Toggle Flag
|
;; --- Toggle Flag
|
||||||
|
|
||||||
(defrecord ToggleFlag [key]
|
(defrecord ToggleFlag [key]
|
||||||
rs/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(update [_ state]
|
||||||
(let [flags (:flags state #{})]
|
(let [flags (:flags state #{})]
|
||||||
(if (contains? flags key)
|
(if (contains? flags key)
|
||||||
(assoc state :flags (disj flags key))
|
(assoc state :flags (disj flags key))
|
||||||
|
|
|
@ -7,17 +7,18 @@
|
||||||
(ns uxbox.view.ui
|
(ns uxbox.view.ui
|
||||||
(:require [lentes.core :as l]
|
(:require [lentes.core :as l]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.router :as rt]
|
[uxbox.store :as st]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.main.data.messages :as dmsg]
|
||||||
[uxbox.util.dom :as dom]
|
|
||||||
[uxbox.main.ui.loader :refer (loader)]
|
[uxbox.main.ui.loader :refer (loader)]
|
||||||
[uxbox.main.ui.lightbox :refer (lightbox)]
|
[uxbox.main.ui.lightbox :refer (lightbox)]
|
||||||
[uxbox.main.state :as st]
|
|
||||||
[uxbox.main.data.messages :as dmsg]
|
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
[uxbox.view.ui.notfound :refer (notfound-page)]
|
[uxbox.view.ui.notfound :refer (notfound-page)]
|
||||||
[uxbox.view.ui.viewer :refer (viewer-page)]))
|
[uxbox.view.ui.viewer :refer (viewer-page)]
|
||||||
|
[uxbox.util.router :as rt]
|
||||||
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
|
[uxbox.util.dom :as dom]))
|
||||||
|
|
||||||
|
|
||||||
(def route-id-ref
|
(def route-id-ref
|
||||||
(-> (l/in [:route :id])
|
(-> (l/in [:route :id])
|
||||||
|
@ -39,7 +40,7 @@
|
||||||
(dmsg/error! (tr "errors.generic"))
|
(dmsg/error! (tr "errors.generic"))
|
||||||
(js/console.error "Stack:" (.-stack error)))))
|
(js/console.error "Stack:" (.-stack error)))))
|
||||||
|
|
||||||
(rs/add-error-watcher :ui on-error)
|
(set! st/*on-error* on-error)
|
||||||
|
|
||||||
;; --- Main App (Component)
|
;; --- Main App (Component)
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
(ns uxbox.view.ui.viewer
|
(ns uxbox.view.ui.viewer
|
||||||
(:require [lentes.core :as l]
|
(:require [lentes.core :as l]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.router :as rt]
|
[uxbox.util.router :as rt]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.view.data.viewer :as dv]
|
[uxbox.view.data.viewer :as dv]
|
||||||
[uxbox.view.ui.viewer.nav :refer (nav)]
|
[uxbox.view.ui.viewer.nav :refer (nav)]
|
||||||
[uxbox.view.ui.viewer.canvas :refer (canvas)]
|
[uxbox.view.ui.viewer.canvas :refer (canvas)]
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
(defn- viewer-page-will-mount
|
(defn- viewer-page-will-mount
|
||||||
[own]
|
[own]
|
||||||
(letfn [(on-change [token]
|
(letfn [(on-change [token]
|
||||||
(rs/emit! (dv/initialize token)))]
|
(st/emit! (dv/initialize token)))]
|
||||||
(add-watch token-ref ::wkey #(on-change %4))
|
(add-watch token-ref ::wkey #(on-change %4))
|
||||||
(on-change @token-ref)
|
(on-change @token-ref)
|
||||||
own))
|
own))
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.data :refer (parse-int)]
|
[uxbox.util.data :refer (parse-int)]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.ui.shapes :as uus]
|
[uxbox.main.ui.shapes :as uus]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
[uxbox.view.ui.viewer.shapes :as shapes]))
|
[uxbox.view.ui.viewer.shapes :as shapes]))
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
|
|
||||||
(ns uxbox.view.ui.viewer.interactions
|
(ns uxbox.view.ui.viewer.interactions
|
||||||
(:require [uxbox.util.dom :as dom]
|
(:require [uxbox.util.dom :as dom]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.geom.matrix :as gmt]
|
[uxbox.util.geom.matrix :as gmt]
|
||||||
[uxbox.util.geom.point :as gpt]
|
[uxbox.util.geom.point :as gpt]
|
||||||
[uxbox.util.timers :as ts]
|
[uxbox.util.timers :as ts]
|
||||||
[uxbox.main.geom :as geom]
|
[uxbox.main.geom :as geom]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.view.data.viewer :as dv]
|
[uxbox.view.data.viewer :as dv]
|
||||||
[vendor.snapsvg])
|
[vendor.snapsvg])
|
||||||
;; Documentation about available events:
|
;; Documentation about available events:
|
||||||
|
@ -145,7 +145,7 @@
|
||||||
|
|
||||||
(defn- run-gotopage-interaction
|
(defn- run-gotopage-interaction
|
||||||
[{:keys [page]}]
|
[{:keys [page]}]
|
||||||
(rs/emit! (dv/select-page page)))
|
(st/emit! (dv/select-page page)))
|
||||||
|
|
||||||
(defn- run-color-interaction
|
(defn- run-color-interaction
|
||||||
[{:keys [element fill-color stroke-color direction easing delay duration]}]
|
[{:keys [element fill-color stroke-color direction easing delay duration]}]
|
||||||
|
|
|
@ -7,14 +7,15 @@
|
||||||
|
|
||||||
(ns uxbox.view.ui.viewer.nav
|
(ns uxbox.view.ui.viewer.nav
|
||||||
(:require [uxbox.util.mixins :as mx :include-macros true]
|
(:require [uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
|
[uxbox.store :as st]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
[uxbox.view.data.viewer :as dv]))
|
[uxbox.view.data.viewer :as dv]))
|
||||||
|
|
||||||
(mx/defc nav
|
(mx/defc nav
|
||||||
[flags]
|
[flags]
|
||||||
(let [toggle-sitemap #(rs/emit! (dv/toggle-flag :sitemap))
|
(let [toggle-sitemap #(st/emit! (dv/toggle-flag :sitemap))
|
||||||
toggle-interactions #(rs/emit! (dv/toggle-flag :interactions))
|
toggle-interactions #(st/emit! (dv/toggle-flag :interactions))
|
||||||
sitemap? (contains? flags :sitemap)
|
sitemap? (contains? flags :sitemap)
|
||||||
interactions? (contains? flags :interactions)]
|
interactions? (contains? flags :interactions)]
|
||||||
[:div.view-nav
|
[:div.view-nav
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
(:require [goog.events :as events]
|
(:require [goog.events :as events]
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.geom :as geom]
|
[uxbox.main.geom :as geom]
|
||||||
[uxbox.main.ui.shapes.rect :refer (rect-shape)]
|
[uxbox.main.ui.shapes.rect :refer (rect-shape)]
|
||||||
[uxbox.main.ui.shapes.icon :refer (icon-shape)]
|
[uxbox.main.ui.shapes.icon :refer (icon-shape)]
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.mixins :as mx :include-macros true]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.data :refer (parse-int)]
|
[uxbox.util.data :refer (parse-int)]
|
||||||
[uxbox.util.rstore :as rs]
|
[potok.core :as ptk]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.store :as st]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
[uxbox.view.data.viewer :as dv]))
|
[uxbox.view.data.viewer :as dv]))
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
(let [project-name (mx/react project-name-ref)
|
(let [project-name (mx/react project-name-ref)
|
||||||
pages (mx/react pages-ref)
|
pages (mx/react pages-ref)
|
||||||
selected (mx/react selected-ref)
|
selected (mx/react selected-ref)
|
||||||
on-click #(rs/emit! (dv/select-page %))]
|
on-click #(st/emit! (dv/select-page %))]
|
||||||
[:div.view-sitemap
|
[:div.view-sitemap
|
||||||
[:span.sitemap-title project-name]
|
[:span.sitemap-title project-name]
|
||||||
[:ul.sitemap-list
|
[:ul.sitemap-list
|
||||||
|
|
Loading…
Add table
Reference in a new issue