From bc756337cd68678e91975312e7e4309d65c5ab76 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 28 Jan 2016 20:22:09 +0200 Subject: [PATCH] Move the shape initialization out of add-shape event. --- src/uxbox/data/workspace.cljs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/uxbox/data/workspace.cljs b/src/uxbox/data/workspace.cljs index 3e5032027..1fa9a00bb 100644 --- a/src/uxbox/data/workspace.cljs +++ b/src/uxbox/data/workspace.cljs @@ -14,12 +14,6 @@ ;; Schemas ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(def ^:static +shape-props-schema+ - {:x [v/integer] - :y [v/integer] - :width [v/integer] - :height [v/integer]}) - (def ^:static +shape-schema+ {:x [v/integer] :y [v/integer] @@ -41,8 +35,10 @@ :opacity [v/number]}) (def ^:static +shape-update-position-schema+ - {:x [v/integer] - :y [v/integer]}) + {:x1 [v/integer] + :y1 [v/integer] + :x2 [v/integer] + :y2 [v/integer]}) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Events (explicit) @@ -125,16 +121,14 @@ (defn add-shape "Create and add shape to the current selected page." - [shape props] + [shape] (sc/validate! +shape-schema+ shape) - (sc/validate! +shape-props-schema+ props) (reify rs/UpdateEvent (-apply-update [_ state] (let [sid (random-uuid) pid (get-in state [:workspace :page]) - shape (merge (sh/-initialize shape props) - shape {:id sid :page pid})] + shape (merge shape {:id sid :page pid})] (as-> state $ (update-in $ [:pages-by-id pid :shapes] conj sid) (assoc-in $ [:shapes-by-id sid] shape))))))