diff --git a/src/uxbox/data/workspace.cljs b/src/uxbox/data/workspace.cljs index 05e62ea7be..a6130f3653 100644 --- a/src/uxbox/data/workspace.cljs +++ b/src/uxbox/data/workspace.cljs @@ -254,16 +254,36 @@ (assoc-in state [:shapes-by-id sid] (assoc shape :hidden false)) (assoc-in state [:shapes-by-id sid] (assoc shape :hidden true))))))) -(defn toggle-shape-blocking + +(defn block-shape [sid] (reify rs/UpdateEvent (-apply-update [_ state] - (let [shape (get-in state [:shapes-by-id sid]) - blocked? (:blocked shape false)] - (if blocked? - (assoc-in state [:shapes-by-id sid] (assoc shape :blocked false)) - (assoc-in state [:shapes-by-id sid] (assoc shape :blocked true))))))) + (assoc-in state [:shapes-by-id sid :blocked] true)) + + rs/WatchEvent + (-apply-watch [_ state] + (let [shape (get-in state [:shapes-by-id sid])] + (if-not (= (:type shape) :builtin/group) + (rx/empty) + (rx/from-coll + (map block-shape (:items shape)))))))) + +(defn unblock-shape + [sid] + (reify + rs/UpdateEvent + (-apply-update [_ state] + (assoc-in state [:shapes-by-id sid :blocked] false)) + + rs/WatchEvent + (-apply-watch [_ state] + (let [shape (get-in state [:shapes-by-id sid])] + (if-not (= (:type shape) :builtin/group) + (rx/empty) + (rx/from-coll + (map unblock-shape (:items shape)))))))) (defn toggle-shape-locking [sid] diff --git a/src/uxbox/ui/workspace/toolboxes/layers.cljs b/src/uxbox/ui/workspace/toolboxes/layers.cljs index afa3a3a540..80222b3a35 100644 --- a/src/uxbox/ui/workspace/toolboxes/layers.cljs +++ b/src/uxbox/ui/workspace/toolboxes/layers.cljs @@ -61,8 +61,11 @@ (defn- toggle-blocking [item event] (dom/stop-propagation event) - (let [id (:id item)] - (rs/emit! (dw/toggle-shape-blocking id)))) + (let [id (:id item) + blocked? (:blocked item)] + (if blocked? + (rs/emit! (dw/unblock-shape id)) + (rs/emit! (dw/block-shape id))))) (defn- toggle-locking [item event]