diff --git a/frontend/src/uxbox/main/data/workspace.cljs b/frontend/src/uxbox/main/data/workspace.cljs index 603572e25..140967b34 100644 --- a/frontend/src/uxbox/main/data/workspace.cljs +++ b/frontend/src/uxbox/main/data/workspace.cljs @@ -1757,6 +1757,7 @@ [id] (us/verify ::us/uuid id) (ptk/reify ::hide-shape + IBatchedChange ptk/UpdateEvent (update [_ state] (impl-update-shape-hidden state id true)))) @@ -1764,24 +1765,41 @@ (defn show-shape [id] (us/verify ::us/uuid id) - (ptk/reify ::hide-shape + (ptk/reify ::show-shape + IBatchedChange ptk/UpdateEvent (update [_ state] (impl-update-shape-hidden state id false)))) +(defn hide-canvas + [id] + (us/verify ::us/uuid id) + (ptk/reify ::hide-shape + IBatchedChange + ptk/UpdateEvent + (update [_ state] + (let [hide #(impl-update-shape-hidden %1 %2 true) + ids (->> (vals (get-in state [:workspace-data :shapes-by-id])) + (filter #(= (:canvas %) id)) + (map :id))] + (reduce hide state (cons id ids)))))) + +(defn show-canvas + [id] + (us/verify ::us/uuid id) + (ptk/reify ::hide-shape + IBatchedChange + ptk/UpdateEvent + (update [_ state] + (let [show #(impl-update-shape-hidden %1 %2 false) + ids (->> (vals (get-in state [:workspace-data :shapes-by-id])) + (filter #(= (:canvas %) id)) + (map :id))] + (reduce show state (cons id ids)))))) + (defn- impl-update-shape-hidden [state id hidden?] - (let [type (get-in state [:workspace-data :shapes-by-id id :type]) - state (update-in state [:workspace-data :shapes-by-id id] assoc :hidden hidden?)] - (cond-> state - (= type :canvas) - (update-in [:workspace-data :shapes-by-id] - (fn [shapes] - (reduce-kv (fn [shapes key {:keys [canvas] :as val}] - (cond-> shapes - (= id canvas) (update key assoc :hidden hidden?))) - shapes - shapes)))))) + (assoc-in state [:workspace-data :shapes-by-id id :hidden] hidden?)) ;; --- Shape Blocking diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/layers.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/layers.cljs index 43d70c1bd..4119c7870 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/layers.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/layers.cljs @@ -173,8 +173,8 @@ (fn [event] (dom/stop-propagation event) (if (:hidden canvas) - (st/emit! (dw/show-shape (:id canvas))) - (st/emit! (dw/hide-shape (:id canvas))))) + (st/emit! (dw/show-canvas (:id canvas))) + (st/emit! (dw/hide-canvas (:id canvas))))) select-shape (fn [event] @@ -274,7 +274,7 @@ data (mf/deref refs/workspace-data) shapes-map (:shapes-by-id data) - strip #(select-keys % [:id :canvas :name :type]) + strip #(select-keys % [:id :canvas :name :type :hidden :blocked]) canvas (->> (:canvas data) (map #(get shapes-map %))